From 646bbbc84b8010e0dacbeed5342cdb045f46cc49 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 27 Jun 2007 15:28:52 +0000 Subject: Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces. --- .../Communications/CommunicationsManager.cs | 51 ++++++++++ OpenSim/Framework/Communications/IGridServices.cs | 51 ++++++++++ .../Communications/IInterRegionCommunications.cs | 41 ++++++++ OpenSim/Framework/Communications/IUserServices.cs | 44 ++++++++ .../OpenSim.Framework.Communications.csproj | 112 +++++++++++++++++++++ .../OpenSim.Framework.Communications.csproj.user | 12 +++ .../Communications/Properties/AssemblyInfo.cs | 62 ++++++++++++ 7 files changed, 373 insertions(+) create mode 100644 OpenSim/Framework/Communications/CommunicationsManager.cs create mode 100644 OpenSim/Framework/Communications/IGridServices.cs create mode 100644 OpenSim/Framework/Communications/IInterRegionCommunications.cs create mode 100644 OpenSim/Framework/Communications/IUserServices.cs create mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj create mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user create mode 100644 OpenSim/Framework/Communications/Properties/AssemblyInfo.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs new file mode 100644 index 0000000..74d12d2 --- /dev/null +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -0,0 +1,51 @@ +/* +* 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 OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + + public class CommunicationsManager + { + public IUserServices UserServer; + public IGridServices GridServer; + public IInterRegionCommunications InterRegion; + + public CommunicationsManager(NetworkServersInfo serversInfo) + { + + } + } +} diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs new file mode 100644 index 0000000..a4812fb --- /dev/null +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -0,0 +1,51 @@ +/* +* 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.Text; +using OpenSim.Framework.Types; +using OpenSim.Framework; + +namespace OpenSim.Framework.Communications +{ + public class GridInfo + { + public string GridServerURI = "http://grid.deepgrid.com:8001/"; // Temporarily hardcoded. + public string GridServerSendKey = "badger"; + public string GridServerRecvKey = "badger"; + } + + public interface IGridServices + { + RegionCommsListener RegisterRegion(RegionInfo regionInfo, GridInfo gridInfo); + List RequestNeighbours(RegionInfo regionInfo); + RegionInfo RequestNeighbourInfo(ulong regionHandle); + List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); + } +} diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs new file mode 100644 index 0000000..7b0d340 --- /dev/null +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.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. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Types; +using OpenSim.Framework; + +namespace OpenSim.Framework.Communications +{ + public interface IInterRegionCommunications + { + bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); + bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position); + } +} diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs new file mode 100644 index 0000000..6790651 --- /dev/null +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -0,0 +1,44 @@ +/* +* 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.Text; +using libsecondlife; + +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications +{ + public interface IUserServices + { + UserProfileData GetUserProfile(string firstName, string lastName); + UserProfileData GetUserProfile(string name); + UserProfileData GetUserProfile(LLUUID avatarID); + + } +} diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj new file mode 100644 index 0000000..31ab172 --- /dev/null +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -0,0 +1,112 @@ + + + Local + 8.0.50727 + 2.0 + {CB52B7E7-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Framework.Communications + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.Communications + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\..\bin\ + False + False + False + 4 + + + + + ..\..\..\bin\libsecondlife.dll + False + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Data + {36B72A9B-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user new file mode 100644 index 0000000..6841907 --- /dev/null +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..83e7dd4 --- /dev/null +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -0,0 +1,62 @@ +/* +* 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.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("OpenGrid.Framework.Communications")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenGrid.Framework.Communications")] +[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("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] + +// 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")] -- cgit v1.1 From fe120533efd0ec6b2248d96b9a1f8b7637c5dadd Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 27 Jun 2007 17:12:32 +0000 Subject: *Updated prebuild.xml and ran prebuild again *Removed .user, .suo, and unneccessary files in /bin/Physics/ *OpenSim.sln should compile with nant and on windows now --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../OpenSim.Framework.Communications.csproj.user | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-) delete mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 31ab172..0ee62e9 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user deleted file mode 100644 index 6841907..0000000 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj.user +++ /dev/null @@ -1,12 +0,0 @@ - - - Debug - AnyCPU - C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\ - 8.0.50727 - ProjectFiles - 0 - - - - -- cgit v1.1 From 3456d951d89fbc83f742d40ca8ca2a1a79d414eb Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 28 Jun 2007 13:13:17 +0000 Subject: Imported the scripting changes, so now should be up to date with sugilite. --- .../OpenSim.Framework.Communications.csproj | 6 +-- .../OpenSim.Framework.Communications.dll.build | 47 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 0ee62e9..31ab172 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build new file mode 100644 index 0000000..52d29f6 --- /dev/null +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1 From bee543300fc812277e9a9478dc05b986e00ed44e Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 28 Jun 2007 14:45:46 +0000 Subject: *User Profile requests on OGS UserServer now uses XMLRPC instead of REST *Added base support for setting up a master user --- OpenSim/Framework/Communications/IUserServices.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index 6790651..37f4942 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -39,6 +39,9 @@ namespace OpenSim.Framework.Communications UserProfileData GetUserProfile(string firstName, string lastName); UserProfileData GetUserProfile(string name); UserProfileData GetUserProfile(LLUUID avatarID); - + + UserProfileData SetupMasterUser(string firstName, string lastName); + UserProfileData SetupMasterUser(string firstName, string lastName, string password); + } } -- cgit v1.1 From 108d89f89436556c8f4662197903c374db943f7d Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 28 Jun 2007 16:17:20 +0000 Subject: *Master User is now set up *Added support for getting user profile information from remote grid server (untested) *Updated prebuild.xml --- OpenSim/Framework/Communications/CommunicationsManager.cs | 3 ++- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 74d12d2..69b5da6 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -43,9 +43,10 @@ namespace OpenSim.Framework.Communications public IGridServices GridServer; public IInterRegionCommunications InterRegion; + public NetworkServersInfo ServersInfo; public CommunicationsManager(NetworkServersInfo serversInfo) { - + ServersInfo = serversInfo; } } } diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 31ab172..66507a8 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,9 +86,6 @@ - - Code - Code @@ -98,6 +95,9 @@ Code + + Code + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 52d29f6..1c55d8c 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ - + -- cgit v1.1 From fe0528b98cfc13d26ac7f1bf6bc23655be1f52e5 Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 28 Jun 2007 19:09:50 +0000 Subject: *Added UUIDNameRequest packet support (untested, but should work -- at least in sandbox mode) *Various small renamings --- .../Framework/Communications/CommunicationsManager.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 69b5da6..b17b37b 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -30,9 +30,11 @@ using System.Collections; using System.Collections.Generic; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using libsecondlife; +using libsecondlife.Packets; namespace OpenSim.Framework.Communications { @@ -48,5 +50,21 @@ namespace OpenSim.Framework.Communications { ServersInfo = serversInfo; } + + #region Packet Handlers + public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) + { + UserProfileData profileData = this.UserServer.GetUserProfile(uuid); + if (profileData != null) + { + UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); + packet.UUIDNameBlock[0].ID = profileData.UUID; + packet.UUIDNameBlock[0].FirstName = libsecondlife.Helpers.StringToField(profileData.username); + packet.UUIDNameBlock[0].LastName = libsecondlife.Helpers.StringToField(profileData.surname); + remote_client.OutPacket((Packet)packet); + } + + } + #endregion } } -- cgit v1.1 From 135e9b1f538ae77dfd8bf68139c960fb8e016c16 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 28 Jun 2007 19:35:20 +0000 Subject: * Removed J# language support because it has issues with Mono. --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 66507a8..31ab172 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,6 +86,9 @@ + + Code + Code @@ -95,9 +98,6 @@ Code - - Code - Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 1c55d8c..52d29f6 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ + - -- cgit v1.1 From 6b3777d3db323f2054aeff1ba4be3e78edef21b8 Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 29 Jun 2007 16:43:48 +0000 Subject: *Deleted Logger.cs from OpenSim.Framework --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 31ab172..0ee62e9 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 52d29f6..8b0e0f6 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ - + + - -- cgit v1.1 From 5e805656db1215518a344d6d5364629a4997fd47 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sun, 1 Jul 2007 13:17:27 +0000 Subject: Fixed SimpleApp - aka thankgoditssundaycommit * Updated SimpleApp with various introduced dependencies * Extracted ScenePrescence creation in Scene * removed try-catchall from UserManagerBase (that actually hid a bug) * Refactored RegionInfo * handle is calculated * it will explode upon accessing x,y,ip,port,externalip if not explicitly initialized * Removed superfluous 'ref' keywords * Removed a shitload of 'catch Exception e' that causes build warnings * Lots of small refactorings, renames et c * Ignored some bins --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 0ee62e9..31ab172 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 8b0e0f6..52d29f6 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ - - + + -- cgit v1.1 From 9800c05c1b3c7804466d6f3a9c38a739156625fd Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 1 Jul 2007 17:26:33 +0000 Subject: Started change to having SceneObject and then that having child Primitives which in turn have a Shape object (currently PrimitiveBaseShape). The plan is only for the SceneObject to interface with the physics engines. As a physics Entity should be able to have mulitple shapes connected to it. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index b17b37b..48ff40e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -54,13 +54,16 @@ namespace OpenSim.Framework.Communications #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { + System.Text.Encoding enc = System.Text.Encoding.ASCII; UserProfileData profileData = this.UserServer.GetUserProfile(uuid); if (profileData != null) { UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); + packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; + packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); packet.UUIDNameBlock[0].ID = profileData.UUID; - packet.UUIDNameBlock[0].FirstName = libsecondlife.Helpers.StringToField(profileData.username); - packet.UUIDNameBlock[0].LastName = libsecondlife.Helpers.StringToField(profileData.surname); + packet.UUIDNameBlock[0].FirstName = enc.GetBytes(profileData.username + "\0"); + packet.UUIDNameBlock[0].LastName = enc.GetBytes(profileData.surname +"\0"); remote_client.OutPacket((Packet)packet); } -- cgit v1.1 From 9b6b6d05d45cf0f754a0b26bf6240ef50be66563 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Jul 2007 14:37:29 +0000 Subject: * Optimized usings (the 'LL ate my scripts' commit) * added some licensing info --- OpenSim/Framework/Communications/CommunicationsManager.cs | 10 +++------- OpenSim/Framework/Communications/IGridServices.cs | 3 --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 7 ++----- OpenSim/Framework/Communications/IUserServices.cs | 4 ---- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 -- 5 files changed, 5 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 48ff40e..f90e766 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,16 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections; -using System.Collections.Generic; using System.Text; -using OpenSim.Framework; +using libsecondlife; +using libsecondlife.Packets; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; -using libsecondlife; -using libsecondlife.Packets; namespace OpenSim.Framework.Communications { @@ -54,7 +50,7 @@ namespace OpenSim.Framework.Communications #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - System.Text.Encoding enc = System.Text.Encoding.ASCII; + Encoding enc = Encoding.ASCII; UserProfileData profileData = this.UserServer.GetUserProfile(uuid); if (profileData != null) { diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index a4812fb..c168c20 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -26,11 +26,8 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using OpenSim.Framework.Types; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 7b0d340..55f12ac 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -25,17 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; +using libsecondlife; using OpenSim.Framework.Types; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { public interface IInterRegionCommunications { bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position); + bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position); } } diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index 37f4942..0b1f86c 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -25,11 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; - using OpenSim.Framework.Data; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 83e7dd4..09f6473 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -26,9 +26,7 @@ * */ 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. -- cgit v1.1 From e06ffb3981d29ddb3383690b4a05dc684813b6d9 Mon Sep 17 00:00:00 2001 From: mingchen Date: Tue, 3 Jul 2007 17:03:14 +0000 Subject: *Removed GridInfo class as it has been previously replaced with the much better NetworkServersInfo class *Got the GridServer in OGS1 to go through with registering the region, but the actual storage of the region isnt working right now. **After this is fixed, grid mode should work! --- OpenSim/Framework/Communications/IGridServices.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index c168c20..c296209 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -31,16 +31,11 @@ using OpenSim.Framework.Types; namespace OpenSim.Framework.Communications { - public class GridInfo - { - public string GridServerURI = "http://grid.deepgrid.com:8001/"; // Temporarily hardcoded. - public string GridServerSendKey = "badger"; - public string GridServerRecvKey = "badger"; - } + public interface IGridServices { - RegionCommsListener RegisterRegion(RegionInfo regionInfo, GridInfo gridInfo); + RegionCommsListener RegisterRegion(RegionInfo regionInfos); List RequestNeighbours(RegionInfo regionInfo); RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); -- cgit v1.1 From 583f2a9de8e503773a427facd5f81a82b40bd585 Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 5 Jul 2007 15:15:28 +0000 Subject: *Removed SimProfile.cs as it is no longer needed (in favor of SimProfileData) *Added simulator_data_request XMLRPC method to request data from the grid server about a sim instead of faking its login *Login is progressing, now just getting an XML error (http://pastebin.com/942515) -- if you can fix this, throw MingChen in IRC a Private Message --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 31ab172..0ee62e9 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 52d29f6..8b0e0f6 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ - + + - -- cgit v1.1 From 10ece46cf681f389b9ecce5e89b94d749a44e9c1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 8 Jul 2007 02:58:01 +0000 Subject: * Updating prebuild --- .../Communications/OpenSim.Framework.Communications.csproj | 6 +++--- .../Communications/OpenSim.Framework.Communications.dll.build | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj index 0ee62e9..31ab172 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj @@ -86,16 +86,16 @@ - + Code Code - + Code - + Code diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build index 8b0e0f6..52d29f6 100644 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build @@ -11,10 +11,10 @@ - - + + -- cgit v1.1 From 5f8de1e7045b9daa2d4f3b21ca826987e32efe6e Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sun, 8 Jul 2007 19:27:04 +0000 Subject: * By popular demand, all generated build files are now deleted. Somebody should make sure the wiki is updated. --- .../OpenSim.Framework.Communications.csproj | 112 --------------------- .../OpenSim.Framework.Communications.dll.build | 47 --------- 2 files changed, 159 deletions(-) delete mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj delete mode 100644 OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj deleted file mode 100644 index 31ab172..0000000 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.csproj +++ /dev/null @@ -1,112 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {CB52B7E7-0000-0000-0000-000000000000} - Debug - AnyCPU - - - - OpenSim.Framework.Communications - JScript - Grid - IE50 - false - Library - - OpenSim.Framework.Communications - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - True - 4096 - False - ..\..\..\bin\ - False - False - False - 4 - - - - False - 285212672 - False - - - TRACE - - False - 4096 - True - ..\..\..\bin\ - False - False - False - 4 - - - - - ..\..\..\bin\libsecondlife.dll - False - - - System.dll - False - - - System.Xml.dll - False - - - - - OpenSim.Framework - {8ACA2445-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Framework.Data - {36B72A9B-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - diff --git a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build b/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build deleted file mode 100644 index 52d29f6..0000000 --- a/OpenSim/Framework/Communications/OpenSim.Framework.Communications.dll.build +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.1 From 7f03246653a6f277505d2055528cbb8dd2e1f4c1 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 10 Jul 2007 17:56:31 +0000 Subject: Gird mode in sugilite should now work in so far as you should be able to login and move between regions in the same instance. Moving to regions in a different instance of opensim still needs implementing (working on it now). Also trying to look at the map in grid mode will crash the server. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index f90e766..109d027 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -31,6 +31,7 @@ using libsecondlife.Packets; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; +using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications { @@ -42,7 +43,7 @@ namespace OpenSim.Framework.Communications public IInterRegionCommunications InterRegion; public NetworkServersInfo ServersInfo; - public CommunicationsManager(NetworkServersInfo serversInfo) + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer) { ServersInfo = serversInfo; } -- cgit v1.1 From 2ceff87a02d9862497d1d8fa965851ae2d9c9b1b Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 11 Jul 2007 17:47:25 +0000 Subject: More work on UserProfile and inventory cache (still currently not enabled). Asset uploading over CAPS now works, and although inventory isn't really working yet, this should now at least enables texturing of prims. --- .../Communications/CommunicationsManager.cs | 4 + .../Framework/Communications/IInventoryServices.cs | 17 ++++ .../Communications/caches/CachedUserInfo.cs | 77 +++++++++++++++ .../Communications/caches/InventoryFolder.cs | 51 ++++++++++ .../Communications/caches/UserProfileCache.cs | 107 +++++++++++++++++++++ 5 files changed, 256 insertions(+) create mode 100644 OpenSim/Framework/Communications/IInventoryServices.cs create mode 100644 OpenSim/Framework/Communications/caches/CachedUserInfo.cs create mode 100644 OpenSim/Framework/Communications/caches/InventoryFolder.cs create mode 100644 OpenSim/Framework/Communications/caches/UserProfileCache.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 109d027..ebc9632 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -32,6 +32,7 @@ using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Servers; +using OpenSim.Framework.Communications.Caches; namespace OpenSim.Framework.Communications { @@ -40,12 +41,15 @@ namespace OpenSim.Framework.Communications { public IUserServices UserServer; public IGridServices GridServer; + public IInventoryServices InventoryServer; public IInterRegionCommunications InterRegion; + public UserProfileCache UserProfilesCache; public NetworkServersInfo ServersInfo; public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer) { ServersInfo = serversInfo; + UserProfilesCache = new UserProfileCache(this); } #region Packet Handlers diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs new file mode 100644 index 0000000..0b05834 --- /dev/null +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Data; +using libsecondlife; +using OpenSim.Framework.Communications.Caches; + +namespace OpenSim.Framework.Communications +{ + public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); + public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); + + public interface IInventoryServices + { + void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + } +} diff --git a/OpenSim/Framework/Communications/caches/CachedUserInfo.cs b/OpenSim/Framework/Communications/caches/CachedUserInfo.cs new file mode 100644 index 0000000..1c779e9 --- /dev/null +++ b/OpenSim/Framework/Communications/caches/CachedUserInfo.cs @@ -0,0 +1,77 @@ +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 new file mode 100644 index 0000000..eaddf19 --- /dev/null +++ b/OpenSim/Framework/Communications/caches/InventoryFolder.cs @@ -0,0 +1,51 @@ +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; + } + } +} diff --git a/OpenSim/Framework/Communications/caches/UserProfileCache.cs b/OpenSim/Framework/Communications/caches/UserProfileCache.cs new file mode 100644 index 0000000..0ee63ba --- /dev/null +++ b/OpenSim/Framework/Communications/caches/UserProfileCache.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +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); + this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + if (userInfo.UserProfile != null) + { + this.UserProfiles.Add(userID, userInfo); + } + else + { + //no profile for this user, what do we do now? + } + } + 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) + { + + } + + /// + /// 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) + { + + } + + /// + /// Make sure UserProfile is updated on user server + /// + /// + private void UpdateUserProfileToServer(LLUUID userID) + { + + } + + /// + /// Update Inventory data to Inventory server + /// + /// + private void UpdateInventoryToServer(LLUUID userID) + { + + } + } +} -- cgit v1.1 From 20a77a6d4b05ee15b7b04a81920d19462e6e542a Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 12 Jul 2007 15:16:19 +0000 Subject: Fixed a number of bugs in the local InstantMessage handling, sending InstantMessages will no longer crash the server. But they still aren't really working correctly, you can't type replies to received messages. --- OpenSim/Framework/Communications/IGridServices.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index c296209..d2e5ab6 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -31,8 +31,6 @@ using OpenSim.Framework.Types; namespace OpenSim.Framework.Communications { - - public interface IGridServices { RegionCommsListener RegisterRegion(RegionInfo regionInfos); -- cgit v1.1 From a0ac1f06e62bdfcf08264c8e89fb4e42a2d1f5d6 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 13 Jul 2007 07:19:00 +0000 Subject: * Moved SendNameReply to ClientView * Removed unused LoginService * Minor renames on BinaryStreamHandler --- .../Framework/Communications/CommunicationsManager.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index ebc9632..550372f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -55,20 +55,17 @@ namespace OpenSim.Framework.Communications #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - Encoding enc = Encoding.ASCII; UserProfileData profileData = this.UserServer.GetUserProfile(uuid); if (profileData != null) { - UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); - packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; - packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); - packet.UUIDNameBlock[0].ID = profileData.UUID; - packet.UUIDNameBlock[0].FirstName = enc.GetBytes(profileData.username + "\0"); - packet.UUIDNameBlock[0].LastName = enc.GetBytes(profileData.surname +"\0"); - remote_client.OutPacket((Packet)packet); - } - + LLUUID profileId = profileData.UUID; + string firstname = profileData.username; + string lastname = profileData.surname; + + remote_client.SendNameReply(profileId, firstname, lastname); + } } + #endregion } } -- cgit v1.1 From 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Jul 2007 15:40:11 +0000 Subject: changed to native line ending encoding --- .../Communications/CommunicationsManager.cs | 142 +++++++------- OpenSim/Framework/Communications/IGridServices.cs | 82 ++++---- .../Communications/IInterRegionCommunications.cs | 76 ++++---- .../Framework/Communications/IInventoryServices.cs | 34 ++-- OpenSim/Framework/Communications/IUserServices.cs | 86 ++++----- .../Communications/Properties/AssemblyInfo.cs | 120 ++++++------ .../Communications/caches/CachedUserInfo.cs | 154 +++++++-------- .../Communications/caches/InventoryFolder.cs | 102 +++++----- .../Communications/caches/UserProfileCache.cs | 214 ++++++++++----------- 9 files changed, 505 insertions(+), 505 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 550372f..db34d1b 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -1,71 +1,71 @@ -/* -* 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.Text; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Communications.Caches; - -namespace OpenSim.Framework.Communications -{ - - public class CommunicationsManager - { - public IUserServices UserServer; - public IGridServices GridServer; - public IInventoryServices InventoryServer; - public IInterRegionCommunications InterRegion; - public UserProfileCache UserProfilesCache; - - public NetworkServersInfo ServersInfo; - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer) - { - ServersInfo = serversInfo; - UserProfilesCache = new UserProfileCache(this); - } - - #region Packet Handlers - public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) - { - UserProfileData profileData = this.UserServer.GetUserProfile(uuid); - if (profileData != null) - { - LLUUID profileId = profileData.UUID; - string firstname = profileData.username; - string lastname = profileData.surname; - - remote_client.SendNameReply(profileId, firstname, lastname); - } - } - - #endregion - } -} +/* +* 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.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Communications.Caches; + +namespace OpenSim.Framework.Communications +{ + + public class CommunicationsManager + { + public IUserServices UserServer; + public IGridServices GridServer; + public IInventoryServices InventoryServer; + public IInterRegionCommunications InterRegion; + public UserProfileCache UserProfilesCache; + + public NetworkServersInfo ServersInfo; + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer) + { + ServersInfo = serversInfo; + UserProfilesCache = new UserProfileCache(this); + } + + #region Packet Handlers + public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) + { + UserProfileData profileData = this.UserServer.GetUserProfile(uuid); + if (profileData != null) + { + LLUUID profileId = profileData.UUID; + string firstname = profileData.username; + string lastname = profileData.surname; + + remote_client.SendNameReply(profileId, firstname, lastname); + } + } + + #endregion + } +} diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index d2e5ab6..1cfe2b6 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -1,41 +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. -* -*/ - -using System.Collections.Generic; -using OpenSim.Framework.Types; - -namespace OpenSim.Framework.Communications -{ - public interface IGridServices - { - RegionCommsListener RegisterRegion(RegionInfo regionInfos); - List RequestNeighbours(RegionInfo regionInfo); - RegionInfo RequestNeighbourInfo(ulong regionHandle); - List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); - } -} +/* +* 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.Generic; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Communications +{ + public interface IGridServices + { + RegionCommsListener RegisterRegion(RegionInfo regionInfos); + List RequestNeighbours(RegionInfo regionInfo); + RegionInfo RequestNeighbourInfo(ulong regionHandle); + List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); + } +} diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 55f12ac..7758f2b 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -1,38 +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. -* -*/ -using libsecondlife; -using OpenSim.Framework.Types; - -namespace OpenSim.Framework.Communications -{ - public interface IInterRegionCommunications - { - bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position); - } -} +/* +* 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; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Communications +{ + public interface IInterRegionCommunications + { + bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); + bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 0b05834..807952c 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Data; -using libsecondlife; -using OpenSim.Framework.Communications.Caches; - -namespace OpenSim.Framework.Communications -{ - public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); - public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); - - public interface IInventoryServices - { - void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Data; +using libsecondlife; +using OpenSim.Framework.Communications.Caches; + +namespace OpenSim.Framework.Communications +{ + public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); + public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); + + public interface IInventoryServices + { + void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + } +} diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index 0b1f86c..cd97b52 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -1,43 +1,43 @@ -/* -* 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; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications -{ - public interface IUserServices - { - UserProfileData GetUserProfile(string firstName, string lastName); - UserProfileData GetUserProfile(string name); - UserProfileData GetUserProfile(LLUUID avatarID); - - UserProfileData SetupMasterUser(string firstName, string lastName); - UserProfileData SetupMasterUser(string firstName, string lastName, string password); - - } -} +/* +* 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; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications +{ + public interface IUserServices + { + UserProfileData GetUserProfile(string firstName, string lastName); + UserProfileData GetUserProfile(string name); + UserProfileData GetUserProfile(LLUUID avatarID); + + UserProfileData SetupMasterUser(string firstName, string lastName); + UserProfileData SetupMasterUser(string firstName, string lastName, string password); + + } +} diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 09f6473..79f3e30 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -1,60 +1,60 @@ -/* -* 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.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("OpenGrid.Framework.Communications")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenGrid.Framework.Communications")] -[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("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] - -// 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")] +/* +* 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.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("OpenGrid.Framework.Communications")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenGrid.Framework.Communications")] +[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("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] + +// 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/Framework/Communications/caches/CachedUserInfo.cs b/OpenSim/Framework/Communications/caches/CachedUserInfo.cs index 1c779e9..b8d8847 100644 --- a/OpenSim/Framework/Communications/caches/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/caches/CachedUserInfo.cs @@ -1,77 +1,77 @@ -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); - } - } - } - - } - } - } -} +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 index eaddf19..af38b12 100644 --- a/OpenSim/Framework/Communications/caches/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/caches/InventoryFolder.cs @@ -1,51 +1,51 @@ -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; - } - } -} +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; + } + } +} diff --git a/OpenSim/Framework/Communications/caches/UserProfileCache.cs b/OpenSim/Framework/Communications/caches/UserProfileCache.cs index 0ee63ba..f651b8a 100644 --- a/OpenSim/Framework/Communications/caches/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/caches/UserProfileCache.cs @@ -1,107 +1,107 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -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); - this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); - if (userInfo.UserProfile != null) - { - this.UserProfiles.Add(userID, userInfo); - } - else - { - //no profile for this user, what do we do now? - } - } - 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) - { - - } - - /// - /// 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) - { - - } - - /// - /// Make sure UserProfile is updated on user server - /// - /// - private void UpdateUserProfileToServer(LLUUID userID) - { - - } - - /// - /// Update Inventory data to Inventory server - /// - /// - private void UpdateInventoryToServer(LLUUID userID) - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +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); + this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + if (userInfo.UserProfile != null) + { + this.UserProfiles.Add(userID, userInfo); + } + else + { + //no profile for this user, what do we do now? + } + } + 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) + { + + } + + /// + /// 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) + { + + } + + /// + /// Make sure UserProfile is updated on user server + /// + /// + private void UpdateUserProfileToServer(LLUUID userID) + { + + } + + /// + /// Update Inventory data to Inventory server + /// + /// + private void UpdateInventoryToServer(LLUUID userID) + { + + } + } +} -- cgit v1.1 From b2c6f316e16e9bb33f81997319a4130fa683bc48 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 19 Jul 2007 20:21:02 +0000 Subject: Some work on Inventory (not yet finished or enabled) --- .../Communications/caches/InventoryFolder.cs | 12 +++- .../Communications/caches/UserProfileCache.cs | 67 +++++++++++++++++++++- 2 files changed, 75 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/caches/InventoryFolder.cs b/OpenSim/Framework/Communications/caches/InventoryFolder.cs index af38b12..8978cee 100644 --- a/OpenSim/Framework/Communications/caches/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/caches/InventoryFolder.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications.Caches return returnFolder; } - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type ) { InventoryFolder subFold = new InventoryFolder(); subFold.name = folderName; @@ -47,5 +47,15 @@ namespace OpenSim.Framework.Communications.Caches 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 index f651b8a..bfb6f07 100644 --- a/OpenSim/Framework/Communications/caches/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/caches/UserProfileCache.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; using libsecondlife; +using OpenSim.Framework.Interfaces; using OpenSim.Framework.Data; using OpenSim.Framework.Communications; @@ -29,14 +30,17 @@ namespace OpenSim.Framework.Communications.Caches { CachedUserInfo userInfo = new CachedUserInfo(); userInfo.UserProfile = this.RequestUserProfileForUser(userID); - this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + 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 @@ -68,6 +72,52 @@ namespace OpenSim.Framework.Communications.Caches } + 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 /// @@ -81,9 +131,20 @@ namespace OpenSim.Framework.Communications.Caches /// Request Iventory Info from Inventory server /// /// - private void RequestInventoryForUser(LLUUID userID) + 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); } /// -- cgit v1.1 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 ---------- 21 files changed, 1004 insertions(+), 310 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 (limited to 'OpenSim/Framework/Communications') 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) - { - - } - } -} -- cgit v1.1 From 276011a0a149c5ea81dd106137889c840c10b738 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 22 Jul 2007 13:31:08 +0000 Subject: Think I've recovered my deleted files, so hopefully it works now. --- .../Framework/Communications/Cache/AssetCache.cs | 561 +++++++++++++++++++++ .../Cache/AssetTransactionManager.cs | 81 +++ .../Communications/Cache/AssetTransactions.cs | 275 ++++++++++ .../Communications/Cache/CachedUserInfo.cs | 94 ++++ .../Communications/Cache/InventoryFolder.cs | 109 ++++ .../Communications/Cache/UserProfileCache.cs | 170 +++++++ 6 files changed, 1290 insertions(+) create mode 100644 OpenSim/Framework/Communications/Cache/AssetCache.cs create mode 100644 OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs create mode 100644 OpenSim/Framework/Communications/Cache/AssetTransactions.cs create mode 100644 OpenSim/Framework/Communications/Cache/CachedUserInfo.cs create mode 100644 OpenSim/Framework/Communications/Cache/InventoryFolder.cs create mode 100644 OpenSim/Framework/Communications/Cache/UserProfileCache.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs new file mode 100644 index 0000000..3d0fd76 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -0,0 +1,561 @@ +/* +* 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.Reflection; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public delegate void DownloadComplete(AssetCache.TextureSender sender); + + public class AssetCache : IAssetReceiver + { + // Fields + private Thread _assetCacheThread; + private IAssetServer _assetServer; + public List AssetRequests; + public Dictionary Assets; + public Dictionary RequestedAssets; + public Dictionary RequestedTextures; + public Dictionary SendingTextures; + private LLUUID[] textureList; + public List TextureRequests; + public Dictionary Textures; + + // Methods + public AssetCache(IAssetServer assetServer) + { + this.AssetRequests = new List(); + this.TextureRequests = new List(); + this.RequestedAssets = new Dictionary(); + this.RequestedTextures = new Dictionary(); + this.SendingTextures = new Dictionary(); + this.textureList = new LLUUID[5]; + Console.WriteLine("Creating Asset cache"); + this._assetServer = assetServer; + this._assetServer.SetReceiver(this); + this.Assets = new Dictionary(); + this.Textures = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + } + + public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) + { + this.AssetRequests = new List(); + this.TextureRequests = new List(); + this.RequestedAssets = new Dictionary(); + this.RequestedTextures = new Dictionary(); + this.SendingTextures = new Dictionary(); + this.textureList = new LLUUID[5]; + Console.WriteLine("Creating Asset cache"); + this._assetServer = this.LoadAssetDll(assetServerDLLName); + this._assetServer.SetServerInfo(assetServerURL, assetServerKey); + this._assetServer.SetReceiver(this); + this.Assets = new Dictionary(); + this.Textures = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + } + + public void AddAsset(AssetBase asset) + { + if (asset.Type == 0) + { + if (!this.Textures.ContainsKey(asset.FullID)) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + this._assetServer.UploadNewAsset(asset); + } + } + else if (!this.Assets.ContainsKey(asset.FullID)) + { + AssetInfo info = new AssetInfo(asset); + this.Assets.Add(info.FullID, info); + this._assetServer.UploadNewAsset(asset); + } + } + + public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) + { + LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0); + if (!this.Assets.ContainsKey(assetID)) + { + if (!this.RequestedAssets.ContainsKey(assetID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = assetID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + this.RequestedAssets.Add(assetID, request); + this._assetServer.RequestAsset(assetID, false); + } + } + else + { + AssetInfo info = this.Assets[assetID]; + AssetRequest request2 = new AssetRequest(); + request2.RequestUser = userInfo; + request2.RequestAssetID = assetID; + request2.TransferRequestID = transferRequest.TransferInfo.TransferID; + request2.AssetInf = info; + if (info.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.AssetRequests.Add(request2); + } + } + + public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) + { + if (!this.Textures.ContainsKey(imageID)) + { + if (!this.RequestedTextures.ContainsKey(imageID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = imageID; + request.IsTextureRequest = true; + this.RequestedTextures.Add(imageID, request); + this._assetServer.RequestAsset(imageID, true); + } + } + else + { + TextureImage image = this.Textures[imageID]; + AssetRequest request2 = new AssetRequest(); + request2.RequestUser = userInfo; + request2.RequestAssetID = imageID; + request2.IsTextureRequest = true; + request2.ImageInfo = image; + if (image.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.TextureRequests.Add(request2); + } + } + + public void AssetNotFound(AssetBase asset) + { + } + + public void AssetReceived(AssetBase asset, bool IsTexture) + { + if (asset.FullID != LLUUID.Zero) + { + if (IsTexture) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + if (this.RequestedTextures.ContainsKey(image.FullID)) + { + AssetRequest request = this.RequestedTextures[image.FullID]; + request.ImageInfo = image; + if (image.Data.LongLength > 600) + { + request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request.NumPackets = 1; + } + this.RequestedTextures.Remove(image.FullID); + this.TextureRequests.Add(request); + } + } + else + { + AssetInfo info = new AssetInfo(asset); + this.Assets.Add(info.FullID, info); + if (this.RequestedAssets.ContainsKey(info.FullID)) + { + AssetRequest request2 = this.RequestedAssets[info.FullID]; + request2.AssetInf = info; + if (info.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.RequestedAssets.Remove(info.FullID); + this.AssetRequests.Add(request2); + } + } + } + } + + public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) + { + AssetInfo info = new AssetInfo(); + info.Data = new byte[sourceAsset.Data.Length]; + Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length); + info.FullID = LLUUID.Random(); + info.Type = sourceAsset.Type; + info.InvType = sourceAsset.InvType; + return info; + } + + public TextureImage CloneImage(LLUUID newOwner, TextureImage source) + { + TextureImage image = new TextureImage(); + image.Data = new byte[source.Data.Length]; + Array.Copy(source.Data, image.Data, source.Data.Length); + image.FullID = LLUUID.Random(); + image.Name = source.Name; + return image; + } + + public AssetBase[] CreateNewInventorySet(LLUUID agentID) + { + AssetBase[] baseArray = new AssetBase[this.textureList.Length]; + for (int i = 0; i < this.textureList.Length; i++) + { + if (this.Textures.ContainsKey(this.textureList[i])) + { + baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]); + TextureImage asset = new TextureImage(baseArray[i]); + this.Textures.Add(asset.FullID, asset); + this._assetServer.UploadNewAsset(asset); + } + } + return baseArray; + } + + public AssetBase GetAsset(LLUUID assetID) + { + AssetBase base2 = null; + if (this.Textures.ContainsKey(assetID)) + { + return this.Textures[assetID]; + } + if (this.Assets.ContainsKey(assetID)) + { + base2 = this.Assets[assetID]; + } + return base2; + } + + private IAssetServer LoadAssetDll(string dllName) + { + Assembly assembly = Assembly.LoadFrom(dllName); + IAssetServer assetServer = null; + foreach (Type type in assembly.GetTypes()) + { + if (type.IsPublic && !type.IsAbstract) + { + if (type.GetInterface("IAssetPlugin", true) != null) + { + assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer(); + break; + } + } + } + assembly = null; + return assetServer; + } + + public void LoadDefaultTextureSet() + { + this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); + this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); + this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); + this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); + this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); + for (int i = 0; i < this.textureList.Length; i++) + { + this._assetServer.RequestAsset(this.textureList[i], true); + } + } + + private void ProcessAssetQueue() + { + if (this.AssetRequests.Count != 0) + { + int num; + if (this.AssetRequests.Count < 5) + { + num = this.AssetRequests.Count; + } + else + { + num = 5; + } + for (int i = 0; i < num; i++) + { + AssetRequest request = this.AssetRequests[i]; + TransferInfoPacket newPack = new TransferInfoPacket(); + newPack.TransferInfo.ChannelType = 2; + newPack.TransferInfo.Status = 0; + newPack.TransferInfo.TargetType = 0; + newPack.TransferInfo.Params = request.RequestAssetID.GetBytes(); + newPack.TransferInfo.Size = request.AssetInf.Data.Length; + newPack.TransferInfo.TransferID = request.TransferRequestID; + request.RequestUser.OutPacket(newPack); + if (request.NumPackets == 1) + { + TransferPacketPacket packet2 = new TransferPacketPacket(); + packet2.TransferData.Packet = 0; + packet2.TransferData.ChannelType = 2; + packet2.TransferData.TransferID = request.TransferRequestID; + packet2.TransferData.Data = request.AssetInf.Data; + packet2.TransferData.Status = 1; + request.RequestUser.OutPacket(packet2); + } + else + { + TransferPacketPacket packet3 = new TransferPacketPacket(); + packet3.TransferData.Packet = 0; + packet3.TransferData.ChannelType = 2; + packet3.TransferData.TransferID = request.TransferRequestID; + byte[] destinationArray = new byte[0x3e8]; + Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8); + packet3.TransferData.Data = destinationArray; + packet3.TransferData.Status = 0; + request.RequestUser.OutPacket(packet3); + packet3 = new TransferPacketPacket(); + packet3.TransferData.Packet = 1; + packet3.TransferData.ChannelType = 2; + packet3.TransferData.TransferID = request.TransferRequestID; + byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8]; + Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length); + packet3.TransferData.Data = buffer2; + packet3.TransferData.Status = 1; + request.RequestUser.OutPacket(packet3); + } + } + for (int j = 0; j < num; j++) + { + this.AssetRequests.RemoveAt(0); + } + } + } + + private void ProcessTextureQueue() + { + if (this.TextureRequests.Count != 0) + { + int num = this.TextureRequests.Count; + for (int i = 0; i < num; i++) + { + AssetRequest req = this.TextureRequests[i]; + if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) + { + TextureSender sender = new TextureSender(req); + sender.OnComplete += new DownloadComplete(this.TextureSent); + lock (this.SendingTextures) + { + this.SendingTextures.Add(req.ImageInfo.FullID, sender); + } + } + } + this.TextureRequests.Clear(); + } + } + + public void RunAssetManager() + { + Label_0000: + try + { + this.ProcessAssetQueue(); + this.ProcessTextureQueue(); + Thread.Sleep(500); + goto Label_0000; + } + catch (Exception exception) + { + Console.WriteLine(exception.Message); + goto Label_0000; + } + } + + public void TextureSent(TextureSender sender) + { + if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) + { + lock (this.SendingTextures) + { + this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + } + } + } + + // Nested Types + public class AssetInfo : AssetBase + { + // Methods + public AssetInfo() + { + } + + public AssetInfo(AssetBase aBase) + { + base.Data = aBase.Data; + base.FullID = aBase.FullID; + base.Type = aBase.Type; + base.InvType = aBase.InvType; + base.Name = aBase.Name; + base.Description = aBase.Description; + } + } + + public class AssetRequest + { + // Fields + public AssetCache.AssetInfo AssetInf; + public long DataPointer; + public AssetCache.TextureImage ImageInfo; + public bool IsTextureRequest; + public int NumPackets; + public int PacketCounter; + public LLUUID RequestAssetID; + public IClientAPI RequestUser; + public LLUUID TransferRequestID; + } + + public class TextureImage : AssetBase + { + // Methods + public TextureImage() + { + } + + public TextureImage(AssetBase aBase) + { + base.Data = aBase.Data; + base.FullID = aBase.FullID; + base.Type = aBase.Type; + base.InvType = aBase.InvType; + base.Name = aBase.Name; + base.Description = aBase.Description; + } + } + + public class TextureSender + { + // Fields + private Thread m_thread; + public AssetCache.AssetRequest request; + + // Events + public event DownloadComplete OnComplete; + + // Methods + public TextureSender(AssetCache.AssetRequest req) + { + this.request = req; + this.m_thread = new Thread(new ThreadStart(this.SendTexture)); + this.m_thread.IsBackground = true; + this.m_thread.Start(); + } + + public void SendPacket() + { + AssetCache.AssetRequest request = this.request; + if (request.PacketCounter == 0) + { + if (request.NumPackets == 1) + { + ImageDataPacket newPack = new ImageDataPacket(); + newPack.ImageID.Packets = 1; + newPack.ImageID.ID = request.ImageInfo.FullID; + newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length; + newPack.ImageData.Data = request.ImageInfo.Data; + newPack.ImageID.Codec = 2; + request.RequestUser.OutPacket(newPack); + request.PacketCounter++; + } + else + { + ImageDataPacket packet2 = new ImageDataPacket(); + packet2.ImageID.Packets = (ushort)request.NumPackets; + packet2.ImageID.ID = request.ImageInfo.FullID; + packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length; + packet2.ImageData.Data = new byte[600]; + Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600); + packet2.ImageID.Codec = 2; + request.RequestUser.OutPacket(packet2); + request.PacketCounter++; + } + } + else + { + ImagePacketPacket packet3 = new ImagePacketPacket(); + packet3.ImageID.Packet = (ushort)request.PacketCounter; + packet3.ImageID.ID = request.ImageInfo.FullID; + int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1)); + if (length > 0x3e8) + { + length = 0x3e8; + } + packet3.ImageData.Data = new byte[length]; + Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length); + request.RequestUser.OutPacket(packet3); + request.PacketCounter++; + } + } + + public void SendTexture() + { + while (this.request.PacketCounter != this.request.NumPackets) + { + this.SendPacket(); + Thread.Sleep(500); + } + if (this.OnComplete != null) + { + this.OnComplete(this); + } + } + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs new file mode 100644 index 0000000..8b485af --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -0,0 +1,81 @@ +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications.Caches +{ + public class AssetTransactionManager + { + // Fields + public Dictionary AgentTransactions = new Dictionary(); + + // Methods + public AgentAssetTransactions AddUser(LLUUID userID) + { + if (!this.AgentTransactions.ContainsKey(userID)) + { + AgentAssetTransactions transactions = new AgentAssetTransactions(userID); + this.AgentTransactions.Add(userID, transactions); + return transactions; + } + return null; + } + + public AgentAssetTransactions GetUserTransActions(LLUUID userID) + { + if (this.AgentTransactions.ContainsKey(userID)) + { + return this.AgentTransactions[userID]; + } + return null; + } + + public void HandleInventoryFromTransaction() + { + } + + public void HandleUDPUploadRequest() + { + } + + public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) + { + } + } +} + + diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs new file mode 100644 index 0000000..bb9c069 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -0,0 +1,275 @@ +/* +* 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 libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Capabilities; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.Communications.Caches +{ + public class AgentAssetTransactions + { + // Fields + public List CapsUploaders = new List(); + public List NotecardUpdaters = new List(); + public LLUUID UserID; + public Dictionary XferUploaders = new Dictionary(); + + // Methods + public AgentAssetTransactions(LLUUID agentID) + { + this.UserID = agentID; + } + + public AssetCapsUploader RequestCapsUploader() + { + AssetCapsUploader uploader = new AssetCapsUploader(); + this.CapsUploaders.Add(uploader); + return uploader; + } + + public NoteCardCapsUpdate RequestNoteCardUpdater() + { + NoteCardCapsUpdate update = new NoteCardCapsUpdate(); + this.NotecardUpdaters.Add(update); + return update; + } + + public AssetXferUploader RequestXferUploader(LLUUID transactionID) + { + AssetXferUploader uploader = new AssetXferUploader(); + this.XferUploaders.Add(transactionID, uploader); + return uploader; + } + + // Nested Types + public class AssetCapsUploader + { + // Fields + private BaseHttpServer httpListener; + private LLUUID inventoryItemID; + private string m_assetDescription = ""; + private string m_assetName = ""; + private LLUUID m_folderID; + private LLUUID newAssetID; + private bool SaveImages; + private string uploaderPath = ""; + + // Events + public event UpLoadedTexture OnUpLoad; + + // Methods + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) + { + this.m_assetName = assetName; + this.m_assetDescription = assetDescription; + this.m_folderID = folderID; + this.newAssetID = assetID; + this.inventoryItemID = inventoryItem; + this.uploaderPath = path; + this.httpListener = httpServer; + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream output = File.Create(filename); + BinaryWriter writer = new BinaryWriter(output); + writer.Write(data); + writer.Close(); + output.Close(); + } + + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inventoryItemID = this.inventoryItemID; + string text = ""; + LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); + complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_inventory_item = inventoryItemID; + complete.state = "complete"; + text = LLSDHelpers.SerialiseLLSDReply(complete); + this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); + if (this.SaveImages) + { + this.SaveImageToFile(this.m_assetName + ".jp2", data); + } + if (this.OnUpLoad != null) + { + this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + } + return text; + } + } + + public class AssetXferUploader + { + // Fields + public bool AddToInventory; + public AssetBase Asset; + public LLUUID InventFolder = LLUUID.Zero; + private IClientAPI ourClient; + public LLUUID TransactionID = LLUUID.Zero; + public bool UploadComplete; + public uint XferID; + + // Methods + public void HandleXferPacket(uint xferID, uint packetID, byte[] data) + { + if (this.XferID == xferID) + { + if (this.Asset.Data.Length > 1) + { + byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; + Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); + Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); + this.Asset.Data = destinationArray; + } + else + { + byte[] buffer2 = new byte[data.Length - 4]; + Array.Copy(data, 4, buffer2, 0, data.Length - 4); + this.Asset.Data = buffer2; + } + ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); + newPack.XferID.ID = xferID; + newPack.XferID.Packet = packetID; + this.ourClient.OutPacket(newPack); + if ((packetID & 0x80000000) != 0) + { + this.SendCompleteMessage(); + } + } + } + + public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) + { + this.ourClient = remoteClient; + this.Asset = new AssetBase(); + this.Asset.FullID = assetID; + this.Asset.InvType = type; + this.Asset.Type = type; + this.Asset.Data = data; + this.Asset.Name = "blank"; + this.Asset.Description = "empty"; + this.TransactionID = transaction; + if (this.Asset.Data.Length > 2) + { + this.SendCompleteMessage(); + } + else + { + this.ReqestStartXfer(); + } + } + + protected void ReqestStartXfer() + { + this.UploadComplete = false; + this.XferID = Util.GetNextXferID(); + RequestXferPacket newPack = new RequestXferPacket(); + newPack.XferID.ID = this.XferID; + newPack.XferID.VFileType = this.Asset.Type; + newPack.XferID.VFileID = this.Asset.FullID; + newPack.XferID.FilePath = 0; + newPack.XferID.Filename = new byte[0]; + this.ourClient.OutPacket(newPack); + } + + protected void SendCompleteMessage() + { + this.UploadComplete = true; + AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); + newPack.AssetBlock.Type = this.Asset.Type; + newPack.AssetBlock.Success = true; + newPack.AssetBlock.UUID = this.Asset.FullID; + this.ourClient.OutPacket(newPack); + } + } + + public class NoteCardCapsUpdate + { + // Fields + private BaseHttpServer httpListener; + private LLUUID inventoryItemID; + private string m_assetName = ""; + private LLUUID newAssetID; + private bool SaveImages; + private string uploaderPath = ""; + + // Events + public event UpLoadedTexture OnUpLoad; + + // Methods + public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) + { + this.inventoryItemID = inventoryItem; + this.uploaderPath = path; + this.httpListener = httpServer; + this.newAssetID = LLUUID.Random(); + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream output = File.Create(filename); + BinaryWriter writer = new BinaryWriter(output); + writer.Write(data); + writer.Close(); + output.Close(); + } + + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inventoryItemID = this.inventoryItemID; + string text = ""; + LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); + complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_inventory_item = inventoryItemID; + complete.state = "complete"; + text = LLSDHelpers.SerialiseLLSDReply(complete); + this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); + if (this.SaveImages) + { + this.SaveImageToFile(this.m_assetName + "notecard.txt", data); + } + if (this.OnUpLoad != null) + { + this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + } + return text; + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs new file mode 100644 index 0000000..2660df3 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -0,0 +1,94 @@ +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Data; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public class CachedUserInfo + { + // Fields + public InventoryFolder RootFolder; + public UserProfileData UserProfile; + + // Methods + public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) + { + if (userID == this.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 folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + if (folder != null) + { + folder.SubFolders.Add(folderInfo.folderID, folderInfo); + } + } + } + } + + public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) + { + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + if (itemInfo.parentFolderID == this.RootFolder.folderID) + { + this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + } + else + { + InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + if (folder != null) + { + folder.Items.Add(itemInfo.inventoryID, itemInfo); + } + } + } + } + } +} + diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs new file mode 100644 index 0000000..8670eb0 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -0,0 +1,109 @@ +/* +* 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.Interfaces; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public class InventoryFolder : InventoryFolderBase + { + // Fields + public Dictionary Items = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); + + // Methods + 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 InventoryItemBase HasItem(LLUUID itemID) + { + InventoryItemBase base2 = null; + if (this.Items.ContainsKey(itemID)) + { + return this.Items[itemID]; + } + foreach (InventoryFolder folder in this.SubFolders.Values) + { + base2 = folder.HasItem(itemID); + if (base2 != null) + { + break; + } + } + return base2; + } + + 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 List RequestListOfItems() + { + List itemList = new List(); + foreach (InventoryItemBase item in this.Items.Values) + { + itemList.Add(item); + } + return itemList; + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs new file mode 100644 index 0000000..8210702 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -0,0 +1,170 @@ +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class UserProfileCache + { + // Fields + private CommunicationsManager m_parent; + public Dictionary UserProfiles = new Dictionary(); + + // Methods + public UserProfileCache(CommunicationsManager parent) + { + this.m_parent = parent; + } + + 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 + { + Console.WriteLine("UserProfileCache.cs: user profile for user not found"); + } + } + } + + public void AddNewUser(string firstName, string lastName) + { + } + + public CachedUserInfo GetUserDetails(LLUUID userID) + { + if (this.UserProfiles.ContainsKey(userID)) + { + return this.UserProfiles[userID]; + } + return null; + } + + public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) + { + if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + { + CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == parentID) + { + info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + } + else + { + InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); + if (folder != null) + { + folder.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 info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == folderID) + { + if (fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + } + } + else + { + InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); + if ((folder != null) && fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + } + } + } + } + + public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) + { + if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + { + InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + if (item != null) + { + remoteClient.SendInventoryItemDetails(ownerID, item); + } + } + } + + private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) + { + InventoryFolder folderInfo = new InventoryFolder(); + folderInfo.agentID = userID; + folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; + folderInfo.name = "My Inventory"; + folderInfo.parentID = LLUUID.Zero; + folderInfo.type = 8; + folderInfo.version = 1; + userInfo.FolderReceive(userID, folderInfo); + } + + private UserProfileData RequestUserProfileForUser(LLUUID userID) + { + return this.m_parent.UserServer.GetUserProfile(userID); + } + + private void UpdateInventoryToServer(LLUUID userID) + { + } + + private void UpdateUserProfileToServer(LLUUID userID) + { + } + + public void UserLogOut(LLUUID userID) + { + } + } +} + -- cgit v1.1 From 5db16cbd9b062976ff519a41dc756c4aea6c5b02 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 22 Jul 2007 13:41:19 +0000 Subject: Couple of small changes --- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index bb9c069..6741969 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -85,7 +85,7 @@ namespace OpenSim.Framework.Communications.Caches private string m_assetName = ""; private LLUUID m_folderID; private LLUUID newAssetID; - private bool SaveImages; + private bool SaveImages = false; private string uploaderPath = ""; // Events @@ -226,7 +226,7 @@ namespace OpenSim.Framework.Communications.Caches private LLUUID inventoryItemID; private string m_assetName = ""; private LLUUID newAssetID; - private bool SaveImages; + private bool SaveImages = false; private string uploaderPath = ""; // Events -- cgit v1.1 From 2b42ea0a429c722bd7c5c67d3815c2ddc8399e78 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 25 Jul 2007 18:19:38 +0000 Subject: Start of the OpenSim library , for now only contains a few textures. --- .../Framework/Communications/Cache/AssetCache.cs | 1122 ++++++++++---------- .../Cache/AssetTransactionManager.cs | 162 +-- .../Communications/Cache/AssetTransactions.cs | 548 +++++----- .../Communications/Cache/CachedUserInfo.cs | 188 ++-- .../Communications/Cache/InventoryFolder.cs | 218 ++-- .../Communications/Cache/LibraryRootFolder.cs | 89 ++ .../Communications/Cache/UserProfileCache.cs | 386 ++++--- .../Communications/CommunicationsManager.cs | 25 +- 8 files changed, 1440 insertions(+), 1298 deletions(-) create mode 100644 OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3d0fd76..a3480ec 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -1,561 +1,561 @@ -/* -* 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.Reflection; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - public delegate void DownloadComplete(AssetCache.TextureSender sender); - - public class AssetCache : IAssetReceiver - { - // Fields - private Thread _assetCacheThread; - private IAssetServer _assetServer; - public List AssetRequests; - public Dictionary Assets; - public Dictionary RequestedAssets; - public Dictionary RequestedTextures; - public Dictionary SendingTextures; - private LLUUID[] textureList; - public List TextureRequests; - public Dictionary Textures; - - // Methods - public AssetCache(IAssetServer assetServer) - { - this.AssetRequests = new List(); - this.TextureRequests = new List(); - this.RequestedAssets = new Dictionary(); - this.RequestedTextures = new Dictionary(); - this.SendingTextures = new Dictionary(); - this.textureList = new LLUUID[5]; - Console.WriteLine("Creating Asset cache"); - this._assetServer = assetServer; - this._assetServer.SetReceiver(this); - this.Assets = new Dictionary(); - this.Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - } - - public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) - { - this.AssetRequests = new List(); - this.TextureRequests = new List(); - this.RequestedAssets = new Dictionary(); - this.RequestedTextures = new Dictionary(); - this.SendingTextures = new Dictionary(); - this.textureList = new LLUUID[5]; - Console.WriteLine("Creating Asset cache"); - this._assetServer = this.LoadAssetDll(assetServerDLLName); - this._assetServer.SetServerInfo(assetServerURL, assetServerKey); - this._assetServer.SetReceiver(this); - this.Assets = new Dictionary(); - this.Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - } - - public void AddAsset(AssetBase asset) - { - if (asset.Type == 0) - { - if (!this.Textures.ContainsKey(asset.FullID)) - { - TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - this._assetServer.UploadNewAsset(asset); - } - } - else if (!this.Assets.ContainsKey(asset.FullID)) - { - AssetInfo info = new AssetInfo(asset); - this.Assets.Add(info.FullID, info); - this._assetServer.UploadNewAsset(asset); - } - } - - public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) - { - LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0); - if (!this.Assets.ContainsKey(assetID)) - { - if (!this.RequestedAssets.ContainsKey(assetID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = assetID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - this.RequestedAssets.Add(assetID, request); - this._assetServer.RequestAsset(assetID, false); - } - } - else - { - AssetInfo info = this.Assets[assetID]; - AssetRequest request2 = new AssetRequest(); - request2.RequestUser = userInfo; - request2.RequestAssetID = assetID; - request2.TransferRequestID = transferRequest.TransferInfo.TransferID; - request2.AssetInf = info; - if (info.Data.LongLength > 600) - { - request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else - { - request2.NumPackets = 1; - } - this.AssetRequests.Add(request2); - } - } - - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) - { - if (!this.Textures.ContainsKey(imageID)) - { - if (!this.RequestedTextures.ContainsKey(imageID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = imageID; - request.IsTextureRequest = true; - this.RequestedTextures.Add(imageID, request); - this._assetServer.RequestAsset(imageID, true); - } - } - else - { - TextureImage image = this.Textures[imageID]; - AssetRequest request2 = new AssetRequest(); - request2.RequestUser = userInfo; - request2.RequestAssetID = imageID; - request2.IsTextureRequest = true; - request2.ImageInfo = image; - if (image.Data.LongLength > 600) - { - request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else - { - request2.NumPackets = 1; - } - this.TextureRequests.Add(request2); - } - } - - public void AssetNotFound(AssetBase asset) - { - } - - public void AssetReceived(AssetBase asset, bool IsTexture) - { - if (asset.FullID != LLUUID.Zero) - { - if (IsTexture) - { - TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - if (this.RequestedTextures.ContainsKey(image.FullID)) - { - AssetRequest request = this.RequestedTextures[image.FullID]; - request.ImageInfo = image; - if (image.Data.LongLength > 600) - { - request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else - { - request.NumPackets = 1; - } - this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(request); - } - } - else - { - AssetInfo info = new AssetInfo(asset); - this.Assets.Add(info.FullID, info); - if (this.RequestedAssets.ContainsKey(info.FullID)) - { - AssetRequest request2 = this.RequestedAssets[info.FullID]; - request2.AssetInf = info; - if (info.Data.LongLength > 600) - { - request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else - { - request2.NumPackets = 1; - } - this.RequestedAssets.Remove(info.FullID); - this.AssetRequests.Add(request2); - } - } - } - } - - public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) - { - AssetInfo info = new AssetInfo(); - info.Data = new byte[sourceAsset.Data.Length]; - Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length); - info.FullID = LLUUID.Random(); - info.Type = sourceAsset.Type; - info.InvType = sourceAsset.InvType; - return info; - } - - public TextureImage CloneImage(LLUUID newOwner, TextureImage source) - { - TextureImage image = new TextureImage(); - image.Data = new byte[source.Data.Length]; - Array.Copy(source.Data, image.Data, source.Data.Length); - image.FullID = LLUUID.Random(); - image.Name = source.Name; - return image; - } - - public AssetBase[] CreateNewInventorySet(LLUUID agentID) - { - AssetBase[] baseArray = new AssetBase[this.textureList.Length]; - for (int i = 0; i < this.textureList.Length; i++) - { - if (this.Textures.ContainsKey(this.textureList[i])) - { - baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]); - TextureImage asset = new TextureImage(baseArray[i]); - this.Textures.Add(asset.FullID, asset); - this._assetServer.UploadNewAsset(asset); - } - } - return baseArray; - } - - public AssetBase GetAsset(LLUUID assetID) - { - AssetBase base2 = null; - if (this.Textures.ContainsKey(assetID)) - { - return this.Textures[assetID]; - } - if (this.Assets.ContainsKey(assetID)) - { - base2 = this.Assets[assetID]; - } - return base2; - } - - private IAssetServer LoadAssetDll(string dllName) - { - Assembly assembly = Assembly.LoadFrom(dllName); - IAssetServer assetServer = null; - foreach (Type type in assembly.GetTypes()) - { - if (type.IsPublic && !type.IsAbstract) - { - if (type.GetInterface("IAssetPlugin", true) != null) - { - assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer(); - break; - } - } - } - assembly = null; - return assetServer; - } - - public void LoadDefaultTextureSet() - { - this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); - this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); - this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); - this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); - this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); - for (int i = 0; i < this.textureList.Length; i++) - { - this._assetServer.RequestAsset(this.textureList[i], true); - } - } - - private void ProcessAssetQueue() - { - if (this.AssetRequests.Count != 0) - { - int num; - if (this.AssetRequests.Count < 5) - { - num = this.AssetRequests.Count; - } - else - { - num = 5; - } - for (int i = 0; i < num; i++) - { - AssetRequest request = this.AssetRequests[i]; - TransferInfoPacket newPack = new TransferInfoPacket(); - newPack.TransferInfo.ChannelType = 2; - newPack.TransferInfo.Status = 0; - newPack.TransferInfo.TargetType = 0; - newPack.TransferInfo.Params = request.RequestAssetID.GetBytes(); - newPack.TransferInfo.Size = request.AssetInf.Data.Length; - newPack.TransferInfo.TransferID = request.TransferRequestID; - request.RequestUser.OutPacket(newPack); - if (request.NumPackets == 1) - { - TransferPacketPacket packet2 = new TransferPacketPacket(); - packet2.TransferData.Packet = 0; - packet2.TransferData.ChannelType = 2; - packet2.TransferData.TransferID = request.TransferRequestID; - packet2.TransferData.Data = request.AssetInf.Data; - packet2.TransferData.Status = 1; - request.RequestUser.OutPacket(packet2); - } - else - { - TransferPacketPacket packet3 = new TransferPacketPacket(); - packet3.TransferData.Packet = 0; - packet3.TransferData.ChannelType = 2; - packet3.TransferData.TransferID = request.TransferRequestID; - byte[] destinationArray = new byte[0x3e8]; - Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8); - packet3.TransferData.Data = destinationArray; - packet3.TransferData.Status = 0; - request.RequestUser.OutPacket(packet3); - packet3 = new TransferPacketPacket(); - packet3.TransferData.Packet = 1; - packet3.TransferData.ChannelType = 2; - packet3.TransferData.TransferID = request.TransferRequestID; - byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8]; - Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length); - packet3.TransferData.Data = buffer2; - packet3.TransferData.Status = 1; - request.RequestUser.OutPacket(packet3); - } - } - for (int j = 0; j < num; j++) - { - this.AssetRequests.RemoveAt(0); - } - } - } - - private void ProcessTextureQueue() - { - if (this.TextureRequests.Count != 0) - { - int num = this.TextureRequests.Count; - for (int i = 0; i < num; i++) - { - AssetRequest req = this.TextureRequests[i]; - if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) - { - TextureSender sender = new TextureSender(req); - sender.OnComplete += new DownloadComplete(this.TextureSent); - lock (this.SendingTextures) - { - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - } - } - } - this.TextureRequests.Clear(); - } - } - - public void RunAssetManager() - { - Label_0000: - try - { - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); - Thread.Sleep(500); - goto Label_0000; - } - catch (Exception exception) - { - Console.WriteLine(exception.Message); - goto Label_0000; - } - } - - public void TextureSent(TextureSender sender) - { - if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) - { - lock (this.SendingTextures) - { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - } - } - } - - // Nested Types - public class AssetInfo : AssetBase - { - // Methods - public AssetInfo() - { - } - - public AssetInfo(AssetBase aBase) - { - base.Data = aBase.Data; - base.FullID = aBase.FullID; - base.Type = aBase.Type; - base.InvType = aBase.InvType; - base.Name = aBase.Name; - base.Description = aBase.Description; - } - } - - public class AssetRequest - { - // Fields - public AssetCache.AssetInfo AssetInf; - public long DataPointer; - public AssetCache.TextureImage ImageInfo; - public bool IsTextureRequest; - public int NumPackets; - public int PacketCounter; - public LLUUID RequestAssetID; - public IClientAPI RequestUser; - public LLUUID TransferRequestID; - } - - public class TextureImage : AssetBase - { - // Methods - public TextureImage() - { - } - - public TextureImage(AssetBase aBase) - { - base.Data = aBase.Data; - base.FullID = aBase.FullID; - base.Type = aBase.Type; - base.InvType = aBase.InvType; - base.Name = aBase.Name; - base.Description = aBase.Description; - } - } - - public class TextureSender - { - // Fields - private Thread m_thread; - public AssetCache.AssetRequest request; - - // Events - public event DownloadComplete OnComplete; - - // Methods - public TextureSender(AssetCache.AssetRequest req) - { - this.request = req; - this.m_thread = new Thread(new ThreadStart(this.SendTexture)); - this.m_thread.IsBackground = true; - this.m_thread.Start(); - } - - public void SendPacket() - { - AssetCache.AssetRequest request = this.request; - if (request.PacketCounter == 0) - { - if (request.NumPackets == 1) - { - ImageDataPacket newPack = new ImageDataPacket(); - newPack.ImageID.Packets = 1; - newPack.ImageID.ID = request.ImageInfo.FullID; - newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length; - newPack.ImageData.Data = request.ImageInfo.Data; - newPack.ImageID.Codec = 2; - request.RequestUser.OutPacket(newPack); - request.PacketCounter++; - } - else - { - ImageDataPacket packet2 = new ImageDataPacket(); - packet2.ImageID.Packets = (ushort)request.NumPackets; - packet2.ImageID.ID = request.ImageInfo.FullID; - packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length; - packet2.ImageData.Data = new byte[600]; - Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600); - packet2.ImageID.Codec = 2; - request.RequestUser.OutPacket(packet2); - request.PacketCounter++; - } - } - else - { - ImagePacketPacket packet3 = new ImagePacketPacket(); - packet3.ImageID.Packet = (ushort)request.PacketCounter; - packet3.ImageID.ID = request.ImageInfo.FullID; - int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1)); - if (length > 0x3e8) - { - length = 0x3e8; - } - packet3.ImageData.Data = new byte[length]; - Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length); - request.RequestUser.OutPacket(packet3); - request.PacketCounter++; - } - } - - public void SendTexture() - { - while (this.request.PacketCounter != this.request.NumPackets) - { - this.SendPacket(); - Thread.Sleep(500); - } - if (this.OnComplete != null) - { - this.OnComplete(this); - } - } - } - } -} +/* +* 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.Reflection; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public delegate void DownloadComplete(AssetCache.TextureSender sender); + + public class AssetCache : IAssetReceiver + { + // Fields + private Thread _assetCacheThread; + private IAssetServer _assetServer; + public List AssetRequests; + public Dictionary Assets; + public Dictionary RequestedAssets; + public Dictionary RequestedTextures; + public Dictionary SendingTextures; + private LLUUID[] textureList; + public List TextureRequests; + public Dictionary Textures; + + // Methods + public AssetCache(IAssetServer assetServer) + { + this.AssetRequests = new List(); + this.TextureRequests = new List(); + this.RequestedAssets = new Dictionary(); + this.RequestedTextures = new Dictionary(); + this.SendingTextures = new Dictionary(); + this.textureList = new LLUUID[5]; + Console.WriteLine("Creating Asset cache"); + this._assetServer = assetServer; + this._assetServer.SetReceiver(this); + this.Assets = new Dictionary(); + this.Textures = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + } + + public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) + { + this.AssetRequests = new List(); + this.TextureRequests = new List(); + this.RequestedAssets = new Dictionary(); + this.RequestedTextures = new Dictionary(); + this.SendingTextures = new Dictionary(); + this.textureList = new LLUUID[5]; + Console.WriteLine("Creating Asset cache"); + this._assetServer = this.LoadAssetDll(assetServerDLLName); + this._assetServer.SetServerInfo(assetServerURL, assetServerKey); + this._assetServer.SetReceiver(this); + this.Assets = new Dictionary(); + this.Textures = new Dictionary(); + this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + this._assetCacheThread.IsBackground = true; + this._assetCacheThread.Start(); + } + + public void AddAsset(AssetBase asset) + { + if (asset.Type == 0) + { + if (!this.Textures.ContainsKey(asset.FullID)) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + this._assetServer.UploadNewAsset(asset); + } + } + else if (!this.Assets.ContainsKey(asset.FullID)) + { + AssetInfo info = new AssetInfo(asset); + this.Assets.Add(info.FullID, info); + this._assetServer.UploadNewAsset(asset); + } + } + + public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) + { + LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0); + if (!this.Assets.ContainsKey(assetID)) + { + if (!this.RequestedAssets.ContainsKey(assetID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = assetID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + this.RequestedAssets.Add(assetID, request); + this._assetServer.RequestAsset(assetID, false); + } + } + else + { + AssetInfo info = this.Assets[assetID]; + AssetRequest request2 = new AssetRequest(); + request2.RequestUser = userInfo; + request2.RequestAssetID = assetID; + request2.TransferRequestID = transferRequest.TransferInfo.TransferID; + request2.AssetInf = info; + if (info.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.AssetRequests.Add(request2); + } + } + + public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) + { + if (!this.Textures.ContainsKey(imageID)) + { + if (!this.RequestedTextures.ContainsKey(imageID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = imageID; + request.IsTextureRequest = true; + this.RequestedTextures.Add(imageID, request); + this._assetServer.RequestAsset(imageID, true); + } + } + else + { + TextureImage image = this.Textures[imageID]; + AssetRequest request2 = new AssetRequest(); + request2.RequestUser = userInfo; + request2.RequestAssetID = imageID; + request2.IsTextureRequest = true; + request2.ImageInfo = image; + if (image.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.TextureRequests.Add(request2); + } + } + + public void AssetNotFound(AssetBase asset) + { + } + + public void AssetReceived(AssetBase asset, bool IsTexture) + { + if (asset.FullID != LLUUID.Zero) + { + if (IsTexture) + { + TextureImage image = new TextureImage(asset); + this.Textures.Add(image.FullID, image); + if (this.RequestedTextures.ContainsKey(image.FullID)) + { + AssetRequest request = this.RequestedTextures[image.FullID]; + request.ImageInfo = image; + if (image.Data.LongLength > 600) + { + request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request.NumPackets = 1; + } + this.RequestedTextures.Remove(image.FullID); + this.TextureRequests.Add(request); + } + } + else + { + AssetInfo info = new AssetInfo(asset); + this.Assets.Add(info.FullID, info); + if (this.RequestedAssets.ContainsKey(info.FullID)) + { + AssetRequest request2 = this.RequestedAssets[info.FullID]; + request2.AssetInf = info; + if (info.Data.LongLength > 600) + { + request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); + } + else + { + request2.NumPackets = 1; + } + this.RequestedAssets.Remove(info.FullID); + this.AssetRequests.Add(request2); + } + } + } + } + + public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) + { + AssetInfo info = new AssetInfo(); + info.Data = new byte[sourceAsset.Data.Length]; + Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length); + info.FullID = LLUUID.Random(); + info.Type = sourceAsset.Type; + info.InvType = sourceAsset.InvType; + return info; + } + + public TextureImage CloneImage(LLUUID newOwner, TextureImage source) + { + TextureImage image = new TextureImage(); + image.Data = new byte[source.Data.Length]; + Array.Copy(source.Data, image.Data, source.Data.Length); + image.FullID = LLUUID.Random(); + image.Name = source.Name; + return image; + } + + public AssetBase[] CreateNewInventorySet(LLUUID agentID) + { + AssetBase[] baseArray = new AssetBase[this.textureList.Length]; + for (int i = 0; i < this.textureList.Length; i++) + { + if (this.Textures.ContainsKey(this.textureList[i])) + { + baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]); + TextureImage asset = new TextureImage(baseArray[i]); + this.Textures.Add(asset.FullID, asset); + this._assetServer.UploadNewAsset(asset); + } + } + return baseArray; + } + + public AssetBase GetAsset(LLUUID assetID) + { + AssetBase base2 = null; + if (this.Textures.ContainsKey(assetID)) + { + return this.Textures[assetID]; + } + if (this.Assets.ContainsKey(assetID)) + { + base2 = this.Assets[assetID]; + } + return base2; + } + + private IAssetServer LoadAssetDll(string dllName) + { + Assembly assembly = Assembly.LoadFrom(dllName); + IAssetServer assetServer = null; + foreach (Type type in assembly.GetTypes()) + { + if (type.IsPublic && !type.IsAbstract) + { + if (type.GetInterface("IAssetPlugin", true) != null) + { + assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer(); + break; + } + } + } + assembly = null; + return assetServer; + } + + public void LoadDefaultTextureSet() + { + this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); + this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); + this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); + this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); + this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); + for (int i = 0; i < this.textureList.Length; i++) + { + this._assetServer.RequestAsset(this.textureList[i], true); + } + } + + private void ProcessAssetQueue() + { + if (this.AssetRequests.Count != 0) + { + int num; + if (this.AssetRequests.Count < 5) + { + num = this.AssetRequests.Count; + } + else + { + num = 5; + } + for (int i = 0; i < num; i++) + { + AssetRequest request = this.AssetRequests[i]; + TransferInfoPacket newPack = new TransferInfoPacket(); + newPack.TransferInfo.ChannelType = 2; + newPack.TransferInfo.Status = 0; + newPack.TransferInfo.TargetType = 0; + newPack.TransferInfo.Params = request.RequestAssetID.GetBytes(); + newPack.TransferInfo.Size = request.AssetInf.Data.Length; + newPack.TransferInfo.TransferID = request.TransferRequestID; + request.RequestUser.OutPacket(newPack); + if (request.NumPackets == 1) + { + TransferPacketPacket packet2 = new TransferPacketPacket(); + packet2.TransferData.Packet = 0; + packet2.TransferData.ChannelType = 2; + packet2.TransferData.TransferID = request.TransferRequestID; + packet2.TransferData.Data = request.AssetInf.Data; + packet2.TransferData.Status = 1; + request.RequestUser.OutPacket(packet2); + } + else + { + TransferPacketPacket packet3 = new TransferPacketPacket(); + packet3.TransferData.Packet = 0; + packet3.TransferData.ChannelType = 2; + packet3.TransferData.TransferID = request.TransferRequestID; + byte[] destinationArray = new byte[0x3e8]; + Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8); + packet3.TransferData.Data = destinationArray; + packet3.TransferData.Status = 0; + request.RequestUser.OutPacket(packet3); + packet3 = new TransferPacketPacket(); + packet3.TransferData.Packet = 1; + packet3.TransferData.ChannelType = 2; + packet3.TransferData.TransferID = request.TransferRequestID; + byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8]; + Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length); + packet3.TransferData.Data = buffer2; + packet3.TransferData.Status = 1; + request.RequestUser.OutPacket(packet3); + } + } + for (int j = 0; j < num; j++) + { + this.AssetRequests.RemoveAt(0); + } + } + } + + private void ProcessTextureQueue() + { + if (this.TextureRequests.Count != 0) + { + int num = this.TextureRequests.Count; + for (int i = 0; i < num; i++) + { + AssetRequest req = this.TextureRequests[i]; + if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) + { + TextureSender sender = new TextureSender(req); + sender.OnComplete += new DownloadComplete(this.TextureSent); + lock (this.SendingTextures) + { + this.SendingTextures.Add(req.ImageInfo.FullID, sender); + } + } + } + this.TextureRequests.Clear(); + } + } + + public void RunAssetManager() + { + Label_0000: + try + { + this.ProcessAssetQueue(); + this.ProcessTextureQueue(); + Thread.Sleep(500); + goto Label_0000; + } + catch (Exception exception) + { + Console.WriteLine(exception.Message); + goto Label_0000; + } + } + + public void TextureSent(TextureSender sender) + { + if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) + { + lock (this.SendingTextures) + { + this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + } + } + } + + // Nested Types + public class AssetInfo : AssetBase + { + // Methods + public AssetInfo() + { + } + + public AssetInfo(AssetBase aBase) + { + base.Data = aBase.Data; + base.FullID = aBase.FullID; + base.Type = aBase.Type; + base.InvType = aBase.InvType; + base.Name = aBase.Name; + base.Description = aBase.Description; + } + } + + public class AssetRequest + { + // Fields + public AssetCache.AssetInfo AssetInf; + public long DataPointer; + public AssetCache.TextureImage ImageInfo; + public bool IsTextureRequest; + public int NumPackets; + public int PacketCounter; + public LLUUID RequestAssetID; + public IClientAPI RequestUser; + public LLUUID TransferRequestID; + } + + public class TextureImage : AssetBase + { + // Methods + public TextureImage() + { + } + + public TextureImage(AssetBase aBase) + { + base.Data = aBase.Data; + base.FullID = aBase.FullID; + base.Type = aBase.Type; + base.InvType = aBase.InvType; + base.Name = aBase.Name; + base.Description = aBase.Description; + } + } + + public class TextureSender + { + // Fields + private Thread m_thread; + public AssetCache.AssetRequest request; + + // Events + public event DownloadComplete OnComplete; + + // Methods + public TextureSender(AssetCache.AssetRequest req) + { + this.request = req; + this.m_thread = new Thread(new ThreadStart(this.SendTexture)); + this.m_thread.IsBackground = true; + this.m_thread.Start(); + } + + public void SendPacket() + { + AssetCache.AssetRequest request = this.request; + if (request.PacketCounter == 0) + { + if (request.NumPackets == 1) + { + ImageDataPacket newPack = new ImageDataPacket(); + newPack.ImageID.Packets = 1; + newPack.ImageID.ID = request.ImageInfo.FullID; + newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length; + newPack.ImageData.Data = request.ImageInfo.Data; + newPack.ImageID.Codec = 2; + request.RequestUser.OutPacket(newPack); + request.PacketCounter++; + } + else + { + ImageDataPacket packet2 = new ImageDataPacket(); + packet2.ImageID.Packets = (ushort)request.NumPackets; + packet2.ImageID.ID = request.ImageInfo.FullID; + packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length; + packet2.ImageData.Data = new byte[600]; + Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600); + packet2.ImageID.Codec = 2; + request.RequestUser.OutPacket(packet2); + request.PacketCounter++; + } + } + else + { + ImagePacketPacket packet3 = new ImagePacketPacket(); + packet3.ImageID.Packet = (ushort)request.PacketCounter; + packet3.ImageID.ID = request.ImageInfo.FullID; + int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1)); + if (length > 0x3e8) + { + length = 0x3e8; + } + packet3.ImageData.Data = new byte[length]; + Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length); + request.RequestUser.OutPacket(packet3); + request.PacketCounter++; + } + } + + public void SendTexture() + { + while (this.request.PacketCounter != this.request.NumPackets) + { + this.SendPacket(); + Thread.Sleep(500); + } + if (this.OnComplete != null) + { + this.OnComplete(this); + } + } + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 8b485af..f9f814a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -1,81 +1,81 @@ -/* -* 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.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications.Caches -{ - public class AssetTransactionManager - { - // Fields - public Dictionary AgentTransactions = new Dictionary(); - - // Methods - public AgentAssetTransactions AddUser(LLUUID userID) - { - if (!this.AgentTransactions.ContainsKey(userID)) - { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID); - this.AgentTransactions.Add(userID, transactions); - return transactions; - } - return null; - } - - public AgentAssetTransactions GetUserTransActions(LLUUID userID) - { - if (this.AgentTransactions.ContainsKey(userID)) - { - return this.AgentTransactions[userID]; - } - return null; - } - - public void HandleInventoryFromTransaction() - { - } - - public void HandleUDPUploadRequest() - { - } - - public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) - { - } - } -} - - +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications.Caches +{ + public class AssetTransactionManager + { + // Fields + public Dictionary AgentTransactions = new Dictionary(); + + // Methods + public AgentAssetTransactions AddUser(LLUUID userID) + { + if (!this.AgentTransactions.ContainsKey(userID)) + { + AgentAssetTransactions transactions = new AgentAssetTransactions(userID); + this.AgentTransactions.Add(userID, transactions); + return transactions; + } + return null; + } + + public AgentAssetTransactions GetUserTransActions(LLUUID userID) + { + if (this.AgentTransactions.ContainsKey(userID)) + { + return this.AgentTransactions[userID]; + } + return null; + } + + public void HandleInventoryFromTransaction() + { + } + + public void HandleUDPUploadRequest() + { + } + + public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) + { + } + } +} + + diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 6741969..c906b76 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -1,275 +1,275 @@ -/* -* 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 libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Capabilities; -using OpenSim.Framework.Servers; - -namespace OpenSim.Framework.Communications.Caches -{ - public class AgentAssetTransactions - { - // Fields - public List CapsUploaders = new List(); - public List NotecardUpdaters = new List(); - public LLUUID UserID; - public Dictionary XferUploaders = new Dictionary(); - - // Methods - public AgentAssetTransactions(LLUUID agentID) - { - this.UserID = agentID; - } - - public AssetCapsUploader RequestCapsUploader() - { - AssetCapsUploader uploader = new AssetCapsUploader(); - this.CapsUploaders.Add(uploader); - return uploader; - } - - public NoteCardCapsUpdate RequestNoteCardUpdater() - { - NoteCardCapsUpdate update = new NoteCardCapsUpdate(); - this.NotecardUpdaters.Add(update); - return update; - } - - public AssetXferUploader RequestXferUploader(LLUUID transactionID) - { - AssetXferUploader uploader = new AssetXferUploader(); - this.XferUploaders.Add(transactionID, uploader); - return uploader; - } - - // Nested Types - public class AssetCapsUploader - { - // Fields - private BaseHttpServer httpListener; - private LLUUID inventoryItemID; - private string m_assetDescription = ""; - private string m_assetName = ""; - private LLUUID m_folderID; - private LLUUID newAssetID; - private bool SaveImages = false; - private string uploaderPath = ""; - - // Events - public event UpLoadedTexture OnUpLoad; - - // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) - { - this.m_assetName = assetName; - this.m_assetDescription = assetDescription; - this.m_folderID = folderID; - this.newAssetID = assetID; - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; - } - - private void SaveImageToFile(string filename, byte[] data) - { - FileStream output = File.Create(filename); - BinaryWriter writer = new BinaryWriter(output); - writer.Write(data); - writer.Close(); - output.Close(); - } - - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inventoryItemID = this.inventoryItemID; - string text = ""; - LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); - complete.new_inventory_item = inventoryItemID; - complete.state = "complete"; - text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) - { - this.SaveImageToFile(this.m_assetName + ".jp2", data); - } - if (this.OnUpLoad != null) - { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); - } - return text; - } - } - - public class AssetXferUploader - { - // Fields - public bool AddToInventory; - public AssetBase Asset; - public LLUUID InventFolder = LLUUID.Zero; - private IClientAPI ourClient; - public LLUUID TransactionID = LLUUID.Zero; - public bool UploadComplete; - public uint XferID; - - // Methods - public void HandleXferPacket(uint xferID, uint packetID, byte[] data) - { - if (this.XferID == xferID) - { - if (this.Asset.Data.Length > 1) - { - byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; - Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); - Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); - this.Asset.Data = destinationArray; - } - else - { - byte[] buffer2 = new byte[data.Length - 4]; - Array.Copy(data, 4, buffer2, 0, data.Length - 4); - this.Asset.Data = buffer2; - } - ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); - newPack.XferID.ID = xferID; - newPack.XferID.Packet = packetID; - this.ourClient.OutPacket(newPack); - if ((packetID & 0x80000000) != 0) - { - this.SendCompleteMessage(); - } - } - } - - public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) - { - this.ourClient = remoteClient; - this.Asset = new AssetBase(); - this.Asset.FullID = assetID; - this.Asset.InvType = type; - this.Asset.Type = type; - this.Asset.Data = data; - this.Asset.Name = "blank"; - this.Asset.Description = "empty"; - this.TransactionID = transaction; - if (this.Asset.Data.Length > 2) - { - this.SendCompleteMessage(); - } - else - { - this.ReqestStartXfer(); - } - } - - protected void ReqestStartXfer() - { - this.UploadComplete = false; - this.XferID = Util.GetNextXferID(); - RequestXferPacket newPack = new RequestXferPacket(); - newPack.XferID.ID = this.XferID; - newPack.XferID.VFileType = this.Asset.Type; - newPack.XferID.VFileID = this.Asset.FullID; - newPack.XferID.FilePath = 0; - newPack.XferID.Filename = new byte[0]; - this.ourClient.OutPacket(newPack); - } - - protected void SendCompleteMessage() - { - this.UploadComplete = true; - AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); - newPack.AssetBlock.Type = this.Asset.Type; - newPack.AssetBlock.Success = true; - newPack.AssetBlock.UUID = this.Asset.FullID; - this.ourClient.OutPacket(newPack); - } - } - - public class NoteCardCapsUpdate - { - // Fields - private BaseHttpServer httpListener; - private LLUUID inventoryItemID; - private string m_assetName = ""; - private LLUUID newAssetID; - private bool SaveImages = false; - private string uploaderPath = ""; - - // Events - public event UpLoadedTexture OnUpLoad; - - // Methods - public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) - { - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; - this.newAssetID = LLUUID.Random(); - } - - private void SaveImageToFile(string filename, byte[] data) - { - FileStream output = File.Create(filename); - BinaryWriter writer = new BinaryWriter(output); - writer.Write(data); - writer.Close(); - output.Close(); - } - - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inventoryItemID = this.inventoryItemID; - string text = ""; - LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); - complete.new_inventory_item = inventoryItemID; - complete.state = "complete"; - text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) - { - this.SaveImageToFile(this.m_assetName + "notecard.txt", data); - } - if (this.OnUpLoad != null) - { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); - } - return text; - } - } - } +/* +* 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 libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Capabilities; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.Communications.Caches +{ + public class AgentAssetTransactions + { + // Fields + public List CapsUploaders = new List(); + public List NotecardUpdaters = new List(); + public LLUUID UserID; + public Dictionary XferUploaders = new Dictionary(); + + // Methods + public AgentAssetTransactions(LLUUID agentID) + { + this.UserID = agentID; + } + + public AssetCapsUploader RequestCapsUploader() + { + AssetCapsUploader uploader = new AssetCapsUploader(); + this.CapsUploaders.Add(uploader); + return uploader; + } + + public NoteCardCapsUpdate RequestNoteCardUpdater() + { + NoteCardCapsUpdate update = new NoteCardCapsUpdate(); + this.NotecardUpdaters.Add(update); + return update; + } + + public AssetXferUploader RequestXferUploader(LLUUID transactionID) + { + AssetXferUploader uploader = new AssetXferUploader(); + this.XferUploaders.Add(transactionID, uploader); + return uploader; + } + + // Nested Types + public class AssetCapsUploader + { + // Fields + private BaseHttpServer httpListener; + private LLUUID inventoryItemID; + private string m_assetDescription = ""; + private string m_assetName = ""; + private LLUUID m_folderID; + private LLUUID newAssetID; + private bool SaveImages = false; + private string uploaderPath = ""; + + // Events + public event UpLoadedTexture OnUpLoad; + + // Methods + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) + { + this.m_assetName = assetName; + this.m_assetDescription = assetDescription; + this.m_folderID = folderID; + this.newAssetID = assetID; + this.inventoryItemID = inventoryItem; + this.uploaderPath = path; + this.httpListener = httpServer; + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream output = File.Create(filename); + BinaryWriter writer = new BinaryWriter(output); + writer.Write(data); + writer.Close(); + output.Close(); + } + + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inventoryItemID = this.inventoryItemID; + string text = ""; + LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); + complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_inventory_item = inventoryItemID; + complete.state = "complete"; + text = LLSDHelpers.SerialiseLLSDReply(complete); + this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); + if (this.SaveImages) + { + this.SaveImageToFile(this.m_assetName + ".jp2", data); + } + if (this.OnUpLoad != null) + { + this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + } + return text; + } + } + + public class AssetXferUploader + { + // Fields + public bool AddToInventory; + public AssetBase Asset; + public LLUUID InventFolder = LLUUID.Zero; + private IClientAPI ourClient; + public LLUUID TransactionID = LLUUID.Zero; + public bool UploadComplete; + public uint XferID; + + // Methods + public void HandleXferPacket(uint xferID, uint packetID, byte[] data) + { + if (this.XferID == xferID) + { + if (this.Asset.Data.Length > 1) + { + byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; + Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); + Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); + this.Asset.Data = destinationArray; + } + else + { + byte[] buffer2 = new byte[data.Length - 4]; + Array.Copy(data, 4, buffer2, 0, data.Length - 4); + this.Asset.Data = buffer2; + } + ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); + newPack.XferID.ID = xferID; + newPack.XferID.Packet = packetID; + this.ourClient.OutPacket(newPack); + if ((packetID & 0x80000000) != 0) + { + this.SendCompleteMessage(); + } + } + } + + public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) + { + this.ourClient = remoteClient; + this.Asset = new AssetBase(); + this.Asset.FullID = assetID; + this.Asset.InvType = type; + this.Asset.Type = type; + this.Asset.Data = data; + this.Asset.Name = "blank"; + this.Asset.Description = "empty"; + this.TransactionID = transaction; + if (this.Asset.Data.Length > 2) + { + this.SendCompleteMessage(); + } + else + { + this.ReqestStartXfer(); + } + } + + protected void ReqestStartXfer() + { + this.UploadComplete = false; + this.XferID = Util.GetNextXferID(); + RequestXferPacket newPack = new RequestXferPacket(); + newPack.XferID.ID = this.XferID; + newPack.XferID.VFileType = this.Asset.Type; + newPack.XferID.VFileID = this.Asset.FullID; + newPack.XferID.FilePath = 0; + newPack.XferID.Filename = new byte[0]; + this.ourClient.OutPacket(newPack); + } + + protected void SendCompleteMessage() + { + this.UploadComplete = true; + AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); + newPack.AssetBlock.Type = this.Asset.Type; + newPack.AssetBlock.Success = true; + newPack.AssetBlock.UUID = this.Asset.FullID; + this.ourClient.OutPacket(newPack); + } + } + + public class NoteCardCapsUpdate + { + // Fields + private BaseHttpServer httpListener; + private LLUUID inventoryItemID; + private string m_assetName = ""; + private LLUUID newAssetID; + private bool SaveImages = false; + private string uploaderPath = ""; + + // Events + public event UpLoadedTexture OnUpLoad; + + // Methods + public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) + { + this.inventoryItemID = inventoryItem; + this.uploaderPath = path; + this.httpListener = httpServer; + this.newAssetID = LLUUID.Random(); + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream output = File.Create(filename); + BinaryWriter writer = new BinaryWriter(output); + writer.Write(data); + writer.Close(); + output.Close(); + } + + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inventoryItemID = this.inventoryItemID; + string text = ""; + LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); + complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_inventory_item = inventoryItemID; + complete.state = "complete"; + text = LLSDHelpers.SerialiseLLSDReply(complete); + this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); + if (this.SaveImages) + { + this.SaveImageToFile(this.m_assetName + "notecard.txt", data); + } + if (this.OnUpLoad != null) + { + this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + } + return text; + } + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 2660df3..d850305 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -1,94 +1,94 @@ -/* -* 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.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - public class CachedUserInfo - { - // Fields - public InventoryFolder RootFolder; - public UserProfileData UserProfile; - - // Methods - public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) - { - if (userID == this.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 folder = this.RootFolder.HasSubFolder(folderInfo.parentID); - if (folder != null) - { - folder.SubFolders.Add(folderInfo.folderID, folderInfo); - } - } - } - } - - public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) - { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) - { - if (itemInfo.parentFolderID == this.RootFolder.folderID) - { - this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); - } - else - { - InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); - if (folder != null) - { - folder.Items.Add(itemInfo.inventoryID, itemInfo); - } - } - } - } - } -} - +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Data; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public class CachedUserInfo + { + // Fields + public InventoryFolder RootFolder; + public UserProfileData UserProfile; + + // Methods + public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) + { + if (userID == this.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 folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + if (folder != null) + { + folder.SubFolders.Add(folderInfo.folderID, folderInfo); + } + } + } + } + + public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) + { + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + if (itemInfo.parentFolderID == this.RootFolder.folderID) + { + this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + } + else + { + InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + if (folder != null) + { + folder.Items.Add(itemInfo.inventoryID, itemInfo); + } + } + } + } + } +} + diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 8670eb0..300a6e3 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -1,109 +1,109 @@ -/* -* 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.Interfaces; -using OpenSim.Framework.Data; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - public class InventoryFolder : InventoryFolderBase - { - // Fields - public Dictionary Items = new Dictionary(); - public Dictionary SubFolders = new Dictionary(); - - // Methods - 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 InventoryItemBase HasItem(LLUUID itemID) - { - InventoryItemBase base2 = null; - if (this.Items.ContainsKey(itemID)) - { - return this.Items[itemID]; - } - foreach (InventoryFolder folder in this.SubFolders.Values) - { - base2 = folder.HasItem(itemID); - if (base2 != null) - { - break; - } - } - return base2; - } - - 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 List RequestListOfItems() - { - List itemList = new List(); - foreach (InventoryItemBase item in this.Items.Values) - { - itemList.Add(item); - } - return itemList; - } - } -} +/* +* 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.Interfaces; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + public class InventoryFolder : InventoryFolderBase + { + // Fields + public Dictionary Items = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); + + // Methods + public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + { + InventoryFolder subFold = new InventoryFolder(); + subFold.name = folderName; + subFold.folderID = folderID; + subFold.type = (short) type; + subFold.parentID = this.folderID; + subFold.agentID = this.agentID; + this.SubFolders.Add(subFold.folderID, subFold); + return subFold; + } + + public InventoryItemBase HasItem(LLUUID itemID) + { + InventoryItemBase base2 = null; + if (this.Items.ContainsKey(itemID)) + { + return this.Items[itemID]; + } + foreach (InventoryFolder folder in this.SubFolders.Values) + { + base2 = folder.HasItem(itemID); + if (base2 != null) + { + break; + } + } + return base2; + } + + 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 List RequestListOfItems() + { + List itemList = new List(); + foreach (InventoryItemBase item in this.Items.Values) + { + itemList.Add(item); + } + return itemList; + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs new file mode 100644 index 0000000..2608145 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications.Caches +{ + public class LibraryRootFolder : InventoryFolder + { + private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + + public LibraryRootFolder() + { + this.agentID = libOwner; + this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); + this.name = "OpenSim Library"; + this.parentID = LLUUID.Zero; + this.type = (short)-1; + this.version = (ushort) 1; + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); + item.inventoryDescription = "Plywood texture"; + item.inventoryName = "Plywood"; + item.type =0; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003"); + item.inventoryDescription = "Rocks texture"; + item.inventoryName = "Rocks"; + item.type = 0; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001"); + item.inventoryDescription = "Bricks texture"; + item.inventoryName = "Bricks"; + item.type = 0; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004"); + item.inventoryDescription = "Granite texture"; + item.inventoryName = "Granite"; + item.type = 0; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005"); + item.inventoryDescription = "Hardwood texture"; + item.inventoryName = "Hardwood"; + item.type = 0; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + this.Items.Add(item.inventoryID, item); + } + + } +} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 8210702..7b4f6a5 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -1,170 +1,216 @@ -/* -* 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.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class UserProfileCache - { - // Fields - private CommunicationsManager m_parent; - public Dictionary UserProfiles = new Dictionary(); - - // Methods - public UserProfileCache(CommunicationsManager parent) - { - this.m_parent = parent; - } - - 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 - { - Console.WriteLine("UserProfileCache.cs: user profile for user not found"); - } - } - } - - public void AddNewUser(string firstName, string lastName) - { - } - - public CachedUserInfo GetUserDetails(LLUUID userID) - { - if (this.UserProfiles.ContainsKey(userID)) - { - return this.UserProfiles[userID]; - } - return null; - } - - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) - { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) - { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == parentID) - { - info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - } - else - { - InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); - if (folder != null) - { - folder.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 info = this.UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == folderID) - { - if (fetchItems) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); - } - } - else - { - InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); - if ((folder != null) && fetchItems) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); - } - } - } - } - - public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) - { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) - { - InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); - if (item != null) - { - remoteClient.SendInventoryItemDetails(ownerID, item); - } - } - } - - private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) - { - InventoryFolder folderInfo = new InventoryFolder(); - folderInfo.agentID = userID; - folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; - folderInfo.name = "My Inventory"; - folderInfo.parentID = LLUUID.Zero; - folderInfo.type = 8; - folderInfo.version = 1; - userInfo.FolderReceive(userID, folderInfo); - } - - private UserProfileData RequestUserProfileForUser(LLUUID userID) - { - return this.m_parent.UserServer.GetUserProfile(userID); - } - - private void UpdateInventoryToServer(LLUUID userID) - { - } - - private void UpdateUserProfileToServer(LLUUID userID) - { - } - - public void UserLogOut(LLUUID userID) - { - } - } -} - +/* +* 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.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications.Caches +{ + public class UserProfileCache + { + // Fields + private CommunicationsManager m_parent; + public Dictionary UserProfiles = new Dictionary(); + + public LibraryRootFolder libraryRoot = new LibraryRootFolder(); + + // Methods + public UserProfileCache(CommunicationsManager parent) + { + this.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 + { + Console.WriteLine("UserProfileCache.cs: user profile for user not found"); + } + } + } + + /// + /// A new user has moved into a region in this instance + /// so get info from servers + /// + /// + /// + public void AddNewUser(string firstName, string lastName) + { + } + + public CachedUserInfo GetUserDetails(LLUUID userID) + { + if (this.UserProfiles.ContainsKey(userID)) + { + return this.UserProfiles[userID]; + } + return null; + } + + public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) + { + if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + { + CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == parentID) + { + info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + } + else + { + InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); + if (folder != null) + { + folder.CreateNewSubFolder(folderID, folderName, folderType); + } + } + } + } + + public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) + { + if (folderID == libraryRoot.folderID ) + { + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); + } + else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + { + CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == folderID) + { + if (fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + } + } + else + { + InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); + if ((folder != null) && fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + } + } + } + } + + public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) + { + if (ownerID == libraryRoot.agentID) + { + //Console.WriteLine("request info for library item"); + } + else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + { + InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + if (item != null) + { + remoteClient.SendInventoryItemDetails(ownerID, item); + } + } + } + + /// + /// 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 folderInfo = new InventoryFolder(); + folderInfo.agentID = userID; + folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; + folderInfo.name = "My Inventory"; + folderInfo.parentID = LLUUID.Zero; + folderInfo.type = 8; + folderInfo.version = 1; + userInfo.FolderReceive(userID, folderInfo); + } + + /// + /// Request the user profile from User server + /// + /// + private UserProfileData RequestUserProfileForUser(LLUUID userID) + { + return this.m_parent.UserServer.GetUserProfile(userID); + } + + /// + /// Update Inventory data to Inventory server + /// + /// + private void UpdateInventoryToServer(LLUUID userID) + { + } + + /// + /// Make sure UserProfile is updated on user server + /// + /// + private void UpdateUserProfileToServer(LLUUID userID) + { + } + + /// + /// A user has left this instance + /// so make sure servers have been updated + /// Then remove cached info + /// + /// + public void UserLogOut(LLUUID userID) + { + } + } +} + diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e220e17..ac882ba 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications public IGridServices GridServer; public IInventoryServices InventoryServer; public IInterRegionCommunications InterRegion; - public UserProfileCache UserProfilesCache; + public UserProfileCache UserProfiles; public AssetCache AssetCache; public NetworkServersInfo ServersInfo; @@ -52,21 +52,28 @@ namespace OpenSim.Framework.Communications { ServersInfo = serversInfo; this.AssetCache = assetCache; - UserProfilesCache = new UserProfileCache(this); + UserProfiles = new UserProfileCache(this); } #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - UserProfileData profileData = this.UserServer.GetUserProfile(uuid); - if (profileData != null) + if (uuid == UserProfiles.libraryRoot.agentID) { - LLUUID profileId = profileData.UUID; - string firstname = profileData.username; - string lastname = profileData.surname; + remote_client.SendNameReply(uuid , "Mr" , "OpenSim"); + } + else + { + UserProfileData profileData = this.UserServer.GetUserProfile(uuid); + if (profileData != null) + { + LLUUID profileId = profileData.UUID; + string firstname = profileData.username; + string lastname = profileData.surname; - remote_client.SendNameReply(profileId, firstname, lastname); - } + remote_client.SendNameReply(profileId, firstname, lastname); + } + } } #endregion -- cgit v1.1 From 74654dc7351baf092ecae12c90a236ec43c86c98 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 25 Jul 2007 19:18:34 +0000 Subject: Added the default shape to the OpenSim library. Now need to get the new ruth into asset format and add that. --- .../Communications/Cache/LibraryRootFolder.cs | 50 +++++++++++++++++----- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 2608145..18803c0 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -19,6 +19,11 @@ namespace OpenSim.Framework.Communications.Caches this.type = (short)-1; this.version = (ushort) 1; + this.CreateLibraryItems(); + } + + private void CreateLibraryItems() + { InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -26,10 +31,12 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); item.inventoryDescription = "Plywood texture"; item.inventoryName = "Plywood"; - item.type =0; + item.type = 0; item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; this.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); @@ -41,8 +48,10 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryName = "Rocks"; item.type = 0; item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; this.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); @@ -54,8 +63,10 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryName = "Bricks"; item.type = 0; item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; this.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); @@ -67,8 +78,10 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryName = "Granite"; item.type = 0; item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; this.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); @@ -80,8 +93,23 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryName = "Hardwood"; item.type = 0; item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"); + item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + item.inventoryDescription = "Default Shape"; + item.inventoryName = "Default Shape"; + item.type = 13; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; this.Items.Add(item.inventoryID, item); } -- cgit v1.1 From f0dd115a8c5c44ebde4631df3469c6e39510325f Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 26 Jul 2007 17:41:31 +0000 Subject: More work on inventory and opensim library. Fixed a number of bugs in the AssetCache related to asset downloading. --- .../Framework/Communications/Cache/AssetCache.cs | 794 ++++++++++++--------- .../Communications/Cache/LibraryRootFolder.cs | 62 +- .../Communications/Cache/UserProfileCache.cs | 5 + 3 files changed, 514 insertions(+), 347 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index a3480ec..32ba830 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -25,537 +25,657 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; -using System.Collections; using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Threading; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Servers; using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications.Caches { public delegate void DownloadComplete(AssetCache.TextureSender sender); + /// + /// Manages local cache of assets and their sending to viewers. + /// public class AssetCache : IAssetReceiver { - // Fields - private Thread _assetCacheThread; - private IAssetServer _assetServer; - public List AssetRequests; public Dictionary Assets; - public Dictionary RequestedAssets; - public Dictionary RequestedTextures; - public Dictionary SendingTextures; - private LLUUID[] textureList; - public List TextureRequests; public Dictionary Textures; - // Methods + 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; + + /// + /// + /// public AssetCache(IAssetServer assetServer) { - this.AssetRequests = new List(); - this.TextureRequests = new List(); - this.RequestedAssets = new Dictionary(); - this.RequestedTextures = new Dictionary(); - this.SendingTextures = new Dictionary(); - this.textureList = new LLUUID[5]; Console.WriteLine("Creating Asset cache"); - this._assetServer = assetServer; - this._assetServer.SetReceiver(this); - this.Assets = new Dictionary(); - this.Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + _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) { - this.AssetRequests = new List(); - this.TextureRequests = new List(); - this.RequestedAssets = new Dictionary(); - this.RequestedTextures = new Dictionary(); - this.SendingTextures = new Dictionary(); - this.textureList = new LLUUID[5]; Console.WriteLine("Creating Asset cache"); - this._assetServer = this.LoadAssetDll(assetServerDLLName); - this._assetServer.SetServerInfo(assetServerURL, assetServerKey); - this._assetServer.SetReceiver(this); - this.Assets = new Dictionary(); - this.Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(this.RunAssetManager)); + _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 AddAsset(AssetBase asset) + /// + /// + /// + public void RunAssetManager() { - if (asset.Type == 0) + while (true) { - if (!this.Textures.ContainsKey(asset.FullID)) + try { - TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - this._assetServer.UploadNewAsset(asset); + this.ProcessAssetQueue(); + this.ProcessTextureQueue(); + Thread.Sleep(500); + } + catch (Exception e) + { + Console.WriteLine(e.Message + " : " + e.StackTrace); } } - else if (!this.Assets.ContainsKey(asset.FullID)) + } + + + public AssetBase GetAsset(LLUUID assetID) + { + AssetBase asset = null; + if (this.Textures.ContainsKey(assetID)) + { + asset = this.Textures[assetID]; + } + else if (this.Assets.ContainsKey(assetID)) { - AssetInfo info = new AssetInfo(asset); - this.Assets.Add(info.FullID, info); - this._assetServer.UploadNewAsset(asset); + asset = this.Assets[assetID]; } + return asset; } - public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) + public void AddAsset(AssetBase asset) { - LLUUID assetID = new LLUUID(transferRequest.TransferInfo.Params, 0); - if (!this.Assets.ContainsKey(assetID)) + // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + if (asset.Type == 0) { - if (!this.RequestedAssets.ContainsKey(assetID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = assetID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - this.RequestedAssets.Add(assetID, request); - this._assetServer.RequestAsset(assetID, false); + //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 { - AssetInfo info = this.Assets[assetID]; - AssetRequest request2 = new AssetRequest(); - request2.RequestUser = userInfo; - request2.RequestAssetID = assetID; - request2.TransferRequestID = transferRequest.TransferInfo.TransferID; - request2.AssetInf = info; - if (info.Data.LongLength > 600) - { - request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else + if (!this.Assets.ContainsKey(asset.FullID)) { - request2.NumPackets = 1; + AssetInfo assetInf = new AssetInfo(asset); + this.Assets.Add(assetInf.FullID, assetInf); + this._assetServer.UploadNewAsset(asset); } - this.AssetRequests.Add(request2); } } - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) + /// + /// + /// + private void ProcessTextureQueue() { - if (!this.Textures.ContainsKey(imageID)) + if (this.TextureRequests.Count == 0) { - if (!this.RequestedTextures.ContainsKey(imageID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = imageID; - request.IsTextureRequest = true; - this.RequestedTextures.Add(imageID, request); - this._assetServer.RequestAsset(imageID, true); - } + //no requests waiting + return; } - else + int num; + num = this.TextureRequests.Count; + + AssetRequest req; + for (int i = 0; i < num; i++) { - TextureImage image = this.Textures[imageID]; - AssetRequest request2 = new AssetRequest(); - request2.RequestUser = userInfo; - request2.RequestAssetID = imageID; - request2.IsTextureRequest = true; - request2.ImageInfo = image; - if (image.Data.LongLength > 600) + req = (AssetRequest)this.TextureRequests[i]; + if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) { - request2.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); - } - else - { - request2.NumPackets = 1; + TextureSender sender = new TextureSender(req); + sender.OnComplete += this.TextureSent; + lock (this.SendingTextures) + { + this.SendingTextures.Add(req.ImageInfo.FullID, sender); + } } - this.TextureRequests.Add(request2); + } + + this.TextureRequests.Clear(); } - public void AssetNotFound(AssetBase asset) + /// + /// 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 (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 request = this.RequestedTextures[image.FullID]; - request.ImageInfo = image; + AssetRequest req = this.RequestedTextures[image.FullID]; + req.ImageInfo = image; if (image.Data.LongLength > 600) { - request.NumPackets = 1 + (((image.Data.Length - 600) + 0x3e7) / 0x3e8); + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; } else { - request.NumPackets = 1; + req.NumPackets = 1; } this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(request); + this.TextureRequests.Add(req); } } else { - AssetInfo info = new AssetInfo(asset); - this.Assets.Add(info.FullID, info); - if (this.RequestedAssets.ContainsKey(info.FullID)) + AssetInfo assetInf = new AssetInfo(asset); + this.Assets.Add(assetInf.FullID, assetInf); + if (this.RequestedAssets.ContainsKey(assetInf.FullID)) { - AssetRequest request2 = this.RequestedAssets[info.FullID]; - request2.AssetInf = info; - if (info.Data.LongLength > 600) + AssetRequest req = this.RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + if (assetInf.Data.LongLength > 600) { - request2.NumPackets = 1 + (((info.Data.Length - 600) + 0x3e7) / 0x3e8); + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; } else { - request2.NumPackets = 1; + req.NumPackets = 1; } - this.RequestedAssets.Remove(info.FullID); - this.AssetRequests.Add(request2); + this.RequestedAssets.Remove(assetInf.FullID); + this.AssetRequests.Add(req); } } } } - public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) + public void AssetNotFound(AssetBase asset) { - AssetInfo info = new AssetInfo(); - info.Data = new byte[sourceAsset.Data.Length]; - Array.Copy(sourceAsset.Data, info.Data, sourceAsset.Data.Length); - info.FullID = LLUUID.Random(); - info.Type = sourceAsset.Type; - info.InvType = sourceAsset.InvType; - return info; - } + //the asset server had no knowledge of requested asset - public TextureImage CloneImage(LLUUID newOwner, TextureImage source) - { - TextureImage image = new TextureImage(); - image.Data = new byte[source.Data.Length]; - Array.Copy(source.Data, image.Data, source.Data.Length); - image.FullID = LLUUID.Random(); - image.Name = source.Name; - return image; } - public AssetBase[] CreateNewInventorySet(LLUUID agentID) + #region Assets + /// + /// + /// + /// + /// + public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { - AssetBase[] baseArray = new AssetBase[this.textureList.Length]; - for (int i = 0; i < this.textureList.Length; i++) + LLUUID requestID = null; + byte source = 2; + if (transferRequest.TransferInfo.SourceType == 2) + { + //direct asset request + requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); + } + else if (transferRequest.TransferInfo.SourceType == 3) + { + //inventory asset request + requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); + source = 3; + } + //check to see if asset is in local cache, if not we need to request it from asset server. + //Console.WriteLine("asset request " + requestID); + if (!this.Assets.ContainsKey(requestID)) { - if (this.Textures.ContainsKey(this.textureList[i])) + //not found asset + // so request from asset server + if (!this.RequestedAssets.ContainsKey(requestID)) { - baseArray[i] = this.CloneImage(agentID, this.Textures[this.textureList[i]]); - TextureImage asset = new TextureImage(baseArray[i]); - this.Textures.Add(asset.FullID, asset); - this._assetServer.UploadNewAsset(asset); + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = requestID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + request.AssetRequestSource = source; + request.Params = transferRequest.TransferInfo.Params; + this.RequestedAssets.Add(requestID, request); + this._assetServer.RequestAsset(requestID, false); } + return; } - return baseArray; - } + //it is in our cache + AssetInfo asset = this.Assets[requestID]; - public AssetBase GetAsset(LLUUID assetID) - { - AssetBase base2 = null; - if (this.Textures.ContainsKey(assetID)) + //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.AssetRequestSource = source; + req.Params = transferRequest.TransferInfo.Params; + req.AssetInf = asset; + + if (asset.Data.LongLength > 600) { - return this.Textures[assetID]; + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; } - if (this.Assets.ContainsKey(assetID)) + else { - base2 = this.Assets[assetID]; + req.NumPackets = 1; } - return base2; + + this.AssetRequests.Add(req); } - private IAssetServer LoadAssetDll(string dllName) + /// + /// + /// + private void ProcessAssetQueue() { - Assembly assembly = Assembly.LoadFrom(dllName); - IAssetServer assetServer = null; - foreach (Type type in assembly.GetTypes()) + if (this.AssetRequests.Count == 0) { - if (type.IsPublic && !type.IsAbstract) - { - if (type.GetInterface("IAssetPlugin", true) != null) - { - assetServer = ((IAssetPlugin)Activator.CreateInstance(assembly.GetType(type.ToString()))).GetAssetServer(); - break; - } - } + //no requests waiting + return; } - assembly = null; - return assetServer; - } + int num; - public void LoadDefaultTextureSet() - { - this.textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); - this.textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); - this.textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); - this.textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); - this.textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); - for (int i = 0; i < this.textureList.Length; i++) + if (this.AssetRequests.Count < 5) { - this._assetServer.RequestAsset(this.textureList[i], true); + //lower than 5 so do all of them + num = this.AssetRequests.Count; } - } - - private void ProcessAssetQueue() - { - if (this.AssetRequests.Count != 0) + else + { + num = 5; + } + AssetRequest req; + for (int i = 0; i < num; i++) { - int num; - if (this.AssetRequests.Count < 5) + req = (AssetRequest)this.AssetRequests[i]; + //Console.WriteLine("sending asset " + req.RequestAssetID); + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + if (req.AssetRequestSource == 2) { - num = this.AssetRequests.Count; + //Transfer.TransferInfo.Params = req.Params; + Transfer.TransferInfo.Params = new byte[20]; + Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + int assType = (int)req.AssetInf.Type; + Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); } - else + else if (req.AssetRequestSource == 3) { - num = 5; + Transfer.TransferInfo.Params = req.Params; + // Transfer.TransferInfo.Params = new byte[100]; + //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } - for (int i = 0; i < num; i++) + Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.TransferID = req.TransferRequestID; + req.RequestUser.OutPacket(Transfer); + + if (req.NumPackets == 1) { - AssetRequest request = this.AssetRequests[i]; - TransferInfoPacket newPack = new TransferInfoPacket(); - newPack.TransferInfo.ChannelType = 2; - newPack.TransferInfo.Status = 0; - newPack.TransferInfo.TargetType = 0; - newPack.TransferInfo.Params = request.RequestAssetID.GetBytes(); - newPack.TransferInfo.Size = request.AssetInf.Data.Length; - newPack.TransferInfo.TransferID = request.TransferRequestID; - request.RequestUser.OutPacket(newPack); - if (request.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 = null; + if (req.AssetInf.Data.Length <= 1000) { - TransferPacketPacket packet2 = new TransferPacketPacket(); - packet2.TransferData.Packet = 0; - packet2.TransferData.ChannelType = 2; - packet2.TransferData.TransferID = request.TransferRequestID; - packet2.TransferData.Data = request.AssetInf.Data; - packet2.TransferData.Status = 1; - request.RequestUser.OutPacket(packet2); + chunk = new byte[req.AssetInf.Data.Length]; + Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length); } else { - TransferPacketPacket packet3 = new TransferPacketPacket(); - packet3.TransferData.Packet = 0; - packet3.TransferData.ChannelType = 2; - packet3.TransferData.TransferID = request.TransferRequestID; - byte[] destinationArray = new byte[0x3e8]; - Array.Copy(request.AssetInf.Data, destinationArray, 0x3e8); - packet3.TransferData.Data = destinationArray; - packet3.TransferData.Status = 0; - request.RequestUser.OutPacket(packet3); - packet3 = new TransferPacketPacket(); - packet3.TransferData.Packet = 1; - packet3.TransferData.ChannelType = 2; - packet3.TransferData.TransferID = request.TransferRequestID; - byte[] buffer2 = new byte[request.AssetInf.Data.Length - 0x3e8]; - Array.Copy(request.AssetInf.Data, 0x3e8, buffer2, 0, buffer2.Length); - packet3.TransferData.Data = buffer2; - packet3.TransferData.Status = 1; - request.RequestUser.OutPacket(packet3); + chunk = new byte[1000]; + Array.Copy(req.AssetInf.Data, chunk, 1000); + } + + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 0; + req.RequestUser.OutPacket(TransferPacket); + + if (req.AssetInf.Data.Length > 1000) + { + 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); } } - for (int j = 0; j < num; j++) - { - this.AssetRequests.RemoveAt(0); - } + } + + //remove requests that have been completed + for (int i = 0; i < num; i++) + { + this.AssetRequests.RemoveAt(0); + } + } - private void ProcessTextureQueue() + 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) { - if (this.TextureRequests.Count != 0) + //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)) { - int num = this.TextureRequests.Count; - for (int i = 0; i < num; i++) + if (!this.RequestedTextures.ContainsKey(imageID)) { - AssetRequest req = this.TextureRequests[i]; - if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) - { - TextureSender sender = new TextureSender(req); - sender.OnComplete += new DownloadComplete(this.TextureSent); - lock (this.SendingTextures) - { - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - } - } + //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); } - this.TextureRequests.Clear(); + return; } - } - public void RunAssetManager() - { - Label_0000: - try + //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) { - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); - Thread.Sleep(500); - goto Label_0000; + //over 600 bytes so split up file + req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; } - catch (Exception exception) + else { - Console.WriteLine(exception.Message); - goto Label_0000; + req.NumPackets = 1; } + this.TextureRequests.Add(req); } - public void TextureSent(TextureSender sender) + public TextureImage CloneImage(LLUUID newOwner, TextureImage source) { - if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) + 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()) { - lock (this.SendingTextures) + if (pluginType.IsPublic) { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + 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 byte AssetRequestSource = 2; + public byte[] Params = null; + //public bool AssetInCache; + //public int TimeRequested; + + public AssetRequest() + { + + } } - // Nested Types public class AssetInfo : AssetBase { - // Methods public AssetInfo() { + } public AssetInfo(AssetBase aBase) { - base.Data = aBase.Data; - base.FullID = aBase.FullID; - base.Type = aBase.Type; - base.InvType = aBase.InvType; - base.Name = aBase.Name; - base.Description = aBase.Description; + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; } } - public class AssetRequest - { - // Fields - public AssetCache.AssetInfo AssetInf; - public long DataPointer; - public AssetCache.TextureImage ImageInfo; - public bool IsTextureRequest; - public int NumPackets; - public int PacketCounter; - public LLUUID RequestAssetID; - public IClientAPI RequestUser; - public LLUUID TransferRequestID; - } - public class TextureImage : AssetBase { - // Methods public TextureImage() { + } public TextureImage(AssetBase aBase) { - base.Data = aBase.Data; - base.FullID = aBase.FullID; - base.Type = aBase.Type; - base.InvType = aBase.InvType; - base.Name = aBase.Name; - base.Description = aBase.Description; + Data = aBase.Data; + FullID = aBase.FullID; + Type = aBase.Type; + InvType = aBase.InvType; + Name = aBase.Name; + Description = aBase.Description; } } public class TextureSender { - // Fields - private Thread m_thread; - public AssetCache.AssetRequest request; - - // Events + 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()); - // Methods - public TextureSender(AssetCache.AssetRequest req) + //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() { - this.request = req; - this.m_thread = new Thread(new ThreadStart(this.SendTexture)); - this.m_thread.IsBackground = true; - this.m_thread.Start(); + //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() { - AssetCache.AssetRequest request = this.request; - if (request.PacketCounter == 0) + AssetRequest req = request; + // Console.WriteLine("sending " + req.ImageInfo.FullID); + + // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) + if (req.PacketCounter == 0) { - if (request.NumPackets == 1) + //first time for this request so send imagedata packet + if (req.NumPackets == 1) { - ImageDataPacket newPack = new ImageDataPacket(); - newPack.ImageID.Packets = 1; - newPack.ImageID.ID = request.ImageInfo.FullID; - newPack.ImageID.Size = (uint)request.ImageInfo.Data.Length; - newPack.ImageData.Data = request.ImageInfo.Data; - newPack.ImageID.Codec = 2; - request.RequestUser.OutPacket(newPack); - request.PacketCounter++; + //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 { - ImageDataPacket packet2 = new ImageDataPacket(); - packet2.ImageID.Packets = (ushort)request.NumPackets; - packet2.ImageID.ID = request.ImageInfo.FullID; - packet2.ImageID.Size = (uint)request.ImageInfo.Data.Length; - packet2.ImageData.Data = new byte[600]; - Array.Copy(request.ImageInfo.Data, 0, packet2.ImageData.Data, 0, 600); - packet2.ImageID.Codec = 2; - request.RequestUser.OutPacket(packet2); - request.PacketCounter++; + //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 { - ImagePacketPacket packet3 = new ImagePacketPacket(); - packet3.ImageID.Packet = (ushort)request.PacketCounter; - packet3.ImageID.ID = request.ImageInfo.FullID; - int length = (request.ImageInfo.Data.Length - 600) - (0x3e8 * (request.PacketCounter - 1)); - if (length > 0x3e8) - { - length = 0x3e8; - } - packet3.ImageData.Data = new byte[length]; - Array.Copy(request.ImageInfo.Data, 600 + (0x3e8 * (request.PacketCounter - 1)), packet3.ImageData.Data, 0, length); - request.RequestUser.OutPacket(packet3); - request.PacketCounter++; + //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); } - } - public void SendTexture() - { - while (this.request.PacketCounter != this.request.NumPackets) - { - this.SendPacket(); - Thread.Sleep(500); - } - if (this.OnComplete != null) - { - this.OnComplete(this); - } } } } } + diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 18803c0..bcfce3f 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -9,6 +9,7 @@ namespace OpenSim.Framework.Communications.Caches public class LibraryRootFolder : InventoryFolder { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + private InventoryFolder m_textureFolder; public LibraryRootFolder() { @@ -19,11 +20,22 @@ namespace OpenSim.Framework.Communications.Caches this.type = (short)-1; this.version = (ushort) 1; + InventoryFolder folderInfo = new InventoryFolder(); + folderInfo.agentID = libOwner; + folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); + folderInfo.name = "My Inventory"; + folderInfo.parentID = this.folderID; + folderInfo.type = -1; + folderInfo.version = 1; + this.SubFolders.Add(folderInfo.folderID, folderInfo); + this.m_textureFolder = folderInfo; + this.CreateLibraryItems(); } private void CreateLibraryItems() { + InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -32,12 +44,12 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryDescription = "Plywood texture"; item.inventoryName = "Plywood"; item.type = 0; - item.parentFolderID = this.folderID; + item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.Items.Add(item.inventoryID, item); + this.m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -47,12 +59,12 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryDescription = "Rocks texture"; item.inventoryName = "Rocks"; item.type = 0; - item.parentFolderID = this.folderID; + item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.Items.Add(item.inventoryID, item); + this.m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -62,12 +74,12 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryDescription = "Bricks texture"; item.inventoryName = "Bricks"; item.type = 0; - item.parentFolderID = this.folderID; + item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.Items.Add(item.inventoryID, item); + this.m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -77,12 +89,12 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryDescription = "Granite texture"; item.inventoryName = "Granite"; item.type = 0; - item.parentFolderID = this.folderID; + item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.Items.Add(item.inventoryID, item); + this.m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -92,12 +104,12 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryDescription = "Hardwood texture"; item.inventoryName = "Hardwood"; item.type = 0; - item.parentFolderID = this.folderID; + item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.Items.Add(item.inventoryID, item); + this.m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -111,6 +123,36 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"); + item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + item.inventoryDescription = "Default Skin"; + item.inventoryName = "Default Skin"; + item.type = 13; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID("00000000-0000-2222-4444-000000000001"); + item.assetID = new LLUUID("00000000-0000-2222-3333-000000000001"); + item.inventoryDescription = "Welcome"; + item.inventoryName = "Welcome"; + item.type = 7; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = (1 << 15); + item.inventoryNextPermissions = (1 << 15); + item.inventoryEveryOnePermissions = (1 << 15); + item.inventoryBasePermissions = (1 << 15); + this.Items.Add(item.inventoryID, item); + + } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 7b4f6a5..32c5db9 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -116,10 +116,15 @@ namespace OpenSim.Framework.Communications.Caches public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + InventoryFolder fold = null; if (folderID == libraryRoot.folderID ) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); } + else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) + { + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); + } else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; -- cgit v1.1 From d143e7b074111c2a4796c6caf05ea5030412d44b Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 27 Jul 2007 12:21:52 +0000 Subject: A few changes so that the number of warnings is less but without deleting everything. Like, I removed the Obsolete from the old caps method as at this time not all caps calls can use the new Caps stream method as it doesn't properly deal with LLSD Arrays. Now down to 3 warnings on the events in IClientAPI and for now I think we have to live with them as I think most of those events will be used. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index bcfce3f..f807b2b 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -23,7 +23,7 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder folderInfo = new InventoryFolder(); folderInfo.agentID = libOwner; folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); - folderInfo.name = "My Inventory"; + folderInfo.name = "Texture Library"; folderInfo.parentID = this.folderID; folderInfo.type = -1; folderInfo.version = 1; diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 3b1cc6a..5df66f4 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -82,7 +82,10 @@ namespace OpenSim.Region.Capabilities AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); } - [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] + + //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] + //Commented out the obsolete as at this time the first caps request can not use the new Caps method + //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { string capsBase = "/CAPS/" + m_capsObjectPath; -- cgit v1.1 From 1b850b4483956a8ef7cb5b44911b1e8dab9f7e86 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 27 Jul 2007 16:23:04 +0000 Subject: Should now have version 0.1 of our new ruth default avatar. At the moment, you only see your own avatar correctly, all other user's avatars show up as the old ruth. This will be fixed soon. We also need better clothing for the new ruth and to edit the body shape. To get this working you will need to delete your asset yap file and also in grid mode the user server needs to be updated. --- .../Framework/Communications/Cache/AssetCache.cs | 15 ++++--- .../Communications/Cache/LibraryRootFolder.cs | 49 ++++++++++++++++++---- .../Framework/Communications/Capabilities/Caps.cs | 2 +- 3 files changed, 48 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 32ba830..0c6d971 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -350,7 +350,6 @@ namespace OpenSim.Framework.Communications.Caches Transfer.TransferInfo.TargetType = 0; if (req.AssetRequestSource == 2) { - //Transfer.TransferInfo.Params = req.Params; Transfer.TransferInfo.Params = new byte[20]; Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); int assType = (int)req.AssetInf.Type; @@ -389,19 +388,19 @@ namespace OpenSim.Framework.Communications.Caches { chunk = new byte[req.AssetInf.Data.Length]; Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length); + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 1; + req.RequestUser.OutPacket(TransferPacket); } else { chunk = new byte[1000]; Array.Copy(req.AssetInf.Data, chunk, 1000); - } - TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 0; - req.RequestUser.OutPacket(TransferPacket); + TransferPacket.TransferData.Data = chunk; + TransferPacket.TransferData.Status = 0; + req.RequestUser.OutPacket(TransferPacket); - if (req.AssetInf.Data.Length > 1000) - { TransferPacket = new TransferPacketPacket(); TransferPacket.TransferData.Packet = 1; TransferPacket.TransferData.ChannelType = 2; @@ -411,7 +410,7 @@ namespace OpenSim.Framework.Communications.Caches TransferPacket.TransferData.Data = chunk1; TransferPacket.TransferData.Status = 1; req.RequestUser.OutPacket(TransferPacket); - } + } } } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index f807b2b..7813adc 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); item.inventoryDescription = "Plywood texture"; item.inventoryName = "Plywood"; - item.type = 0; + item.assetType = 0; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -58,7 +58,7 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003"); item.inventoryDescription = "Rocks texture"; item.inventoryName = "Rocks"; - item.type = 0; + item.assetType = 0; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -73,7 +73,7 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001"); item.inventoryDescription = "Bricks texture"; item.inventoryName = "Bricks"; - item.type = 0; + item.assetType = 0; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004"); item.inventoryDescription = "Granite texture"; item.inventoryName = "Granite"; - item.type = 0; + item.assetType = 0; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -103,7 +103,7 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005"); item.inventoryDescription = "Hardwood texture"; item.inventoryName = "Hardwood"; - item.type = 0; + item.assetType = 0; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -118,7 +118,8 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); item.inventoryDescription = "Default Shape"; item.inventoryName = "Default Shape"; - item.type = 13; + item.assetType = 13; + item.invType = 18; item.parentFolderID = this.folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; @@ -131,12 +132,41 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); item.inventoryDescription = "Default Skin"; item.inventoryName = "Default Skin"; - item.type = 13; + item.assetType = 13; + item.invType = 18; item.parentFolderID = this.folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; this.Items.Add(item.inventoryID, item); - + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"); + item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + item.inventoryDescription = "Default Shirt"; + item.inventoryName = "Default Shirt"; + item.assetType = 5; + item.invType = 18; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + this.Items.Add(item.inventoryID, item); + + item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"); + item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + item.inventoryDescription = "Default Pants"; + item.inventoryName = "Default Pants"; + item.assetType = 5; + item.invType = 18; + item.parentFolderID = this.folderID; + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + this.Items.Add(item.inventoryID, item); + item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -144,7 +174,8 @@ namespace OpenSim.Framework.Communications.Caches item.assetID = new LLUUID("00000000-0000-2222-3333-000000000001"); item.inventoryDescription = "Welcome"; item.inventoryName = "Welcome"; - item.type = 7; + item.assetType = 7; + item.invType = 7; item.parentFolderID = this.folderID; item.inventoryCurrentPermissions = (1 << 15); item.inventoryNextPermissions = (1 << 15); diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 5df66f4..a55297a 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -299,7 +299,7 @@ namespace OpenSim.Region.Capabilities private LLUUID newAssetID; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveImages = true; + private bool SaveImages = false; private string m_assetName = ""; /// -- cgit v1.1 From e86396ad1fbb492dd2164b7d26f3ed87e0ba0fa0 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jul 2007 13:44:12 +0000 Subject: You should now see the correct Avatar for other users, including their clothes, although their still seems to be a few problems with the clothes, in that sometimes other avatar's default clothes are white. At last, removed the need for the avatar-texture.dat file. (Please never come back). --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a55297a..5aacecb 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } - + /// /// /// -- cgit v1.1 From 038774de30ce26120c91ccd8e1cda1b2a89e1841 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 29 Jul 2007 09:37:29 +0000 Subject: Commit 1/2 * DB4o no longer crashes the sim on Startup * DB4o now crashes the sim on shutdown. * Variety of console verbosity fixes. --- OpenSim/Framework/Communications/Cache/UserProfileCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 32c5db9..2f3691c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications.Caches } else { - Console.WriteLine("UserProfileCache.cs: user profile for user not found"); + Console.WriteLine("CACHE", "User profile for user not found"); } } } -- cgit v1.1 From 5ee2e38c11785e9b68ecf1767af7a4ea5b13b7c7 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jul 2007 13:05:57 +0000 Subject: Deleting objects should now work. But beware they aren't send to your trash folder or anything so there is at the moment no way to recover deleted objects. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0c6d971..e4c01b3 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -272,6 +272,7 @@ namespace OpenSim.Framework.Communications.Caches //inventory asset request requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); source = 3; + Console.WriteLine("asset request " + requestID); } //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); -- cgit v1.1 From 74bb5282a09ec095a7ff810c62f79cc64e187686 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 30 Jul 2007 20:11:40 +0000 Subject: mass update of files to have native line endings --- .../Framework/Communications/Capabilities/Caps.cs | 724 ++++++++++----------- .../Communications/Capabilities/LLSDArray.cs | 84 +-- .../Capabilities/LLSDAssetUploadComplete.cs | 90 +-- .../Capabilities/LLSDAssetUploadRequest.cs | 42 +- .../Capabilities/LLSDAssetUploadResponse.cs | 36 +- .../Communications/Capabilities/LLSDCapEvent.cs | 82 +-- .../Communications/Capabilities/LLSDCapsDetails.cs | 36 +- .../Communications/Capabilities/LLSDEmpty.cs | 76 +-- .../Communications/Capabilities/LLSDHelpers.cs | 328 +++++----- .../Communications/Capabilities/LLSDMapLayer.cs | 92 +-- .../Capabilities/LLSDMapLayerResponse.cs | 82 +-- .../Communications/Capabilities/LLSDMapRequest.cs | 26 +- .../Communications/Capabilities/LLSDMethod.cs | 16 +- .../Capabilities/LLSDStreamHandler.cs | 84 +-- .../Communications/Capabilities/LLSDTest.cs | 82 +-- .../Communications/Capabilities/LLSDType.cs | 118 ++-- 16 files changed, 999 insertions(+), 999 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 5aacecb..05fa963 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -1,362 +1,362 @@ -/* -* 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.")] - //Commented out the obsolete as at this time the first caps request can not use the new Caps method - //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. - 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 = 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(); - } - } - } -} +/* +* 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.")] + //Commented out the obsolete as at this time the first caps request can not use the new Caps method + //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. + 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 = 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/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index e04849f..d3e1979 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -1,42 +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() - { - - } - } -} +/* +* 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 index ce373c0..db9836c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -1,45 +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() - { - - } - } -} +/* +* 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 index 7ef77cb..0096fb1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -1,21 +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() - { - } - } -} +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 index 1a620ae..2a2a5d1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -1,18 +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() - { - - } - } -} +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 index 51b4fe0..2c2689b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -1,41 +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() - { - - } - } -} +/* +* 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 index 3b6a629..cae7e97 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -1,18 +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() - { - - } - } -} +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 index d79c09e..ca27c9d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -1,38 +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() - { - - } - } -} +/* +* 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 index 19ef0c9..efeb9b1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -1,164 +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; - } - } - - - - - - - - - - - - - - - - - - - -} +/* +* 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 index 566d0e9..e0c006c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -1,46 +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() - { - - } - } -} +/* +* 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 index ce746ae..8b9837b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -1,41 +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() - { - - } - } -} +/* +* 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 index fb739cd..8ac7943 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -1,13 +1,13 @@ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapRequest - { - public int Flags = 0; - - public LLSDMapRequest() - { - - } - } -} +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 index 5f42f44..068d539 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Capabilities -{ - public delegate TResponse LLSDMethod(TRequest request); -} +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 index 7d99b6e..d98e23f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -1,42 +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) ); - - } - } -} +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 index f23e327..78ccf67 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -1,41 +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() - { - - } - } -} +/* +* 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 index c58a937..04f4d9a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -1,59 +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" ) - { - } - } -} +/* +* 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" ) + { + } + } +} -- cgit v1.1 From 55b569069dfd6eb7c87d4fbd66d68083878f6c65 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 31 Jul 2007 14:42:50 +0000 Subject: clear userAgent state on client shutdown, which fixes the issue where you could only login once with a given id in standalone mode. --- OpenSim/Framework/Communications/IUserServices.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index cd97b52..40a3182 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -35,6 +35,7 @@ namespace OpenSim.Framework.Communications UserProfileData GetUserProfile(string firstName, string lastName); UserProfileData GetUserProfile(string name); UserProfileData GetUserProfile(LLUUID avatarID); + void clearUserAgent(LLUUID avatarID); UserProfileData SetupMasterUser(string firstName, string lastName); UserProfileData SetupMasterUser(string firstName, string lastName, string password); -- cgit v1.1 From edc572dacf3ff65c5584f8c02bb291abce0c7122 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 1 Aug 2007 16:50:20 +0000 Subject: Some more work on SceneObject/primitive rewrites (AllNewSceneObjectGroup2 /Part2). Updated the JavaVM to a later version I did (basically some clean up and a little bit more functional). Added SendLoadURL method to IClientAPI. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 13 +++++++------ .../Communications/Capabilities/LLSDCapsDetails.cs | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 05fa963..d133617 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Capabilities private string m_requestPath = "0000/"; private string m_mapLayerPath = "0001/"; private string m_newInventory = "0002/"; - // private string m_requestTexture = "0003/"; + //private string m_requestTexture = "0003/"; private string m_notecardUpdatePath = "0004/"; //private string eventQueue = "0100/"; private BaseHttpServer httpListener; @@ -79,6 +79,7 @@ namespace OpenSim.Region.Capabilities httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); + //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); } @@ -116,7 +117,6 @@ namespace OpenSim.Region.Capabilities 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; } @@ -299,7 +299,7 @@ namespace OpenSim.Region.Capabilities private LLUUID newAssetID; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveImages = false; + private bool SaveAssets = false; private string m_assetName = ""; /// @@ -338,8 +338,8 @@ namespace OpenSim.Region.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); - if(this.SaveImages) - this.SaveImageToFile(m_assetName + ".jp2", data); + if(this.SaveAssets) + this.SaveAssetToFile(m_assetName + ".jp2", data); if (OnUpLoad != null) { @@ -349,7 +349,7 @@ namespace OpenSim.Region.Capabilities return res; } - private void SaveImageToFile(string filename, byte[] data) + private void SaveAssetToFile(string filename, byte[] data) { FileStream fs = File.Create(filename); BinaryWriter bw = new BinaryWriter(fs); @@ -360,3 +360,4 @@ namespace OpenSim.Region.Capabilities } } } + diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index cae7e97..913d7ab 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -6,9 +6,10 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - //public string RequestTextureDownload = ""; - //public string ChatSessionRequest = ""; + // public string RequestTextureDownload = ""; + // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; + // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() { @@ -16,3 +17,5 @@ namespace OpenSim.Region.Capabilities } } } + + -- cgit v1.1 From cdd1285e9ef2af6196d53941efcad4626624cabc Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 1 Aug 2007 18:04:31 +0000 Subject: few small changes. Updated libsl to latest version. --- OpenSim/Framework/Communications/IInventoryServices.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 807952c..b78cba1 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -4,6 +4,7 @@ using System.Text; using OpenSim.Framework.Data; using libsecondlife; using OpenSim.Framework.Communications.Caches; +using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications { -- cgit v1.1 From 5ac5785cf2af152b44d8faeb3207b671b81c6684 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 7 Aug 2007 17:22:15 +0000 Subject: a couple of changes in the new Sceneobject classes, just committing so things are kept in sync. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 7813adc..9e54701 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -181,9 +181,7 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryNextPermissions = (1 << 15); item.inventoryEveryOnePermissions = (1 << 15); item.inventoryBasePermissions = (1 << 15); - this.Items.Add(item.inventoryID, item); - - + this.Items.Add(item.inventoryID, item); } } -- cgit v1.1 From 5061a703eafedaaec01b756ac0fd3ac5ea51d3c5 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Wed, 8 Aug 2007 07:00:56 +0000 Subject: CAPS should now be working in standalone mode. Texture uploads will work even after you cross a region boundary. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d133617..82ef08d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -74,13 +74,18 @@ namespace OpenSim.Region.Capabilities { Console.WriteLine("registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; + try + { + httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer)); + httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); - 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_requestTexture , RequestTexture); - AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); + AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); + //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); + AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); + } + catch + { + } } @@ -361,3 +366,4 @@ namespace OpenSim.Region.Capabilities } } + -- cgit v1.1 From cf203cf5ee809d3832daafbed12eb130bd590f5c Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 8 Aug 2007 17:11:02 +0000 Subject: The startup set of assets in the local asset server can now be set from a xml file (OpenSimAssetSet.xml). (remember to make changes to the set, you will also need to delete the old asset .yap file, so that it is recreated). Also the set of items in the OpenSim inventory Library can also now be set from a xml file (OpenSimLibrary.xml). --- .../Communications/Cache/LibraryRootFolder.cs | 45 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 9e54701..b214598 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -1,8 +1,11 @@ using System; +using System.IO; using System.Collections.Generic; using System.Text; using libsecondlife; +using OpenSim.Framework.Utilities; using OpenSim.Framework.Data; +using Nini.Config; namespace OpenSim.Framework.Communications.Caches { @@ -18,7 +21,7 @@ namespace OpenSim.Framework.Communications.Caches this.name = "OpenSim Library"; this.parentID = LLUUID.Zero; this.type = (short)-1; - this.version = (ushort) 1; + this.version = (ushort)1; InventoryFolder folderInfo = new InventoryFolder(); folderInfo.agentID = libOwner; @@ -31,11 +34,15 @@ namespace OpenSim.Framework.Communications.Caches this.m_textureFolder = folderInfo; this.CreateLibraryItems(); + + string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); + XmlConfigSource source = new XmlConfigSource(filePath); + this.ReadItemsFromFile(source); } private void CreateLibraryItems() { - + InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -167,6 +174,7 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryNextPermissions = 0; this.Items.Add(item.inventoryID, item); + /* item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -181,7 +189,38 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryNextPermissions = (1 << 15); item.inventoryEveryOnePermissions = (1 << 15); item.inventoryBasePermissions = (1 << 15); - this.Items.Add(item.inventoryID, item); + this.Items.Add(item.inventoryID, item); + */ + } + + private void ReadItemsFromFile(IConfigSource source) + { + for (int i = 0; i < source.Configs.Count; i++) + { + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); + item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + item.inventoryDescription = source.Configs[i].GetString("description", ""); + item.inventoryName = source.Configs[i].GetString("name", ""); + item.assetType = source.Configs[i].GetInt("assetType", 0); + item.invType = source.Configs[i].GetInt("inventoryType", 0); + item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + if (item.assetType == 0) + { + item.parentFolderID = this.m_textureFolder.folderID; + this.m_textureFolder.Items.Add(item.inventoryID, item); + } + else + { + item.parentFolderID = this.folderID; + this.Items.Add(item.inventoryID, item); + } + } } } -- cgit v1.1 From 369fb2e623acae2ad6ef0508a665d7622a39217d Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 8 Aug 2007 17:29:37 +0000 Subject: Added checks to the last commit to make sure the xml files exist before it tries to load them. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index b214598..2eb59d2 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -36,8 +36,11 @@ namespace OpenSim.Framework.Communications.Caches this.CreateLibraryItems(); string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); - XmlConfigSource source = new XmlConfigSource(filePath); - this.ReadItemsFromFile(source); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + this.ReadItemsFromFile(source); + } } private void CreateLibraryItems() -- cgit v1.1 From be483bc697220effb97338531de4357248f5d71f Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 8 Aug 2007 18:55:58 +0000 Subject: Hopefully improved texture downloading (including the speed at which they download), but still a few problems, it seems that the client has a quite short timeout for receiving a texture and if the whole texture isn't sent within this time, the client will request the texture again, With quite small textures this is fine, but it seems that with larger textures we can't send them fast enough and a infinite loop develops where the client keeps requesting a texture and we keep trying to send it, but are never fast enough. So I've for now put code in that so that the server will try to send a texture only once and then after that will ignore future requests from that client for that texture. --- .../Framework/Communications/Cache/AssetCache.cs | 118 +++++++++++++++------ 1 file changed, 83 insertions(+), 35 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e4c01b3..ca74724 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -28,12 +28,14 @@ using System; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Threading; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications.Caches { @@ -54,9 +56,15 @@ namespace OpenSim.Framework.Communications.Caches public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server public Dictionary SendingTextures = new Dictionary(); + private BlockingQueue QueueTextures = new BlockingQueue(); + + private Dictionary> AvatarRecievedTextures = new Dictionary>(); + private IAssetServer _assetServer; private Thread _assetCacheThread; + private Thread TextureSenderThread; + /// /// /// @@ -71,6 +79,10 @@ namespace OpenSim.Framework.Communications.Caches this._assetCacheThread.IsBackground = true; this._assetCacheThread.Start(); + this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders)); + this.TextureSenderThread.IsBackground = true; + this.TextureSenderThread.Start(); + } public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) @@ -85,6 +97,9 @@ namespace OpenSim.Framework.Communications.Caches this._assetCacheThread.IsBackground = true; this._assetCacheThread.Start(); + this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders)); + this.TextureSenderThread.IsBackground = true; + this.TextureSenderThread.Start(); } /// @@ -165,12 +180,14 @@ namespace OpenSim.Framework.Communications.Caches req = (AssetRequest)this.TextureRequests[i]; if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) { + //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); - sender.OnComplete += this.TextureSent; + //sender.OnComplete += this.TextureSent; lock (this.SendingTextures) { this.SendingTextures.Add(req.ImageInfo.FullID, sender); } + this.QueueTextures.Enqueue(sender); } } @@ -178,6 +195,25 @@ namespace OpenSim.Framework.Communications.Caches this.TextureRequests.Clear(); } + public void ProcessTextureSenders() + { + while (true) + { + TextureSender sender = this.QueueTextures.Dequeue(); + bool finished = sender.SendTexture(); + if (finished) + { + this.TextureSent(sender); + } + else + { + // Console.WriteLine("readding texture"); + this.QueueTextures.Enqueue(sender); + } + } + + } + /// /// Event handler, called by a TextureSender object to say that texture has been sent /// @@ -189,6 +225,7 @@ namespace OpenSim.Framework.Communications.Caches lock (this.SendingTextures) { this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } } @@ -201,8 +238,10 @@ namespace OpenSim.Framework.Communications.Caches //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) { + // Console.WriteLine("asset recieved from asset server"); TextureImage image = new TextureImage(asset); this.Textures.Add(image.FullID, image); if (this.RequestedTextures.ContainsKey(image.FullID)) @@ -212,7 +251,7 @@ namespace OpenSim.Framework.Communications.Caches if (image.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; + req.NumPackets = 1 + (int)(image.Data.Length - 600 ) / 1000; } else { @@ -260,7 +299,7 @@ namespace OpenSim.Framework.Communications.Caches /// public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { - LLUUID requestID = null; + LLUUID requestID = null; byte source = 2; if (transferRequest.TransferInfo.SourceType == 2) { @@ -359,7 +398,7 @@ namespace OpenSim.Framework.Communications.Caches else if (req.AssetRequestSource == 3) { Transfer.TransferInfo.Params = req.Params; - // Transfer.TransferInfo.Params = new byte[100]; + // Transfer.TransferInfo.Params = new byte[100]; //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } @@ -411,7 +450,7 @@ namespace OpenSim.Framework.Communications.Caches TransferPacket.TransferData.Data = chunk1; TransferPacket.TransferData.Status = 1; req.RequestUser.OutPacket(TransferPacket); - } + } } } @@ -444,8 +483,17 @@ namespace OpenSim.Framework.Communications.Caches /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) { - //Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); + // Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); //check to see if texture is in local cache, if not request from asset server + if(!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + { + this.AvatarRecievedTextures.Add(userInfo.AgentId, new List()); + } + if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) + { + //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); + return; + } if (!this.Textures.ContainsKey(imageID)) { if (!this.RequestedTextures.ContainsKey(imageID)) @@ -472,7 +520,8 @@ namespace OpenSim.Framework.Communications.Caches if (imag.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; + req.NumPackets = 1 + (int)(imag.Data.Length - 600 ) / 1000; + //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); } else { @@ -582,37 +631,22 @@ namespace OpenSim.Framework.Communications.Caches 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() + public bool SendTexture() { - //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); - while (request.PacketCounter != request.NumPackets) + SendPacket(); + + if ((request.PacketCounter > request.NumPackets) |(request.NumPackets ==1)) { - SendPacket(); - Thread.Sleep(500); - } - - //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); - if (OnComplete != null) - { - OnComplete(this); + return true; } + return false; } public void SendPacket() @@ -643,13 +677,14 @@ namespace OpenSim.Framework.Communications.Caches { //more than one packet so split file up ImageDataPacket im = new ImageDataPacket(); - im.ImageID.Packets = (ushort)req.NumPackets; + 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); + //this.SaveAssetToFile("packetheader.dat", im.ImageData.Data); req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent first packet of texture: @@ -658,23 +693,36 @@ namespace OpenSim.Framework.Communications.Caches } else { - //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); + // 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.Packet = (ushort)(req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); + 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); + Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, size); req.RequestUser.OutPacket(im); + //if (req.PacketCounter == req.NumPackets) + // { + // this.SaveAssetToFile("packet"+req.PacketCounter+".dat", im.ImageData.Data); + //} req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); } } + + private void SaveAssetToFile(string filename, byte[] data) + { + FileStream fs = File.Create(filename); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close(); + } } } } -- cgit v1.1 From a13770361142faaaae7e535eae9526586de1106f Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 8 Aug 2007 19:51:51 +0000 Subject: Fixed the asset download problem I think, solution might not be ideal but works for now. --- .../Framework/Communications/Cache/AssetCache.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index ca74724..acdd593 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -211,7 +211,6 @@ namespace OpenSim.Framework.Communications.Caches this.QueueTextures.Enqueue(sender); } } - } /// @@ -481,7 +480,7 @@ namespace OpenSim.Framework.Communications.Caches /// /// /// - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) + public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber) { // Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); //check to see if texture is in local cache, if not request from asset server @@ -489,11 +488,11 @@ namespace OpenSim.Framework.Communications.Caches { this.AvatarRecievedTextures.Add(userInfo.AgentId, new List()); } - if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) + /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) { //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; - } + }*/ if (!this.Textures.ContainsKey(imageID)) { if (!this.RequestedTextures.ContainsKey(imageID)) @@ -527,6 +526,10 @@ namespace OpenSim.Framework.Communications.Caches { req.NumPackets = 1; } + if (packetNumber != 0) + { + req.PacketCounter = (int)packetNumber; + } this.TextureRequests.Add(req); } @@ -653,8 +656,6 @@ namespace OpenSim.Framework.Communications.Caches { 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 @@ -684,7 +685,7 @@ namespace OpenSim.Framework.Communications.Caches Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); im.ImageID.Codec = 2; req.RequestUser.OutPacket(im); - //this.SaveAssetToFile("packetheader.dat", im.ImageData.Data); + req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent first packet of texture: @@ -693,7 +694,7 @@ namespace OpenSim.Framework.Communications.Caches } else { - // Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); + //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(); @@ -704,10 +705,6 @@ namespace OpenSim.Framework.Communications.Caches 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); - //if (req.PacketCounter == req.NumPackets) - // { - // this.SaveAssetToFile("packet"+req.PacketCounter+".dat", im.ImageData.Data); - //} req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); -- cgit v1.1 From a56a17fab20e1ef94e70dbf6648ebb2f437de364 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 9 Aug 2007 12:59:42 +0000 Subject: Making sure my local working copy is in sync with svn before I start the job of enabling the new SceneObject classes. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 8 +++++--- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index acdd593..3866e21 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -224,7 +224,7 @@ namespace OpenSim.Framework.Communications.Caches lock (this.SendingTextures) { this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); + // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } } @@ -634,7 +634,8 @@ namespace OpenSim.Framework.Communications.Caches public class TextureSender { public AssetRequest request; - + private int counter = 0; + public TextureSender(AssetRequest req) { request = req; @@ -644,8 +645,9 @@ namespace OpenSim.Framework.Communications.Caches public bool SendTexture() { SendPacket(); + counter++; - if ((request.PacketCounter > request.NumPackets) |(request.NumPackets ==1)) + if ((request.PacketCounter > request.NumPackets) | (counter >120) |(request.NumPackets ==1)) { return true; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 82ef08d..d56cf6f 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.Capabilities private LLUUID newAssetID; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveAssets = false; + private bool SaveAssets = true; private string m_assetName = ""; /// -- cgit v1.1 From d451dddcd0e061cd5aa326cb08d6e24e08817dcc Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 9 Aug 2007 17:54:22 +0000 Subject: Start of replacing the old SceneObject/Primitive classes with the new versions. PLEASE NOTE: that with this revision some prim related features may be broke for a while. (things like linking prims and the parcel prim count.) Also this revision may not work on mono, but that will be fixed soon. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d56cf6f..82ef08d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.Capabilities private LLUUID newAssetID; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveAssets = true; + private bool SaveAssets = false; private string m_assetName = ""; /// -- cgit v1.1 From e34f5edb701c82e8e6cb97f78281f966cc996db6 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 13 Aug 2007 13:37:50 +0000 Subject: Deleted some unused code. --- .../Framework/Communications/Cache/LibraryRootFolder.cs | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 2eb59d2..6d85477 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -177,23 +177,6 @@ namespace OpenSim.Framework.Communications.Caches item.inventoryNextPermissions = 0; this.Items.Add(item.inventoryID, item); - /* - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("00000000-0000-2222-4444-000000000001"); - item.assetID = new LLUUID("00000000-0000-2222-3333-000000000001"); - item.inventoryDescription = "Welcome"; - item.inventoryName = "Welcome"; - item.assetType = 7; - item.invType = 7; - item.parentFolderID = this.folderID; - item.inventoryCurrentPermissions = (1 << 15); - item.inventoryNextPermissions = (1 << 15); - item.inventoryEveryOnePermissions = (1 << 15); - item.inventoryBasePermissions = (1 << 15); - this.Items.Add(item.inventoryID, item); - */ } private void ReadItemsFromFile(IConfigSource source) -- cgit v1.1 From a228b5984e6523456871f2f8e51aa086050acbf2 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 13:54:46 +0000 Subject: Start of Inventory service, currently only (partially) functional in standalone mode and using sqlite). In standalone mode, if you have account authenticate turned on (setting in opensim.ini) then when you create a new account, a set of inventory is created for that account and stored in database (currently only a set of empty folders). Then during login the database is search for that set and sent to the client in the login response. More functions will be added soon, like creating new folders (and a bit later items) from the client inventory window. --- OpenSim/Framework/Communications/Cache/InventoryFolder.cs | 15 +++++++++++++++ .../Framework/Communications/Cache/UserProfileCache.cs | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 300a6e3..6b0e2b4 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -44,6 +44,21 @@ namespace OpenSim.Framework.Communications.Caches public Dictionary Items = new Dictionary(); public Dictionary SubFolders = new Dictionary(); + public InventoryFolder(InventoryFolderBase folderbase) + { + this.agentID = folderbase.agentID; + this.folderID = folderbase.folderID; + this.name = folderbase.name; + this.parentID = folderbase.parentID; + this.type = folderbase.type; + this.version = folderbase.version; + } + + public InventoryFolder() + { + + } + // Methods public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 2f3691c..2271550 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -168,18 +168,18 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - // this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + //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 folderInfo = new InventoryFolder(); + /* InventoryFolder folderInfo = new InventoryFolder(); folderInfo.agentID = userID; folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; folderInfo.name = "My Inventory"; folderInfo.parentID = LLUUID.Zero; folderInfo.type = 8; folderInfo.version = 1; - userInfo.FolderReceive(userID, folderInfo); + userInfo.FolderReceive(userID, folderInfo);*/ } /// -- cgit v1.1 From ff08d4d016c048d78cc6de86e62d8e94748bf968 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 14:57:52 +0000 Subject: More inventory work, should be able to now create new inventory folders and them be stored in database (so are there on next login). Again only works in standalone mode with Account/password authentication turned on. [Creating new inventory items should be working very soon.] The test is to make sure that it hasn't broke grid mode at all. --- .../Communications/Cache/CachedUserInfo.cs | 4 +- .../Communications/Cache/UserProfileCache.cs | 59 +++++++++++++--------- .../Framework/Communications/IInventoryServices.cs | 1 + 3 files changed, 39 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d850305..fc2f948 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -41,8 +41,8 @@ namespace OpenSim.Framework.Communications.Caches public class CachedUserInfo { // Fields - public InventoryFolder RootFolder; - public UserProfileData UserProfile; + public InventoryFolder RootFolder = null; + public UserProfileData UserProfile = null; // Methods public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 2271550..e65b6b2 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -98,17 +98,24 @@ namespace OpenSim.Framework.Communications.Caches { if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == parentID) + if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) { - info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - } - else - { - InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); - if (folder != null) + CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == parentID) + { + InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + if (createdFolder != null) + { + this.m_parent.InventoryServer.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + } + } + else { - folder.CreateNewSubFolder(folderID, folderName, folderType); + InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); + if (folder != null) + { + folder.CreateNewSubFolder(folderID, folderName, folderType); + } } } } @@ -127,20 +134,23 @@ namespace OpenSim.Framework.Communications.Caches } else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == folderID) + if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) { - if (fetchItems) + CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + if (info.RootFolder.folderID == folderID) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + if (fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + } } - } - else - { - InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); - if ((folder != null) && fetchItems) + else { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); + if ((folder != null) && fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + } } } } @@ -154,10 +164,13 @@ namespace OpenSim.Framework.Communications.Caches } else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { - InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); - if (item != null) + if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) { - remoteClient.SendInventoryItemDetails(ownerID, item); + InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + if (item != null) + { + remoteClient.SendInventoryItemDetails(ownerID, item); + } } } } @@ -168,7 +181,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - //this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + 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. diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index b78cba1..777dbe2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -14,5 +14,6 @@ namespace OpenSim.Framework.Communications public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); } } -- cgit v1.1 From 181a90967ee9084676f84e74b2393855218c5723 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 17:29:15 +0000 Subject: Start of inventory items, when you upload a texture the data will now be stored in the inventory database and you will still have that texture in inventory on later logins (Again only in standalone mode with authentication.) Also there might be some problems if you upload textures in other regions to the start one (due to us not updating the CAPS url properly). --- .../Communications/Cache/AssetTransactions.cs | 4 +- .../Communications/Cache/CachedUserInfo.cs | 21 ++++++++++- .../Communications/Cache/UserProfileCache.cs | 2 +- .../Framework/Communications/Capabilities/Caps.cs | 43 ++++++++++++++++++---- .../Framework/Communications/IInventoryServices.cs | 1 + 5 files changed, 60 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index c906b76..e12d234 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); } return text; } @@ -266,7 +266,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); } return text; } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index fc2f948..123e692 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -40,10 +40,16 @@ namespace OpenSim.Framework.Communications.Caches { public class CachedUserInfo { + private CommunicationsManager m_parentCommsManager; // Fields public InventoryFolder RootFolder = null; public UserProfileData UserProfile = null; + public CachedUserInfo(CommunicationsManager commsManager) + { + m_parentCommsManager = commsManager; + } + // Methods public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) { @@ -73,6 +79,7 @@ namespace OpenSim.Framework.Communications.Caches public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { + Console.WriteLine("received new inventory item " + itemInfo.inventoryID + " with asset id of " + itemInfo.assetID); if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { if (itemInfo.parentFolderID == this.RootFolder.folderID) @@ -84,11 +91,23 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + folder.Items.Add(itemInfo.inventoryID, itemInfo); } } } } + + public void AddItem(LLUUID userID, InventoryItemBase itemInfo) + { + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + this.ItemReceive(userID, itemInfo); + Console.WriteLine("now adding inventory item to database"); + this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); + } + } } + + } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index e65b6b2..02c5f65 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -61,7 +61,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.UserProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(); + CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); userInfo.UserProfile = this.RequestUserProfileForUser(userID); if (userInfo.UserProfile != null) { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 82ef08d..eb88aa7 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -35,10 +35,12 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedTexture(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data); + public delegate void UpLoadedTexture(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); + public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public class Caps { @@ -56,6 +58,7 @@ namespace OpenSim.Region.Capabilities private AssetCache assetCache; private int eventQueueCount = 1; private Queue CapsEventQueue = new Queue(); + public NewInventoryItem AddNewInventoryItem = null; public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { @@ -122,7 +125,7 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; + // caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; return caps; } @@ -242,7 +245,7 @@ namespace OpenSim.Region.Capabilities LLUUID newInvItem = LLUUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, "description", newAsset, newInvItem, LLUUID.Zero, "", "", capsBase + uploaderPath, this.httpListener); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -261,13 +264,16 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { // Console.WriteLine("asset upload request via CAPS"); + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; LLUUID newAsset = LLUUID.Random(); LLUUID newInvItem = LLUUID.Random(); + LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, "" , "", capsBase + uploaderPath, this.httpListener); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -284,7 +290,7 @@ namespace OpenSim.Region.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data) + public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data) { AssetBase asset; asset = new AssetBase(); @@ -294,6 +300,25 @@ namespace OpenSim.Region.Capabilities asset.Name = assetName; asset.Data = data; this.assetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = agentID; + item.creatorsID = agentID; + item.inventoryID = inventoryItem; + item.assetID = asset.FullID; + item.inventoryDescription = assetDescription; + item.inventoryName = assetName; + item.assetType = 0; + item.invType = 0; + item.parentFolderID = parentFolder; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + + if (AddNewInventoryItem != null) + { + AddNewInventoryItem(agentID, item); + } + } public class AssetUploader @@ -303,9 +328,11 @@ namespace OpenSim.Region.Capabilities private string uploaderPath = ""; private LLUUID newAssetID; private LLUUID inventoryItemID; + private LLUUID parentFolder; private BaseHttpServer httpListener; private bool SaveAssets = false; private string m_assetName = ""; + private string m_assetDes = ""; /// /// @@ -314,13 +341,15 @@ namespace OpenSim.Region.Capabilities /// /// /// - public AssetUploader(string assetName, LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) + public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer) { m_assetName = assetName; + m_assetDes = description; newAssetID = assetID; inventoryItemID = inventoryItem; uploaderPath = path; httpListener = httpServer; + parentFolder = parentFolderID; } /// @@ -348,7 +377,7 @@ namespace OpenSim.Region.Capabilities if (OnUpLoad != null) { - OnUpLoad(m_assetName, newAssetID, inv, data); + OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data); } return res; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 777dbe2..6f01cf2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -15,5 +15,6 @@ namespace OpenSim.Framework.Communications { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); } } -- cgit v1.1 From 20b50489c0d57a5e3335c8329ba0133cfa7b7f8d Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 17:48:25 +0000 Subject: Can now create some new empty inventory items (like notecards and scripts) from the create menu in the inventory window. Although currently you can't update/edit them (and have those changes saved). --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 123e692..57c79b4 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -79,7 +79,6 @@ namespace OpenSim.Framework.Communications.Caches public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - Console.WriteLine("received new inventory item " + itemInfo.inventoryID + " with asset id of " + itemInfo.assetID); if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { if (itemInfo.parentFolderID == this.RootFolder.folderID) @@ -102,7 +101,6 @@ namespace OpenSim.Framework.Communications.Caches if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { this.ItemReceive(userID, itemInfo); - Console.WriteLine("now adding inventory item to database"); this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); } } -- cgit v1.1 From a979808493b20362ab3fe06ac68e5370622ceafa Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 19:19:09 +0000 Subject: preliminary support for editing notecards and scripts. Although there seems to sometimes be a problem of when you login again, old notecards and scripts will have their permissions messed up and you won't be able to even view their text. This seems to be related to the client's cache, and if you clear your client's cache, on the next login they should be fine again. [I have a couple of ideas about what might be causing this so hopefully will have it fixed soon.] --- .../Communications/Cache/AssetTransactions.cs | 4 +- .../Communications/Cache/CachedUserInfo.cs | 8 ++ .../Framework/Communications/Capabilities/Caps.cs | 102 +++++++++++++++++++-- .../Communications/Capabilities/LLSDCapsDetails.cs | 1 + .../Communications/Capabilities/LLSDItemUpdate.cs | 17 ++++ 5 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index e12d234..8909bdf 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Caches private string uploaderPath = ""; // Events - public event UpLoadedTexture OnUpLoad; + public event UpLoadedAsset OnUpLoad; // Methods public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches private string uploaderPath = ""; // Events - public event UpLoadedTexture OnUpLoad; + public event UpLoadedAsset OnUpLoad; // Methods public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 57c79b4..9970d80 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -104,6 +104,14 @@ namespace OpenSim.Framework.Communications.Caches this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); } } + + public void updateItem(LLUUID userID, InventoryItemBase itemInfo) + { + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); + } + } } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index eb88aa7..14f9c95 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -39,8 +39,10 @@ using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedTexture(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); + public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); + public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); + public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); public class Caps { @@ -59,6 +61,7 @@ namespace OpenSim.Region.Capabilities private int eventQueueCount = 1; private Queue CapsEventQueue = new Queue(); public NewInventoryItem AddNewInventoryItem = null; + public ItemUpdatedCallback ItemUpdatedCall = null; public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { @@ -125,7 +128,8 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - // caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; + caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; + caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; return caps; } @@ -238,21 +242,24 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { - Console.WriteLine("notecard update request " + request); - string assetName = "notecardupdate"; + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + string capsBase = "/CAPS/" + m_capsObjectPath; - LLUUID newAsset = LLUUID.Random(); - LLUUID newInvItem = LLUUID.Random(); + LLUUID newInvItem = llsdRequest.item_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, "description", newAsset, newInvItem, LLUUID.Zero, "", "", capsBase + uploaderPath, this.httpListener); + ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener); + uploader.OnUpLoad += this.ItemUpdated; + 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); } @@ -321,9 +328,18 @@ namespace OpenSim.Region.Capabilities } + public LLUUID ItemUpdated(LLUUID itemID, byte[] data) + { + if (ItemUpdatedCall != null) + { + return ItemUpdatedCall(this.agentID, itemID, data); + } + return LLUUID.Zero; + } + public class AssetUploader { - public event UpLoadedTexture OnUpLoad; + public event UpLoadedAsset OnUpLoad; private string uploaderPath = ""; private LLUUID newAssetID; @@ -392,6 +408,74 @@ namespace OpenSim.Region.Capabilities fs.Close(); } } + + public class ItemUpdater + { + public event UpdateItem OnUpLoad; + + private string uploaderPath = ""; + private LLUUID inventoryItemID; + private BaseHttpServer httpListener; + private bool SaveAssets = false; + + + /// + /// + /// + /// + /// + /// + /// + public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer) + { + + 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(); + LLUUID assetID = LLUUID.Zero; + + if (OnUpLoad != null) + { + assetID = OnUpLoad(inv, data); + } + + uploadComplete.new_asset = assetID.ToStringHyphenated(); + uploadComplete.new_inventory_item = inv; + uploadComplete.state = "complete"; + + res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); + + httpListener.RemoveStreamHandler("POST", uploaderPath); + + if (this.SaveAssets) + this.SaveAssetToFile("updateditem"+Util.RandomClass.Next(1,1000) + ".dat", data); + + return res; + } + + private void SaveAssetToFile(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/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index 913d7ab..af20468 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -9,6 +9,7 @@ namespace OpenSim.Region.Capabilities // public string RequestTextureDownload = ""; // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; + public string UpdateScriptAgentInventory = ""; // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs new file mode 100644 index 0000000..d47bb07 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDItemUpdate + { + public LLUUID item_id; + + public LLSDItemUpdate() + { + } + } +} -- cgit v1.1 From 94dded470d04f72c573bf0aa82e1f7522362c54a Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 15 Aug 2007 18:34:36 +0000 Subject: More work on inventory, can now create other inventory types, like Clothes and body parts. [Note while you can edit these, at the moment your changes won't be saved between restarts. This will be fixed very soon.] --- .../Cache/AssetTransactionManager.cs | 36 ++++++- .../Communications/Cache/AssetTransactions.cs | 114 +++++++++++++++++++-- .../Communications/CommunicationsManager.cs | 2 + 3 files changed, 141 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index f9f814a..1f5f99d 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -41,14 +41,20 @@ namespace OpenSim.Framework.Communications.Caches public class AssetTransactionManager { // Fields + public CommunicationsManager CommsManager; public Dictionary AgentTransactions = new Dictionary(); + public AssetTransactionManager(CommunicationsManager commsManager) + { + CommsManager = commsManager; + } + // Methods public AgentAssetTransactions AddUser(LLUUID userID) { if (!this.AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID); + AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this); this.AgentTransactions.Add(userID, transactions); return transactions; } @@ -64,18 +70,38 @@ namespace OpenSim.Framework.Communications.Caches return null; } - public void HandleInventoryFromTransaction() + public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) { + AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + if (transactions != null) + { + transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + } + } - public void HandleUDPUploadRequest() + public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) { + AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + if (transactions != null) + { + AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); + if (uploader != null) + { + uploader.Initialise(remoteClient, assetID, transaction, type, data); + } + } } - public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) + public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { + AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + if (transactions != null) + { + transactions.HandleXfer(xferID, packetID, data); + } } } } - + diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 8909bdf..cea6e6e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -35,6 +35,7 @@ using libsecondlife.Packets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Data; using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; @@ -47,11 +48,13 @@ namespace OpenSim.Framework.Communications.Caches public List NotecardUpdaters = new List(); public LLUUID UserID; public Dictionary XferUploaders = new Dictionary(); + public AssetTransactionManager Manager; // Methods - public AgentAssetTransactions(LLUUID agentID) + public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager) { this.UserID = agentID; + Manager = manager; } public AssetCapsUploader RequestCapsUploader() @@ -70,9 +73,34 @@ namespace OpenSim.Framework.Communications.Caches public AssetXferUploader RequestXferUploader(LLUUID transactionID) { - AssetXferUploader uploader = new AssetXferUploader(); - this.XferUploaders.Add(transactionID, uploader); - return uploader; + if (!this.XferUploaders.ContainsKey(transactionID)) + { + AssetXferUploader uploader = new AssetXferUploader(this); + + this.XferUploaders.Add(transactionID, uploader); + return uploader; + } + return null; + } + + public void HandleXfer(ulong xferID, uint packetID, byte[] data) + { + foreach (AssetXferUploader uploader in this.XferUploaders.Values) + { + if (uploader.XferID == xferID) + { + uploader.HandleXferPacket(xferID, packetID, data); + break; + } + } + } + + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + { + if (this.XferUploaders.ContainsKey(transactionID)) + { + this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + } } // Nested Types @@ -143,10 +171,23 @@ namespace OpenSim.Framework.Communications.Caches private IClientAPI ourClient; public LLUUID TransactionID = LLUUID.Zero; public bool UploadComplete; - public uint XferID; + public ulong XferID; + private string m_name = ""; + private string m_description = ""; + private sbyte type = 0; + private sbyte invType = 0; + private uint nextPerm = 0; + private bool m_finished = false; + private bool m_createItem = false; + private AgentAssetTransactions m_userTransactions; + + public AssetXferUploader(AgentAssetTransactions transactions) + { + this.m_userTransactions = transactions; + } // Methods - public void HandleXferPacket(uint xferID, uint packetID, byte[] data) + public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) { if (this.XferID == xferID) { @@ -216,6 +257,67 @@ namespace OpenSim.Framework.Communications.Caches newPack.AssetBlock.Success = true; newPack.AssetBlock.UUID = this.Asset.FullID; this.ourClient.OutPacket(newPack); + this.m_finished = true; + if (m_createItem) + { + DoCreateItem(); + } + Console.WriteLine("upload complete "+ this.TransactionID); + //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + } + private void SaveAssetToFile(string filename, byte[] data) + { + FileStream fs = File.Create(filename); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close(); + } + + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + { + if (this.TransactionID == transactionID) + { + this.InventFolder = folderID; + this.m_name = name; + this.m_description = description; + this.type = type; + this.invType = invType; + this.nextPerm = nextOwnerMask; + this.Asset.Name = name; + this.Asset.Description = description; + this.Asset.Type = type; + this.Asset.InvType = invType; + m_createItem = true; + if (m_finished) + { + DoCreateItem(); + } + } + } + + private void DoCreateItem() + { + this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); + CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId); + if (userInfo != null) + { + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = this.ourClient.AgentId; + item.creatorsID = ourClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = Asset.FullID; + item.inventoryDescription = this.m_description; + item.inventoryName = m_name; + item.assetType = type; + item.invType = this.invType; + item.parentFolderID = this.InventFolder; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = this.nextPerm; + + userInfo.AddItem(ourClient.AgentId, item); + ourClient.SendInventoryItemUpdate(item); + } } } diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index ac882ba..7676597 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -45,6 +45,7 @@ namespace OpenSim.Framework.Communications public IInventoryServices InventoryServer; public IInterRegionCommunications InterRegion; public UserProfileCache UserProfiles; + public AssetTransactionManager TransactionsManager; public AssetCache AssetCache; public NetworkServersInfo ServersInfo; @@ -53,6 +54,7 @@ namespace OpenSim.Framework.Communications ServersInfo = serversInfo; this.AssetCache = assetCache; UserProfiles = new UserProfileCache(this); + TransactionsManager = new AssetTransactionManager(this); } #region Packet Handlers -- cgit v1.1 From b6c48c53b21df9dbde4549bced938089f43ed1f0 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 16 Aug 2007 11:24:40 +0000 Subject: Can now set the plugins for standalone mode's Inventory database (default sqlite) and for its user database (default DB4o). Currently changing the user plugin to MySql should work (if you have MySql setup (should be same as for grid mode). There is also a MySql provider for the inventory but not 100% certain if that is finished and functional (will need to check with Adam on that). --- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index cea6e6e..7f52739 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -262,7 +262,7 @@ namespace OpenSim.Framework.Communications.Caches { DoCreateItem(); } - Console.WriteLine("upload complete "+ this.TransactionID); + // Console.WriteLine("upload complete "+ this.TransactionID); //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); } private void SaveAssetToFile(string filename, byte[] data) @@ -319,6 +319,11 @@ namespace OpenSim.Framework.Communications.Caches ourClient.SendInventoryItemUpdate(item); } } + + public void UpdateInventoryItem(LLUUID itemID) + { + + } } public class NoteCardCapsUpdate -- cgit v1.1 From 531f64a53bbd084dd8d0b33ae6c49821c74d718a Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 16 Aug 2007 16:31:32 +0000 Subject: Taking Prims (SceneObjectGroups) in and out of inventory should now work and if left in inventory will still be there after restarts. (as with the rest of inventory it will only fully work in standalone mode with account authentication turned on). --- .../Framework/Communications/Cache/AssetCache.cs | 69 ++++++++++++++-------- .../Communications/Cache/CachedUserInfo.cs | 16 ++++- .../Communications/Cache/InventoryFolder.cs | 20 +++++++ .../Framework/Communications/IInventoryServices.cs | 1 + 4 files changed, 79 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3866e21..c08bef2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -137,6 +137,16 @@ namespace OpenSim.Framework.Communications.Caches return asset; } + public AssetBase GetAsset(LLUUID assetID, bool isTexture) + { + AssetBase asset = GetAsset(assetID); + if (asset == null) + { + this._assetServer.RequestAsset(assetID, isTexture); + } + return asset; + } + public void AddAsset(AssetBase asset) { // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); @@ -241,44 +251,51 @@ namespace OpenSim.Framework.Communications.Caches if (IsTexture) { // Console.WriteLine("asset recieved from asset server"); + TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - if (this.RequestedTextures.ContainsKey(image.FullID)) + if (!this.Textures.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 ) / 1000; - } - else + this.Textures.Add(image.FullID, image); + if (this.RequestedTextures.ContainsKey(image.FullID)) { - req.NumPackets = 1; + 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) / 1000; + } + else + { + req.NumPackets = 1; + } + this.RequestedTextures.Remove(image.FullID); + this.TextureRequests.Add(req); } - 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)) + if (!this.Assets.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 + this.Assets.Add(assetInf.FullID, assetInf); + if (this.RequestedAssets.ContainsKey(assetInf.FullID)) { - req.NumPackets = 1; + 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); } - this.RequestedAssets.Remove(assetInf.FullID); - this.AssetRequests.Add(req); } } } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9970d80..ddb5658 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -105,13 +105,27 @@ namespace OpenSim.Framework.Communications.Caches } } - public void updateItem(LLUUID userID, InventoryItemBase itemInfo) + public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); } } + + public bool DeleteItem(LLUUID userID, InventoryItemBase item) + { + bool result = false; + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + result = RootFolder.DeleteItem(item.inventoryID); + if (result) + { + this.m_parentCommsManager.InventoryServer.DeleteInventoryItem(userID, item); + } + } + return result; + } } diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 6b0e2b4..34f83db 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -90,6 +90,26 @@ namespace OpenSim.Framework.Communications.Caches return base2; } + public bool DeleteItem(LLUUID itemID) + { + bool found = false; + if (this.Items.ContainsKey(itemID)) + { + Items.Remove(itemID); + return true; + } + foreach (InventoryFolder folder in this.SubFolders.Values) + { + found = folder.DeleteItem(itemID); + if (found == true) + { + break; + } + } + return found; + } + + public InventoryFolder HasSubFolder(LLUUID folderID) { InventoryFolder returnFolder = null; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 6f01cf2..bd58756 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -16,5 +16,6 @@ namespace OpenSim.Framework.Communications void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } } -- cgit v1.1 From c89db49f3cd3bbd60577eb5a1787ccf8dea930e3 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 19 Aug 2007 13:35:20 +0000 Subject: Sqlite datastore should now save the textures and extraparams data (used by sculpties) correctly. [Really need to add a ExtraParams field to the sqlite database though, but for now I have combined their data so that we don't lose backward compatibility, know a couple of people have been using the datastore already]. Now have a rough day/night cycle (the movement of the sun needs to be made smoother but for now it is better than we had I think). Added dalien's patch (issue 294) for saving and loading prims to a xml file (think he will be modifying these to be import/export functions and maybe writing a xml datastore for backups). Some preliminary work on task inventory (ie object's/prim's inventory). Added place holder data for AvatarProperties (ie a avatar's profile). Should we store this sort of data on the user server or have another server for it (a normal webserver should work). Added a few more method to IClientAPI. Sure there is something I'm forgeting. --- .../Communications/Cache/AssetTransactions.cs | 4 +-- .../Framework/Communications/Capabilities/Caps.cs | 40 ++++++++++++++++------ 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 7f52739..addd20a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -156,7 +156,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , ""); } return text; } @@ -373,7 +373,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" ); } return text; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 14f9c95..6afb35c 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); + public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); @@ -113,7 +113,7 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { - //Console.WriteLine("caps request " + request); + // Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); return result; } @@ -270,7 +270,7 @@ namespace OpenSim.Region.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { - // Console.WriteLine("asset upload request via CAPS"); + //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; @@ -280,7 +280,7 @@ namespace OpenSim.Region.Capabilities LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, "" , "", capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -297,13 +297,27 @@ namespace OpenSim.Region.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data) + public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType) { + sbyte assType = 0; + sbyte inType = 0; + + if (inventoryType == "sound") + { + inType = 1; + assType = 1; + } + else if (inventoryType == "animation") + { + inType = 19; + assType = 19; + } + AssetBase asset; asset = new AssetBase(); asset.FullID = assetID; - asset.Type = 0; - asset.InvType = 0; + asset.Type = assType; + asset.InvType = inType; asset.Name = assetName; asset.Data = data; this.assetCache.AddAsset(asset); @@ -315,8 +329,8 @@ namespace OpenSim.Region.Capabilities item.assetID = asset.FullID; item.inventoryDescription = assetDescription; item.inventoryName = assetName; - item.assetType = 0; - item.invType = 0; + item.assetType = assType; + item.invType = inType; item.parentFolderID = parentFolder; item.inventoryCurrentPermissions = 2147483647; item.inventoryNextPermissions = 2147483647; @@ -350,6 +364,9 @@ namespace OpenSim.Region.Capabilities private string m_assetName = ""; private string m_assetDes = ""; + private string m_invType = ""; + private string m_assetType = ""; + /// /// /// @@ -366,6 +383,9 @@ namespace OpenSim.Region.Capabilities uploaderPath = path; httpListener = httpServer; parentFolder = parentFolderID; + m_assetType = assetType; + m_invType = invType; + } /// @@ -393,7 +413,7 @@ namespace OpenSim.Region.Capabilities if (OnUpLoad != null) { - OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data); + OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } return res; -- cgit v1.1 From 252b48fb3e0905e6b21648e818aebd091e8532a8 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 21 Aug 2007 13:21:03 +0000 Subject: Can now turn on/off server side permission checking (on prim editing etc) from the opensim.ini file. Just add a line to the Startup section like : serverside_object_permissions = true Changes /editing that are made to clothing/ body parts in your inventory should now be saved between logins/ restarts. --- .../Communications/Cache/AssetTransactions.cs | 19 +++++++++++++++++++ .../Communications/Cache/LibraryRootFolder.cs | 4 ++++ .../Communications/Cache/UserProfileCache.cs | 11 ----------- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index addd20a..4cde5f6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -103,6 +103,15 @@ namespace OpenSim.Framework.Communications.Caches } } + public AssetBase GetTransactionAsset(LLUUID transactionID) + { + if (this.XferUploaders.ContainsKey(transactionID)) + { + return XferUploaders[transactionID].GetAssetData(); + } + return null; + } + // Nested Types public class AssetCapsUploader { @@ -298,6 +307,7 @@ namespace OpenSim.Framework.Communications.Caches private void DoCreateItem() { + //really need to fix this call, if lbsa71 saw this he would die. this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId); if (userInfo != null) @@ -324,6 +334,15 @@ namespace OpenSim.Framework.Communications.Caches { } + + public AssetBase GetAssetData() + { + if (m_finished) + { + return this.Asset; + } + return null; + } } public class NoteCardCapsUpdate diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 6d85477..deef028 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -9,6 +9,10 @@ using Nini.Config; namespace OpenSim.Framework.Communications.Caches { + /// + /// Basically a hack to give us a Inventory library while we don't have a inventory server + /// once the server is fully implemented then should read the data from that + /// public class LibraryRootFolder : InventoryFolder { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 02c5f65..a599a19 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -182,17 +182,6 @@ namespace OpenSim.Framework.Communications.Caches 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 folderInfo = new InventoryFolder(); - folderInfo.agentID = userID; - folderInfo.folderID = userInfo.UserProfile.rootInventoryFolderID; - folderInfo.name = "My Inventory"; - folderInfo.parentID = LLUUID.Zero; - folderInfo.type = 8; - folderInfo.version = 1; - userInfo.FolderReceive(userID, folderInfo);*/ } /// -- cgit v1.1 From 5ea6d8d739d9aaf0cbcbe3151a37d50335ac1b8b Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 22 Aug 2007 16:59:13 +0000 Subject: A little bit of cleaning up. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c08bef2..d0186e6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -327,7 +327,7 @@ namespace OpenSim.Framework.Communications.Caches //inventory asset request requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); source = 3; - Console.WriteLine("asset request " + requestID); + //Console.WriteLine("asset request " + requestID); } //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); -- cgit v1.1 From fafe70bba4f6c6b08a578dc5d9791a13ac449c72 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 25 Aug 2007 20:35:51 +0000 Subject: Second attempt to commit : Test to see if this change improves or makes worse the texture sending bug --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d0186e6..f38552f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -664,7 +664,7 @@ namespace OpenSim.Framework.Communications.Caches SendPacket(); counter++; - if ((request.PacketCounter > request.NumPackets) | (counter >120) |(request.NumPackets ==1)) + if ((request.PacketCounter > request.NumPackets) | (counter > 50) |(request.NumPackets ==1)) { return true; } -- cgit v1.1 From 291eb48fb0338d80e3baeed65664d7a72fea1892 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 26 Aug 2007 17:57:25 +0000 Subject: Another attempt to fix the image sending bug (next week, I intend to rewrite the assetcache and asset server). Attempt to fix bug # 326. (crashing when using save-xml and hollow prims) Attempt to fix bug # 328 (limit of 50 items in a folder) --- .../Framework/Communications/Cache/AssetCache.cs | 101 ++++++++++++++------- .../Cache/AssetTransactionManager.cs | 5 +- .../Communications/Cache/AssetTransactions.cs | 9 +- 3 files changed, 80 insertions(+), 35 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f38552f..c6de226 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -58,7 +58,9 @@ namespace OpenSim.Framework.Communications.Caches public Dictionary SendingTextures = new Dictionary(); private BlockingQueue QueueTextures = new BlockingQueue(); - private Dictionary> AvatarRecievedTextures = new Dictionary>(); + private Dictionary> AvatarRecievedTextures = new Dictionary>(); + + private Dictionary> TimesTextureSent = new Dictionary>(); private IAssetServer _assetServer; private Thread _assetCacheThread; @@ -139,12 +141,12 @@ namespace OpenSim.Framework.Communications.Caches public AssetBase GetAsset(LLUUID assetID, bool isTexture) { - AssetBase asset = GetAsset(assetID); - if (asset == null) - { - this._assetServer.RequestAsset(assetID, isTexture); - } - return asset; + AssetBase asset = GetAsset(assetID); + if (asset == null) + { + this._assetServer.RequestAsset(assetID, isTexture); + } + return asset; } public void AddAsset(AssetBase asset) @@ -190,7 +192,7 @@ namespace OpenSim.Framework.Communications.Caches req = (AssetRequest)this.TextureRequests[i]; if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) { - //Console.WriteLine("new texture to send"); + //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; lock (this.SendingTextures) @@ -210,15 +212,40 @@ namespace OpenSim.Framework.Communications.Caches while (true) { TextureSender sender = this.QueueTextures.Dequeue(); - bool finished = sender.SendTexture(); - if (finished) + if (TimesTextureSent.ContainsKey(sender.request.RequestUser.AgentId)) { - this.TextureSent(sender); + if (TimesTextureSent[sender.request.RequestUser.AgentId].ContainsKey(sender.request.ImageInfo.FullID)) + { + TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID]++; + } + else + { + TimesTextureSent[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID, 1); + } } else { - // Console.WriteLine("readding texture"); - this.QueueTextures.Enqueue(sender); + Dictionary UsersSent = new Dictionary(); + TimesTextureSent.Add(sender.request.RequestUser.AgentId, UsersSent ); + UsersSent.Add(sender.request.ImageInfo.FullID, 1); + + } + if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 600) + { + bool finished = sender.SendTexture(); + if (finished) + { + this.TextureSent(sender); + } + else + { + // Console.WriteLine("readding texture"); + this.QueueTextures.Enqueue(sender); + } + } + else + { + this.TextureSent(sender); } } } @@ -234,7 +261,7 @@ namespace OpenSim.Framework.Communications.Caches lock (this.SendingTextures) { this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); + // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } } @@ -247,11 +274,11 @@ namespace OpenSim.Framework.Communications.Caches //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) { - // Console.WriteLine("asset recieved from asset server"); - + //Console.WriteLine("asset recieved from asset server"); + TextureImage image = new TextureImage(asset); if (!this.Textures.ContainsKey(image.FullID)) { @@ -301,10 +328,17 @@ namespace OpenSim.Framework.Communications.Caches } } - public void AssetNotFound(AssetBase asset) + public void AssetNotFound(LLUUID assetID) { - //the asset server had no knowledge of requested asset + if (this.RequestedTextures.ContainsKey(assetID)) + { + AssetRequest req = this.RequestedTextures[assetID]; + ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); + notFound.ImageID.ID = assetID; + req.RequestUser.OutPacket(notFound); + this.RequestedTextures.Remove(assetID); + } } #region Assets @@ -499,17 +533,17 @@ namespace OpenSim.Framework.Communications.Caches /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber) { - // Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); + //Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); //check to see if texture is in local cache, if not request from asset server - if(!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { this.AvatarRecievedTextures.Add(userInfo.AgentId, new List()); } - /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) - { - //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); - return; - }*/ + /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) + { + //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); + return; + }*/ if (!this.Textures.ContainsKey(imageID)) { if (!this.RequestedTextures.ContainsKey(imageID)) @@ -536,7 +570,7 @@ namespace OpenSim.Framework.Communications.Caches if (imag.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(imag.Data.Length - 600 ) / 1000; + req.NumPackets = 1 + (int)(imag.Data.Length - 600) / 1000; //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); } else @@ -656,15 +690,15 @@ namespace OpenSim.Framework.Communications.Caches public TextureSender(AssetRequest req) { request = req; - + } public bool SendTexture() { SendPacket(); counter++; - - if ((request.PacketCounter > request.NumPackets) | (counter > 50) |(request.NumPackets ==1)) + + if ((request.PacketCounter > request.NumPackets) | (counter > 90) | (request.NumPackets == 1)) { return true; } @@ -682,6 +716,7 @@ namespace OpenSim.Framework.Communications.Caches { //only one packet so send whole file ImageDataPacket im = new ImageDataPacket(); + im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = req.ImageInfo.FullID; im.ImageID.Size = (uint)req.ImageInfo.Data.Length; @@ -697,6 +732,7 @@ namespace OpenSim.Framework.Communications.Caches { //more than one packet so split file up ImageDataPacket im = new ImageDataPacket(); + im.Header.Reliable = false; im.ImageID.Packets = (ushort)(req.NumPackets); im.ImageID.ID = req.ImageInfo.FullID; im.ImageID.Size = (uint)req.ImageInfo.Data.Length; @@ -704,7 +740,7 @@ namespace OpenSim.Framework.Communications.Caches 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: @@ -713,10 +749,11 @@ namespace OpenSim.Framework.Communications.Caches } else { - //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); + //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.Header.Reliable = false; im.ImageID.Packet = (ushort)(req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 1f5f99d..2e72a3e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -80,15 +80,16 @@ namespace OpenSim.Framework.Communications.Caches } - public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) + public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) { + // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); if (transactions != null) { AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { - uploader.Initialise(remoteClient, assetID, transaction, type, data); + uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal); } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 4cde5f6..63623a4 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -189,6 +189,7 @@ namespace OpenSim.Framework.Communications.Caches private bool m_finished = false; private bool m_createItem = false; private AgentAssetTransactions m_userTransactions; + private bool m_storeLocal; public AssetXferUploader(AgentAssetTransactions transactions) { @@ -224,7 +225,7 @@ namespace OpenSim.Framework.Communications.Caches } } - public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data) + public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) { this.ourClient = remoteClient; this.Asset = new AssetBase(); @@ -235,6 +236,7 @@ namespace OpenSim.Framework.Communications.Caches this.Asset.Name = "blank"; this.Asset.Description = "empty"; this.TransactionID = transaction; + this.m_storeLocal = storeLocal; if (this.Asset.Data.Length > 2) { this.SendCompleteMessage(); @@ -271,6 +273,11 @@ namespace OpenSim.Framework.Communications.Caches { DoCreateItem(); } + else if (m_storeLocal) + { + this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); + } + // Console.WriteLine("upload complete "+ this.TransactionID); //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); } -- cgit v1.1 From b9346844c1d56a74f405c6e518706c0e754297d8 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 26 Aug 2007 20:34:14 +0000 Subject: See if this fixes the 0x0 texture size problems, and speeds up texture downloads in general a little bit. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c6de226..4f845b5 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches UsersSent.Add(sender.request.ImageInfo.FullID, 1); } - if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 600) + if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) { bool finished = sender.SendTexture(); if (finished) @@ -336,6 +336,7 @@ namespace OpenSim.Framework.Communications.Caches ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); notFound.ImageID.ID = assetID; req.RequestUser.OutPacket(notFound); + //Console.WriteLine("sending image not found for " + assetID); this.RequestedTextures.Remove(assetID); } @@ -698,7 +699,7 @@ namespace OpenSim.Framework.Communications.Caches SendPacket(); counter++; - if ((request.PacketCounter > request.NumPackets) | (counter > 90) | (request.NumPackets == 1)) + if ((request.PacketCounter > request.NumPackets) | (counter > 100) | (request.NumPackets == 1)) { return true; } -- cgit v1.1 From 6e35ff28227432ff902a7d535b4e141e9406b966 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Mon, 27 Aug 2007 04:20:14 +0000 Subject: Tweaks to assetcache to make texture downloading better (I hope) --- .../Framework/Communications/Cache/AssetCache.cs | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4f845b5..d06582e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -534,7 +534,7 @@ namespace OpenSim.Framework.Communications.Caches /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber) { - //Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); + //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { @@ -570,8 +570,9 @@ namespace OpenSim.Framework.Communications.Caches if (imag.Data.LongLength > 600) { + //Console.WriteLine("{0}", imag.Data.LongLength); //over 600 bytes so split up file - req.NumPackets = 1 + (int)(imag.Data.Length - 600) / 1000; + req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000; //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); } else @@ -698,8 +699,7 @@ namespace OpenSim.Framework.Communications.Caches { SendPacket(); counter++; - - if ((request.PacketCounter > request.NumPackets) | (counter > 100) | (request.NumPackets == 1)) + if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1)) { return true; } @@ -709,13 +709,13 @@ namespace OpenSim.Framework.Communications.Caches public void SendPacket() { AssetRequest req = request; - // Console.WriteLine("sending " + req.ImageInfo.FullID); + //Console.WriteLine("sending " + req.ImageInfo.FullID); if (req.PacketCounter == 0) { //first time for this request so send imagedata packet if (req.NumPackets == 1) { - //only one packet so send whole file + //Console.WriteLine("only one packet so send whole file"); ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; im.ImageID.Packets = 1; @@ -727,7 +727,7 @@ namespace OpenSim.Framework.Communications.Caches req.PacketCounter++; //req.ImageInfo.l= time; //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); - // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); + //Console.WriteLine("sending single packet for " + req.ImageInfo.FullID.ToStringHyphenated()); } else { @@ -744,27 +744,28 @@ namespace OpenSim.Framework.Communications.Caches 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()); + //System.Console.WriteLine("sent first packet of texture: " + req.ImageInfo.FullID); + //Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); } } else { - //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); + //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.Header.Reliable = false; im.ImageID.Packet = (ushort)(req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); + int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter-1)); if (size > 1000) size = 1000; + //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, 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); + //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID); } } -- cgit v1.1 From 4c3be4e91f25d9d89b5adadd1eea3cf0b0d5cfec Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 27 Aug 2007 10:34:28 +0000 Subject: Another small tweak to image sending. Implemented a few ll Functions, llSetObjectName llGetObjectName, llLoadURL (all currently untested). --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d06582e..322cd6a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches UsersSent.Add(sender.request.ImageInfo.FullID, 1); } - if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) + if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1200) { bool finished = sender.SendTexture(); if (finished) @@ -699,6 +699,7 @@ namespace OpenSim.Framework.Communications.Caches { SendPacket(); counter++; + if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1)) { return true; -- cgit v1.1 From 6181191a037fd8481cff640405685d9a46ba89a3 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 27 Aug 2007 11:18:50 +0000 Subject: Stopped EntityBase from implementing IScriptHost, as don't think it should, multiple objects are based on entitybase and they all don't want the baggage from IScriptHost. SceneObjectPart already implements it anyway. Added llGetOwner function, and tested the ll functions that I added in last commit. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 322cd6a..1b3bb18 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches UsersSent.Add(sender.request.ImageInfo.FullID, 1); } - if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1200) + if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) { bool finished = sender.SendTexture(); if (finished) -- cgit v1.1 From 653a4ff22ddb80d586a19648a239f01322ef78be Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 27 Aug 2007 15:34:21 +0000 Subject: Deleted a few old files that are no longer used. Deleted the GridInterfaces projects, and for now moved the old local asset server into Framework.Communications, as we prepare to rewrite the asset cache and asset server. Deleted Framework.manager as I am sure this is no longer in use. --- .../Framework/Communications/Cache/AssetCache.cs | 6 +- .../Framework/Communications/Cache/AssetServer.cs | 392 +++++++++++++++++++++ .../Communications/Cache/UserProfileCache.cs | 2 +- 3 files changed, 396 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Framework/Communications/Cache/AssetServer.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1b3bb18..3d31ba6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Caches /// public AssetCache(IAssetServer assetServer) { - Console.WriteLine("Creating Asset cache"); + System.Console.WriteLine("Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary(); @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Caches public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) { - Console.WriteLine("Creating Asset cache"); + System.Console.WriteLine("Creating Asset cache"); _assetServer = this.LoadAssetDll(assetServerDLLName); _assetServer.SetServerInfo(assetServerURL, assetServerKey); _assetServer.SetReceiver(this); @@ -119,7 +119,7 @@ namespace OpenSim.Framework.Communications.Caches } catch (Exception e) { - Console.WriteLine(e.Message + " : " + e.StackTrace); + System.Console.WriteLine(e.Message + " : " + e.StackTrace); } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs new file mode 100644 index 0000000..fd203f7 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -0,0 +1,392 @@ +/* +* 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.IO; +using System.Threading; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class LocalAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private IObjectContainer db; + private Thread _localAssetServerThread; + + public LocalAssetServer() + { + bool yapfile; + this._assetRequests = new BlockingQueue(); + yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); + + MainLog.Instance.Verbose("Local Asset Server class created"); + db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); + MainLog.Instance.Verbose("Db4 Asset database creation"); + + if (!yapfile) + { + this.SetUpAssetDatabase(); + } + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void RequestAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void UploadNewAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + if (db != null) + { + MainLog.Instance.Verbose("Closing local asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + this.LoadAsset(newAsset, false, fileName); + AssetStorage store = new AssetStorage(); + store.Data = newAsset.Data; + store.Name = newAsset.Name; + store.UUID = newAsset.FullID; + db.Set(store); + db.Commit(); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } + +} + diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index a599a19..07d7cf4 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications.Caches } else { - Console.WriteLine("CACHE", "User profile for user not found"); + System.Console.WriteLine("CACHE", "User profile for user not found"); } } } -- cgit v1.1 From 2ccc8e1e9886286f02c981ff47b3dac62314902f Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 28 Aug 2007 20:07:59 +0000 Subject: Fixed the problem of uploaded animations not showing up in inventory [Mantis number 338]. They should now show up in inventory and play locally should work. But Play in world doesn't seem to work yet. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6afb35c..1a63b98 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -310,7 +310,7 @@ namespace OpenSim.Region.Capabilities else if (inventoryType == "animation") { inType = 19; - assType = 19; + assType = 20; } AssetBase asset; -- cgit v1.1 From e1505be97fbf71ac91e0747b7604c1bc7e54e1ed Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 30 Aug 2007 13:47:04 +0000 Subject: Added some place holder classes for various modules. Some work on the asset cache, can people please test this. including on one of the public systems so we can see if it causes problems with multiple users. --- .../Framework/Communications/Cache/AssetCache.cs | 75 +++++++++++----------- .../Framework/Communications/Capabilities/Caps.cs | 1 + 2 files changed, 40 insertions(+), 36 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3d31ba6..3f594af 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -212,41 +212,41 @@ namespace OpenSim.Framework.Communications.Caches while (true) { TextureSender sender = this.QueueTextures.Dequeue(); - if (TimesTextureSent.ContainsKey(sender.request.RequestUser.AgentId)) - { - if (TimesTextureSent[sender.request.RequestUser.AgentId].ContainsKey(sender.request.ImageInfo.FullID)) - { - TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID]++; - } - else - { - TimesTextureSent[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID, 1); - } - } - else - { - Dictionary UsersSent = new Dictionary(); - TimesTextureSent.Add(sender.request.RequestUser.AgentId, UsersSent ); - UsersSent.Add(sender.request.ImageInfo.FullID, 1); + /* if (TimesTextureSent.ContainsKey(sender.request.RequestUser.AgentId)) + { + if (TimesTextureSent[sender.request.RequestUser.AgentId].ContainsKey(sender.request.ImageInfo.FullID)) + { + TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID]++; + } + else + { + TimesTextureSent[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID, 1); + } + } + else + { + Dictionary UsersSent = new Dictionary(); + TimesTextureSent.Add(sender.request.RequestUser.AgentId, UsersSent ); + UsersSent.Add(sender.request.ImageInfo.FullID, 1); - } - if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) + } + if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) + {*/ + bool finished = sender.SendTexture(); + if (finished) { - bool finished = sender.SendTexture(); - if (finished) - { - this.TextureSent(sender); - } - else - { - // Console.WriteLine("readding texture"); - this.QueueTextures.Enqueue(sender); - } + this.TextureSent(sender); } else { - this.TextureSent(sender); + // Console.WriteLine("readding texture"); + this.QueueTextures.Enqueue(sender); } + /* } + else + { + this.TextureSent(sender); + }*/ } } @@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Caches ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); notFound.ImageID.ID = assetID; req.RequestUser.OutPacket(notFound); - //Console.WriteLine("sending image not found for " + assetID); + //Console.WriteLine("sending image not found for " + assetID); this.RequestedTextures.Remove(assetID); } @@ -532,9 +532,9 @@ namespace OpenSim.Framework.Communications.Caches /// /// /// - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber) + public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) { - //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); + //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { @@ -554,6 +554,7 @@ namespace OpenSim.Framework.Communications.Caches request.RequestUser = userInfo; request.RequestAssetID = imageID; request.IsTextureRequest = true; + request.DiscardLevel = discard; this.RequestedTextures.Add(imageID, request); this._assetServer.RequestAsset(imageID, true); } @@ -567,6 +568,7 @@ namespace OpenSim.Framework.Communications.Caches req.RequestAssetID = imageID; req.IsTextureRequest = true; req.ImageInfo = imag; + req.DiscardLevel = discard; if (imag.Data.LongLength > 600) { @@ -641,6 +643,7 @@ namespace OpenSim.Framework.Communications.Caches public byte[] Params = null; //public bool AssetInCache; //public int TimeRequested; + public int DiscardLevel = -1; public AssetRequest() { @@ -700,7 +703,7 @@ namespace OpenSim.Framework.Communications.Caches SendPacket(); counter++; - if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1)) + if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | (request.DiscardLevel == -1)) { return true; } @@ -746,7 +749,7 @@ namespace OpenSim.Framework.Communications.Caches req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent first packet of texture: " + req.ImageInfo.FullID); - //Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); + //Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); } } else @@ -758,11 +761,11 @@ namespace OpenSim.Framework.Communications.Caches im.Header.Reliable = false; im.ImageID.Packet = (ushort)(req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter-1)); + int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); if (size > 1000) size = 1000; //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter-1)), im.ImageData.Data, 0, 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; diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 1a63b98..ba5503e 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -127,6 +127,7 @@ namespace OpenSim.Region.Capabilities LLSDCapsDetails caps = new LLSDCapsDetails(); string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; + // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; -- cgit v1.1 From bfd36e2e836f92539e68bba077104d5016c5bf8b Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 4 Sep 2007 13:43:56 +0000 Subject: Some work on Module loading/management. Some more modules templates classes (hoping that someone will pick some of these and work on implementing them). Early version of the "Dynamic Texture Module", although currently there are no render modules included (so not really functional without them). Added osSetDynamicTextureURL script function, for attaching a dynamic texture to a prim. Some work on the console command handling. Added "change-region " and "exit-region" so that after the use of change-region, the commands entered will apply to that region only. Then use exit-region to return to the top level (so commands then function as they did before and either apply to all regions or to the first region) (Note: this hasn't been tested very much) --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3f594af..d947228 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -151,7 +151,7 @@ namespace OpenSim.Framework.Communications.Caches public void AddAsset(AssetBase asset) { - // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); if (asset.Type == 0) { //Console.WriteLine("which is a texture"); @@ -161,6 +161,11 @@ namespace OpenSim.Framework.Communications.Caches this.Textures.Add(textur.FullID, textur); this._assetServer.UploadNewAsset(asset); } + else + { + TextureImage textur = new TextureImage(asset); + this.Textures[asset.FullID] = textur; + } } else { -- cgit v1.1 From 15423539f98d47201a819e35f80b0c30ee459556 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 10 Sep 2007 06:45:54 +0000 Subject: hooked up sdague new sqlite asset database provider to the old asset system. So we can still use sqlite for assets while we wait for the rest of the new asset system to be wrote. Needs more testing, so if it causes problems will have to swap back to db4o. --- .../Framework/Communications/Cache/AssetCache.cs | 12 +- .../Framework/Communications/Cache/AssetServer.cs | 4 +- .../Communications/Cache/SQLAssetServer.cs | 297 +++++++++++++++++++++ 3 files changed, 305 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Framework/Communications/Cache/SQLAssetServer.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d947228..2dceb54 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -144,14 +144,14 @@ namespace OpenSim.Framework.Communications.Caches AssetBase asset = GetAsset(assetID); if (asset == null) { - this._assetServer.RequestAsset(assetID, isTexture); + this._assetServer.FetchAsset(assetID, isTexture); } return asset; } public void AddAsset(AssetBase asset) { - System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + // System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); if (asset.Type == 0) { //Console.WriteLine("which is a texture"); @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Caches { //texture TextureImage textur = new TextureImage(asset); this.Textures.Add(textur.FullID, textur); - this._assetServer.UploadNewAsset(asset); + this._assetServer.CreateAsset(asset); } else { @@ -173,7 +173,7 @@ namespace OpenSim.Framework.Communications.Caches { AssetInfo assetInf = new AssetInfo(asset); this.Assets.Add(assetInf.FullID, assetInf); - this._assetServer.UploadNewAsset(asset); + this._assetServer.CreateAsset(asset); } } } @@ -384,7 +384,7 @@ namespace OpenSim.Framework.Communications.Caches request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; this.RequestedAssets.Add(requestID, request); - this._assetServer.RequestAsset(requestID, false); + this._assetServer.FetchAsset(requestID, false); } return; } @@ -561,7 +561,7 @@ namespace OpenSim.Framework.Communications.Caches request.IsTextureRequest = true; request.DiscardLevel = discard; this.RequestedTextures.Add(imageID, request); - this._assetServer.RequestAsset(imageID, true); + this._assetServer.FetchAsset(imageID, true); } return; } diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index fd203f7..4e2644c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework.Communications.Caches this._receiver = receiver; } - public void RequestAsset(LLUUID assetID, bool isTexture) + public void FetchAsset(LLUUID assetID, bool isTexture) { ARequest req = new ARequest(); req.AssetID = assetID; @@ -86,7 +86,7 @@ namespace OpenSim.Framework.Communications.Caches } - public void UploadNewAsset(AssetBase asset) + public void CreateAsset(AssetBase asset) { AssetStorage store = new AssetStorage(); store.Data = asset.Data; diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs new file mode 100644 index 0000000..50653d8 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -0,0 +1,297 @@ +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class SQLAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private Thread _localAssetServerThread; + protected IAssetProvider m_plugin; + + + public SQLAssetServer() + { + _assetRequests = new BlockingQueue(); + AddPlugin("OpenSim.Framework.Data.SQLite.dll"); + this.SetUpAssetDatabase(); + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void AddPlugin(string FileName) + { + //MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + + if (typeInterface != null) + { + IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + m_plugin = plug; + m_plugin.Initialise("AssetStorage.db", ""); + + //MainLog.Instance.Verbose("AssetStorage: Added IAssetProvider Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); + } + + public void CreateAsset(AssetBase asset) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + m_plugin.CommitAssets(); + } + + private void RunRequests() + { + + while (true) + { + ARequest req = this._assetRequests.Dequeue(); + + m_plugin.FetchAsset(req.AssetID); + + AssetBase asset = m_plugin.FetchAsset(req.AssetID); + if (asset != null) + { + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + m_plugin.CreateAsset(Image); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + + m_plugin.CommitAssets(); + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + this.LoadAsset(newAsset, false, fileName); + m_plugin.CreateAsset(newAsset); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + +} -- cgit v1.1 From 22dbe82b26effea0c021a6eb9bffd58d58781c3f Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 10 Sep 2007 07:48:22 +0000 Subject: A couple of fixes to make sure db4o gets set as the default asset database. Also added a couple of console output lines to try to make it easier to tell which asset storage system is in use. --- OpenSim/Framework/Communications/Cache/AssetServer.cs | 1 + OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 4e2644c..7412190 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -49,6 +49,7 @@ namespace OpenSim.Framework.Communications.Caches public LocalAssetServer() { + System.Console.WriteLine("Starting Db4o asset storage system"); bool yapfile; this._assetRequests = new BlockingQueue(); yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 50653d8..ac22573 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -49,6 +49,7 @@ namespace OpenSim.Framework.Communications.Caches public SQLAssetServer() { + System.Console.WriteLine("Starting sqlite asset storage system"); _assetRequests = new BlockingQueue(); AddPlugin("OpenSim.Framework.Data.SQLite.dll"); this.SetUpAssetDatabase(); -- cgit v1.1 From ffe9c9374a9b220b2046940a4dec7eb47e5c958b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 10 Sep 2007 08:14:38 +0000 Subject: mass update of urls in source code to new website --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- OpenSim/Framework/Communications/Cache/AssetServer.cs | 2 +- OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs | 2 +- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 2 +- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/Cache/InventoryFolder.cs | 2 +- OpenSim/Framework/Communications/Cache/UserProfileCache.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDArray.cs | 2 +- .../Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDTest.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDType.cs | 2 +- OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- OpenSim/Framework/Communications/IGridServices.cs | 2 +- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- OpenSim/Framework/Communications/IUserServices.cs | 2 +- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2dceb54..8a16f03 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 7412190..8c63b30 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 2e72a3e..42c0a8e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 63623a4..59a9e00 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ddb5658..acdb6db 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 34f83db..885cffc 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 07d7cf4..0c8c0f9 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index ba5503e..f9c8b47 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index d3e1979..2af5a4a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index db9836c..e65e741 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index 2c2689b..d1894d4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index ca27c9d..0169d3c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index efeb9b1..8a2215f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index e0c006c..6d17bff 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 8b9837b..7900290 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index 78ccf67..f70fa11 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 04f4d9a..6af7f39 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 7676597..6d73af8 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 1cfe2b6..d538e23 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index d82fa19..4853c3a 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index 40a3182..c1bea48 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 79f3e30..43fce84 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) Contributors, http://www.openmetaverse.org/ +* Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without -- cgit v1.1 From a1be7f4be50a645be22eb7d80679530906e8aeba Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 10 Sep 2007 13:34:20 +0000 Subject: added some debugging for tracing where asset code isn't working with sqlite --- .../Communications/Cache/SQLAssetServer.cs | 597 +++++++++++---------- 1 file changed, 299 insertions(+), 298 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index ac22573..fc4efc5 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -1,298 +1,299 @@ -/* -* 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.IO; -using System.Threading; -using System.Reflection; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class SQLAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; - - - public SQLAssetServer() - { - System.Console.WriteLine("Starting sqlite asset storage system"); - _assetRequests = new BlockingQueue(); - AddPlugin("OpenSim.Framework.Data.SQLite.dll"); - this.SetUpAssetDatabase(); - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - - } - - public void AddPlugin(string FileName) - { - //MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); - - if (typeInterface != null) - { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_plugin = plug; - m_plugin.Initialise("AssetStorage.db", ""); - - //MainLog.Instance.Verbose("AssetStorage: Added IAssetProvider Interface"); - } - - typeInterface = null; - } - } - - pluginAssembly = null; - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); - } - - public void CreateAsset(AssetBase asset) - { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() - { - m_plugin.CommitAssets(); - } - - private void RunRequests() - { - - while (true) - { - ARequest req = this._assetRequests.Dequeue(); - - m_plugin.FetchAsset(req.AssetID); - - AssetBase asset = m_plugin.FetchAsset(req.AssetID); - if (asset != null) - { - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - private void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - m_plugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - m_plugin.CreateAsset(Image); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - - m_plugin.CommitAssets(); - } - - protected void ReadAssetDetails(IConfigSource source) - { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - this.LoadAsset(newAsset, false, fileName); - m_plugin.CreateAsset(newAsset); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - } - -} +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class SQLAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private Thread _localAssetServerThread; + protected IAssetProvider m_plugin; + + + public SQLAssetServer() + { + System.Console.WriteLine("Starting sqlite asset storage system"); + _assetRequests = new BlockingQueue(); + AddPlugin("OpenSim.Framework.Data.SQLite.dll"); + this.SetUpAssetDatabase(); + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void AddPlugin(string FileName) + { + //MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + + if (typeInterface != null) + { + IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + m_plugin = plug; + m_plugin.Initialise("AssetStorage.db", ""); + + //MainLog.Instance.Verbose("AssetStorage: Added IAssetProvider Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); + } + + public void CreateAsset(AssetBase asset) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + m_plugin.CommitAssets(); + } + + private void RunRequests() + { + + while (true) + { + ARequest req = this._assetRequests.Dequeue(); + + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = m_plugin.FetchAsset(req.AssetID); + if (asset != null) + { + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + m_plugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + m_plugin.CreateAsset(Image); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + + m_plugin.CommitAssets(); + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); + this.LoadAsset(newAsset, false, fileName); + m_plugin.CreateAsset(newAsset); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + +} -- cgit v1.1 From 0770a5de0a53c9b539891e6a993724628668a489 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 11 Sep 2007 04:54:55 +0000 Subject: Trying some locks on asset database access. --- .../Communications/Cache/SQLAssetServer.cs | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index fc4efc5..a965ee0 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,7 +44,8 @@ namespace OpenSim.Framework.Communications.Caches private IAssetReceiver _receiver; private BlockingQueue _assetRequests; private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; + protected IAssetProvider m_plugin; + private object syncLock = new object(); public SQLAssetServer() @@ -101,15 +102,21 @@ namespace OpenSim.Framework.Communications.Caches } public void UpdateAsset(AssetBase asset) - { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); + } } public void CreateAsset(AssetBase asset) - { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); + } } public void SetServerInfo(string ServerUrl, string ServerKey) @@ -128,9 +135,13 @@ namespace OpenSim.Framework.Communications.Caches { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = m_plugin.FetchAsset(req.AssetID); + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_plugin.FetchAsset(req.AssetID); + } if (asset != null) { _receiver.AssetReceived(asset, req.IsTexture); -- cgit v1.1 From a1e2fea7c1fc612da088914aab7a462c212bc97d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 11 Sep 2007 08:25:32 +0000 Subject: move the locks closer to the data, sqlite for assets now works like a champ --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 8a16f03..2f4c006 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -200,10 +200,7 @@ namespace OpenSim.Framework.Communications.Caches //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; - lock (this.SendingTextures) - { - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - } + this.SendingTextures.Add(req.ImageInfo.FullID, sender); this.QueueTextures.Enqueue(sender); } @@ -263,11 +260,8 @@ namespace OpenSim.Framework.Communications.Caches { if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { - lock (this.SendingTextures) - { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); - } + this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } -- cgit v1.1 From 4a07800f14698ea089d5b681ed527667a79626b1 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 15 Sep 2007 10:39:17 +0000 Subject: Testing to see if this fixes the editing appearance crash, or makes it (or anything else) worse. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2f4c006..ce7d224 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -178,6 +178,13 @@ namespace OpenSim.Framework.Communications.Caches } } + public void DeleteAsset(LLUUID assetID) + { + this._assetServer.DeleteAsset(assetID); + + //Todo should delete it from memory too + } + /// /// /// @@ -329,6 +336,7 @@ namespace OpenSim.Framework.Communications.Caches public void AssetNotFound(LLUUID assetID) { + /* if (this.RequestedTextures.ContainsKey(assetID)) { AssetRequest req = this.RequestedTextures[assetID]; @@ -338,7 +346,7 @@ namespace OpenSim.Framework.Communications.Caches //Console.WriteLine("sending image not found for " + assetID); this.RequestedTextures.Remove(assetID); - } + }*/ } #region Assets -- cgit v1.1 From 12378312d5f43f349c55682ca923edc8cf8e46ed Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 15 Sep 2007 10:53:46 +0000 Subject: Hopefully fixed the build error that I introduced with my last commit. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index ce7d224..0fadb85 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -180,7 +180,7 @@ namespace OpenSim.Framework.Communications.Caches public void DeleteAsset(LLUUID assetID) { - this._assetServer.DeleteAsset(assetID); + // this._assetServer.DeleteAsset(assetID); //Todo should delete it from memory too } -- cgit v1.1 From b8d9737a47696952bedec33dface8f18df47341f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 17 Sep 2007 12:52:03 +0000 Subject: fixing me some line endings --- .../Framework/Communications/Cache/AssetServer.cs | 786 ++++++++++----------- .../Communications/Cache/SQLAssetServer.cs | 34 +- .../Communications/Capabilities/LLSDItemUpdate.cs | 34 +- 3 files changed, 427 insertions(+), 427 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 8c63b30..e5329ec 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,393 +1,393 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.IO; -using System.Threading; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class LocalAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private IObjectContainer db; - private Thread _localAssetServerThread; - - public LocalAssetServer() - { - System.Console.WriteLine("Starting Db4o asset storage system"); - bool yapfile; - this._assetRequests = new BlockingQueue(); - yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); - - MainLog.Instance.Verbose("Local Asset Server class created"); - db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); - - if (!yapfile) - { - this.SetUpAssetDatabase(); - } - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - - } - - public void CreateAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - db.Commit(); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() - { - if (db != null) - { - MainLog.Instance.Verbose("Closing local asset server database"); - db.Close(); - } - } - - private void RunRequests() - { - while (true) - { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage)result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - private void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - AssetStorage store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - } - - protected void ReadAssetDetails(IConfigSource source) - { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - this.LoadAsset(newAsset, false, fileName); - AssetStorage store = new AssetStorage(); - store.Data = newAsset.Data; - store.Name = newAsset.Name; - store.UUID = newAsset.FullID; - db.Set(store); - db.Commit(); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - } - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; - - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } - } - -} - +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.IO; +using System.Threading; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class LocalAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private IObjectContainer db; + private Thread _localAssetServerThread; + + public LocalAssetServer() + { + System.Console.WriteLine("Starting Db4o asset storage system"); + bool yapfile; + this._assetRequests = new BlockingQueue(); + yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); + + MainLog.Instance.Verbose("Local Asset Server class created"); + db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); + MainLog.Instance.Verbose("Db4 Asset database creation"); + + if (!yapfile) + { + this.SetUpAssetDatabase(); + } + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + + } + + public void CreateAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + if (db != null) + { + MainLog.Instance.Verbose("Closing local asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + this.LoadAsset(newAsset, false, fileName); + AssetStorage store = new AssetStorage(); + store.Data = newAsset.Data; + store.Name = newAsset.Name; + store.UUID = newAsset.FullID; + db.Set(store); + db.Commit(); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } + +} + diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index a965ee0..a64d195 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Caches private IAssetReceiver _receiver; private BlockingQueue _assetRequests; private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; + protected IAssetProvider m_plugin; private object syncLock = new object(); @@ -102,20 +102,20 @@ namespace OpenSim.Framework.Communications.Caches } public void UpdateAsset(AssetBase asset) - { - lock (syncLock) - { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); } } public void CreateAsset(AssetBase asset) - { - lock (syncLock) - { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); } } @@ -135,12 +135,12 @@ namespace OpenSim.Framework.Communications.Caches { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = null; - lock (syncLock) - { - asset = m_plugin.FetchAsset(req.AssetID); + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_plugin.FetchAsset(req.AssetID); } if (asset != null) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index d47bb07..19220ac 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - [LLSDMap] - public class LLSDItemUpdate - { - public LLUUID item_id; - - public LLSDItemUpdate() - { - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDItemUpdate + { + public LLUUID item_id; + + public LLSDItemUpdate() + { + } + } +} -- cgit v1.1 From 40468f18a493d6bad5b512b1cb13c1091ab7f17f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 05:15:13 +0000 Subject: * Encapsulated all CommunicationsManager services --- .../Framework/Communications/Cache/AssetCache.cs | 9 ++- .../Framework/Communications/Capabilities/Caps.cs | 2 +- .../Communications/CommunicationsManager.cs | 78 +++++++++++++++++----- 3 files changed, 68 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0fadb85..4ae8595 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -37,7 +37,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public delegate void DownloadComplete(AssetCache.TextureSender sender); @@ -180,7 +180,7 @@ namespace OpenSim.Framework.Communications.Caches public void DeleteAsset(LLUUID assetID) { - // this._assetServer.DeleteAsset(assetID); + // this._assetServer.DeleteAsset(assetID); //Todo should delete it from memory too } @@ -268,7 +268,7 @@ namespace OpenSim.Framework.Communications.Caches if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); + // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } @@ -791,5 +791,4 @@ namespace OpenSim.Framework.Communications.Caches } } } -} - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f9c8b47..59c6d7c 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -31,10 +31,10 @@ using System.Collections.Generic; using System.Text; using System.IO; using libsecondlife; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6d73af8..d6a577f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,6 +28,7 @@ using System.Text; using libsecondlife; using libsecondlife.Packets; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; @@ -40,33 +41,80 @@ namespace OpenSim.Framework.Communications public class CommunicationsManager { - public IUserServices UserServer; - public IGridServices GridServer; - public IInventoryServices InventoryServer; - public IInterRegionCommunications InterRegion; - public UserProfileCache UserProfiles; - public AssetTransactionManager TransactionsManager; - public AssetCache AssetCache; - - public NetworkServersInfo ServersInfo; public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) { - ServersInfo = serversInfo; - this.AssetCache = assetCache; - UserProfiles = new UserProfileCache(this); - TransactionsManager = new AssetTransactionManager(this); + this.serversInfo = serversInfo; + this.m_assetCache = assetCache; + m_userProfiles = new UserProfileCache(this); + m_transactionsManager = new AssetTransactionManager(this); + } + + private IUserServices m_userServer; + public IUserServices UserServer + { + get { return m_userServer; } + set { m_userServer = value; } + } + + private IGridServices m_gridServer; + public IGridServices GridServer + { + get { return m_gridServer; } + set { m_gridServer = value; } + } + + private IInventoryServices m_inventoryServer; + public IInventoryServices InventoryServer + { + get { return m_inventoryServer; } + set { m_inventoryServer = value; } + } + + private IInterRegionCommunications m_interRegion; + public IInterRegionCommunications InterRegion + { + get { return m_interRegion; } + set { m_interRegion = value; } + } + + private UserProfileCache m_userProfiles; + public UserProfileCache UserProfiles + { + get { return m_userProfiles; } + set { m_userProfiles = value; } + } + + private AssetTransactionManager m_transactionsManager; + public AssetTransactionManager TransactionsManager + { + get { return m_transactionsManager; } + set { m_transactionsManager = value; } + } + + private AssetCache m_assetCache; + public AssetCache AssetCache + { + get { return m_assetCache; } + set { m_assetCache = value; } + } + + private NetworkServersInfo serversInfo; + public NetworkServersInfo ServersInfo + { + get { return serversInfo; } + set { serversInfo = value; } } #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == UserProfiles.libraryRoot.agentID) + if (uuid == m_userProfiles.libraryRoot.agentID) { remote_client.SendNameReply(uuid , "Mr" , "OpenSim"); } else { - UserProfileData profileData = this.UserServer.GetUserProfile(uuid); + UserProfileData profileData = this.m_userServer.GetUserProfile(uuid); if (profileData != null) { LLUUID profileId = profileData.UUID; -- cgit v1.1 From 6c41efa4e3124b1814defc93201ede75af5d8824 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 05:20:23 +0000 Subject: * reorder and rename --- .../Communications/CommunicationsManager.cs | 42 +++++++++++----------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d6a577f..e5abb2e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,96 +25,94 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Text; using libsecondlife; -using libsecondlife.Packets; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; using OpenSim.Framework.Servers; -using OpenSim.Framework.Communications.Caches; - +using OpenSim.Framework.Types; namespace OpenSim.Framework.Communications { - public class CommunicationsManager { + private AssetCache m_assetCache; + private IGridServices m_gridServer; + private IInterRegionCommunications m_interRegion; + private IInventoryServices m_inventoryServer; + private AssetTransactionManager m_transactionsManager; + private UserProfileCache m_userProfiles; + private IUserServices m_userServer; + private NetworkServersInfo m_networkServersInfo; + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) { - this.serversInfo = serversInfo; - this.m_assetCache = assetCache; + this.m_networkServersInfo = serversInfo; + m_assetCache = assetCache; m_userProfiles = new UserProfileCache(this); m_transactionsManager = new AssetTransactionManager(this); } - private IUserServices m_userServer; public IUserServices UserServer { get { return m_userServer; } set { m_userServer = value; } } - private IGridServices m_gridServer; public IGridServices GridServer { get { return m_gridServer; } set { m_gridServer = value; } } - private IInventoryServices m_inventoryServer; public IInventoryServices InventoryServer { get { return m_inventoryServer; } set { m_inventoryServer = value; } } - private IInterRegionCommunications m_interRegion; public IInterRegionCommunications InterRegion { get { return m_interRegion; } set { m_interRegion = value; } } - private UserProfileCache m_userProfiles; public UserProfileCache UserProfiles { get { return m_userProfiles; } set { m_userProfiles = value; } } - private AssetTransactionManager m_transactionsManager; public AssetTransactionManager TransactionsManager { get { return m_transactionsManager; } set { m_transactionsManager = value; } } - private AssetCache m_assetCache; public AssetCache AssetCache { get { return m_assetCache; } set { m_assetCache = value; } } - private NetworkServersInfo serversInfo; - public NetworkServersInfo ServersInfo + public NetworkServersInfo NetworkServersInfo { - get { return serversInfo; } - set { serversInfo = value; } + get { return m_networkServersInfo; } + set { m_networkServersInfo = value; } } #region Packet Handlers + public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { if (uuid == m_userProfiles.libraryRoot.agentID) { - remote_client.SendNameReply(uuid , "Mr" , "OpenSim"); + remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } else { - UserProfileData profileData = this.m_userServer.GetUserProfile(uuid); + UserProfileData profileData = m_userServer.GetUserProfile(uuid); if (profileData != null) { LLUUID profileId = profileData.UUID; @@ -128,4 +126,4 @@ namespace OpenSim.Framework.Communications #endregion } -} +} \ No newline at end of file -- cgit v1.1 From 9ccab46ae8e65412d898603426de6584629ad05f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 05:30:03 +0000 Subject: * Trying to streamline CommunicationsManager --- .../Framework/Communications/CommunicationsManager.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e5abb2e..2a87306 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -37,18 +37,18 @@ namespace OpenSim.Framework.Communications { public class CommunicationsManager { - private AssetCache m_assetCache; - private IGridServices m_gridServer; - private IInterRegionCommunications m_interRegion; - private IInventoryServices m_inventoryServer; - private AssetTransactionManager m_transactionsManager; - private UserProfileCache m_userProfiles; - private IUserServices m_userServer; - private NetworkServersInfo m_networkServersInfo; + protected AssetCache m_assetCache; + protected IGridServices m_gridServer; + protected IInterRegionCommunications m_interRegion; + protected IInventoryServices m_inventoryServer; + protected AssetTransactionManager m_transactionsManager; + protected UserProfileCache m_userProfiles; + protected IUserServices m_userServer; + protected NetworkServersInfo m_networkServersInfo; public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) { - this.m_networkServersInfo = serversInfo; + m_networkServersInfo = serversInfo; m_assetCache = assetCache; m_userProfiles = new UserProfileCache(this); m_transactionsManager = new AssetTransactionManager(this); @@ -63,7 +63,6 @@ namespace OpenSim.Framework.Communications public IGridServices GridServer { get { return m_gridServer; } - set { m_gridServer = value; } } public IInventoryServices InventoryServer -- cgit v1.1 From 1302ef44e3c632159378bc4042c753bcf36e9c63 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 07:30:30 +0000 Subject: * Started major restructusing of comms to prepare for better grid and region functionality * Working towards one shared set of services * Killed off two projects with very little functionality --- OpenSim/Framework/Communications/CAPSService.cs | 38 ++ .../Communications/Cache/AssetTransactions.cs | 2 +- .../Communications/Cache/CachedUserInfo.cs | 6 +- .../Communications/Cache/UserProfileCache.cs | 6 +- .../Communications/CommunicationsManager.cs | 61 +- .../Framework/Communications/IInventoryServices.cs | 8 + OpenSim/Framework/Communications/IUserServices.cs | 5 + .../Communications/InventoryServiceBase.cs | 211 +++++++ OpenSim/Framework/Communications/LoginResponse.cs | 667 +++++++++++++++++++++ OpenSim/Framework/Communications/LoginService.cs | 287 +++++++++ .../Framework/Communications/UserManagerBase.cs | 379 ++++++++++++ 11 files changed, 1629 insertions(+), 41 deletions(-) create mode 100644 OpenSim/Framework/Communications/CAPSService.cs create mode 100644 OpenSim/Framework/Communications/InventoryServiceBase.cs create mode 100644 OpenSim/Framework/Communications/LoginResponse.cs create mode 100644 OpenSim/Framework/Communications/LoginService.cs create mode 100644 OpenSim/Framework/Communications/UserManagerBase.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs new file mode 100644 index 0000000..a8eac26 --- /dev/null +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.UserManagement +{ + public class CAPSService + { + private BaseHttpServer m_server; + + public CAPSService(BaseHttpServer httpServer) + { + m_server = httpServer; + this.AddCapsSeedHandler("/CapsSeed/", CapsRequest); + } + + private void AddCapsSeedHandler(string path, RestMethod restMethod) + { + m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); + } + + public string CapsRequest(string request, string path, string param) + { + System.Console.WriteLine("new caps request " + request +" from path "+ path); + return ""; + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 59a9e00..d0507d0 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -316,7 +316,7 @@ namespace OpenSim.Framework.Communications.Caches { //really need to fix this call, if lbsa71 saw this he would die. this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); - CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId); + CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index acdb6db..99dc45a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Communications.Caches if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { this.ItemReceive(userID, itemInfo); - this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); + this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } @@ -109,7 +109,7 @@ namespace OpenSim.Framework.Communications.Caches { if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { - this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); + this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } @@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Caches result = RootFolder.DeleteItem(item.inventoryID); if (result) { - this.m_parentCommsManager.InventoryServer.DeleteInventoryItem(userID, item); + this.m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); } } return result; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 0c8c0f9..390b938 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -106,7 +106,7 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); if (createdFolder != null) { - this.m_parent.InventoryServer.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); } } else @@ -181,7 +181,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -190,7 +190,7 @@ namespace OpenSim.Framework.Communications.Caches /// private UserProfileData RequestUserProfileForUser(LLUUID userID) { - return this.m_parent.UserServer.GetUserProfile(userID); + return this.m_parent.UserService.GetUserProfile(userID); } /// diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2a87306..6ea3c29 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -37,81 +37,74 @@ namespace OpenSim.Framework.Communications { public class CommunicationsManager { - protected AssetCache m_assetCache; - protected IGridServices m_gridServer; - protected IInterRegionCommunications m_interRegion; - protected IInventoryServices m_inventoryServer; - protected AssetTransactionManager m_transactionsManager; - protected UserProfileCache m_userProfiles; - protected IUserServices m_userServer; - protected NetworkServersInfo m_networkServersInfo; - - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) - { - m_networkServersInfo = serversInfo; - m_assetCache = assetCache; - m_userProfiles = new UserProfileCache(this); - m_transactionsManager = new AssetTransactionManager(this); - } - - public IUserServices UserServer + protected IUserServices m_userService; + public IUserServices UserService { - get { return m_userServer; } - set { m_userServer = value; } + get { return m_userService; } } - public IGridServices GridServer + protected IGridServices m_gridService; + public IGridServices GridService { - get { return m_gridServer; } + get { return m_gridService; } } - public IInventoryServices InventoryServer + protected IInventoryServices m_inventoryService; + public IInventoryServices InventoryService { - get { return m_inventoryServer; } - set { m_inventoryServer = value; } + get { return m_inventoryService; } } + protected IInterRegionCommunications m_interRegion; public IInterRegionCommunications InterRegion { get { return m_interRegion; } - set { m_interRegion = value; } } - public UserProfileCache UserProfiles + protected UserProfileCache m_userProfileCache; + public UserProfileCache UserProfileCache { - get { return m_userProfiles; } - set { m_userProfiles = value; } + get { return m_userProfileCache; } } + protected AssetTransactionManager m_transactionsManager; public AssetTransactionManager TransactionsManager { get { return m_transactionsManager; } - set { m_transactionsManager = value; } } + protected AssetCache m_assetCache; public AssetCache AssetCache { get { return m_assetCache; } - set { m_assetCache = value; } } + protected NetworkServersInfo m_networkServersInfo; public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } - set { m_networkServersInfo = value; } } + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) + { + m_networkServersInfo = serversInfo; + m_assetCache = assetCache; + m_userProfileCache = new UserProfileCache(this); + m_transactionsManager = new AssetTransactionManager(this); + } + + #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfiles.libraryRoot.agentID) + if (uuid == m_userProfileCache.libraryRoot.agentID) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } else { - UserProfileData profileData = m_userServer.GetUserProfile(uuid); + UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) { LLUUID profileId = profileData.UUID; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index bd58756..80c2e64 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -17,5 +17,13 @@ namespace OpenSim.Framework.Communications void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + void CreateNewUserInventory(LLUUID user); + + /// + /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) + /// + /// + /// + List RequestFirstLevelFolders(LLUUID userID); } } diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index c1bea48..13dd378 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -40,5 +40,10 @@ namespace OpenSim.Framework.Communications UserProfileData SetupMasterUser(string firstName, string lastName); UserProfileData SetupMasterUser(string firstName, string lastName, string password); + /// + /// + /// + /// + void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs new file mode 100644 index 0000000..da7a0ce --- /dev/null +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; + +namespace OpenSim.Framework.Communications +{ + public abstract class InventoryServiceBase : IInventoryServices + { + protected Dictionary m_plugins = new Dictionary(); + //protected IAssetServer m_assetServer; + + public InventoryServiceBase() + { + //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) + { + if (!String.IsNullOrEmpty(FileName)) + { + MainLog.Instance.Verbose("Inventory", "Inventorystorage: 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"); + } + } + } + } + } + + /// + /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) + /// + /// + /// + 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 AddFolder(InventoryFolderBase folder) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.addInventoryFolder(folder); + } + } + + public void AddItem(InventoryItemBase item) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.addInventoryItem(item); + } + } + + public void deleteItem(InventoryItemBase item) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.deleteInventoryItem(item); + } + } + + /// + /// + /// + /// + public void AddNewInventorySet(UsersInventory inventory) + { + foreach (InventoryFolderBase folder in inventory.Folders.Values) + { + this.AddFolder(folder); + } + } + + public void CreateNewUserInventory(LLUUID user) + { + UsersInventory inven = new UsersInventory(); + inven.CreateNewInventorySet(user); + this.AddNewInventorySet(inven); + } + + public class UsersInventory + { + public Dictionary Folders = new Dictionary(); + public Dictionary Items = new Dictionary(); + + public UsersInventory() + { + + } + + public virtual void CreateNewInventorySet(LLUUID user) + { + InventoryFolderBase folder = new InventoryFolderBase(); + folder.parentID = LLUUID.Zero; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "My Inventory"; + folder.type = 8; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + LLUUID rootFolder = folder.folderID; + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Textures"; + folder.type = 0; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Objects"; + folder.type = 6; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Clothes"; + folder.type = 5; + folder.version = 1; + Folders.Add(folder.folderID, folder); + } + } + + public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs new file mode 100644 index 0000000..b5a4184 --- /dev/null +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -0,0 +1,667 @@ +using System; +using System.Collections; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.UserManagement +{ + + /// + /// A temp class to handle login response. + /// Should make use of UserProfileManager where possible. + /// + + public class LoginResponse + { + private Hashtable loginFlagsHash; + private Hashtable globalTexturesHash; + private Hashtable loginError; + private Hashtable uiConfigHash; + + private ArrayList loginFlags; + private ArrayList globalTextures; + private ArrayList eventCategories; + private ArrayList uiConfig; + private ArrayList classifiedCategories; + private ArrayList inventoryRoot; + private ArrayList initialOutfit; + private ArrayList agentInventory; + private ArrayList inventoryLibraryOwner; + private ArrayList inventoryLibrary; + + private UserInfo userProfile; + + private LLUUID agentID; + private LLUUID sessionID; + private LLUUID secureSessionID; + + // Login Flags + private string dst; + private string stipendSinceLogin; + private string gendered; + private string everLoggedIn; + private string login; + private int simPort; + private string simAddress; + private string agentAccess; + private Int32 circuitCode; + private uint regionX; + private uint regionY; + + // Login + private string firstname; + private string lastname; + + // Global Textures + private string sunTexture; + private string cloudTexture; + private string moonTexture; + + // Error Flags + private string errorReason; + private string errorMessage; + + // Response + private XmlRpcResponse xmlRpcResponse; + private XmlRpcResponse defaultXmlRpcResponse; + + private string welcomeMessage; + private string startLocation; + private string allowFirstLife; + private string home; + private string seedCapability; + private string lookAt; + + public LoginResponse() + { + this.loginFlags = new ArrayList(); + this.globalTextures = new ArrayList(); + this.eventCategories = new ArrayList(); + this.uiConfig = new ArrayList(); + this.classifiedCategories = new ArrayList(); + + this.loginError = new Hashtable(); + this.uiConfigHash = new Hashtable(); + + this.defaultXmlRpcResponse = new XmlRpcResponse(); + this.userProfile = new UserInfo(); + this.inventoryRoot = new ArrayList(); + this.initialOutfit = new ArrayList(); + this.agentInventory = new ArrayList(); + this.inventoryLibrary = new ArrayList(); + this.inventoryLibraryOwner = new ArrayList(); + + this.xmlRpcResponse = new XmlRpcResponse(); + this.defaultXmlRpcResponse = new XmlRpcResponse(); + + this.SetDefaultValues(); + } // LoginServer + + public void SetDefaultValues() + { + this.DST = "N"; + this.StipendSinceLogin = "N"; + this.Gendered = "Y"; + this.EverLoggedIn = "Y"; + this.login = "false"; + this.firstname = "Test"; + this.lastname = "User"; + this.agentAccess = "M"; + this.startLocation = "last"; + this.allowFirstLife = "Y"; + + this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + + this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + this.ErrorReason = "key"; + this.welcomeMessage = "Welcome to OpenSim!"; + this.seedCapability = ""; + this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}"; + this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + this.RegionX = (uint)255232; + this.RegionY = (uint)254976; + + // Classifieds; + this.AddClassifiedCategory((Int32)1, "Shopping"); + this.AddClassifiedCategory((Int32)2, "Land Rental"); + this.AddClassifiedCategory((Int32)3, "Property Rental"); + this.AddClassifiedCategory((Int32)4, "Special Attraction"); + this.AddClassifiedCategory((Int32)5, "New Products"); + this.AddClassifiedCategory((Int32)6, "Employment"); + this.AddClassifiedCategory((Int32)7, "Wanted"); + this.AddClassifiedCategory((Int32)8, "Service"); + this.AddClassifiedCategory((Int32)9, "Personal"); + + + this.SessionID = LLUUID.Random(); + this.SecureSessionID = LLUUID.Random(); + this.AgentID = LLUUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + this.initialOutfit.Add(InitialOutfitHash); + + + } // SetDefaultValues + + #region Login Failure Methods + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) + { + // Overwrite any default values; + this.xmlRpcResponse = new XmlRpcResponse(); + + // Ensure Login Failed message/reason; + this.ErrorMessage = message; + this.ErrorReason = reason; + + this.loginError["reason"] = this.ErrorReason; + this.loginError["message"] = this.ErrorMessage; + this.loginError["login"] = login; + this.xmlRpcResponse.Value = this.loginError; + return (this.xmlRpcResponse); + } // GenerateResponse + + public XmlRpcResponse CreateFailedResponse() + { + return (this.CreateLoginFailedResponse()); + } // CreateErrorConnectingToGridResponse() + + public XmlRpcResponse CreateLoginFailedResponse() + { + return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false")); + } // LoginFailedResponse + + public XmlRpcResponse CreateAlreadyLoggedInResponse() + { + return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false")); + } // CreateAlreadyLoggedInResponse() + + public XmlRpcResponse CreateDeadRegionResponse() + { + return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false")); + } + + public XmlRpcResponse CreateGridErrorResponse() + { + return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false")); + } + + #endregion + + public XmlRpcResponse ToXmlRpcResponse() + { + try + { + + Hashtable responseData = new Hashtable(); + + this.loginFlagsHash = new Hashtable(); + this.loginFlagsHash["daylight_savings"] = this.DST; + this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin; + this.loginFlagsHash["gendered"] = this.Gendered; + this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn; + this.loginFlags.Add(this.loginFlagsHash); + + responseData["first_name"] = this.Firstname; + responseData["last_name"] = this.Lastname; + responseData["agent_access"] = this.agentAccess; + + this.globalTexturesHash = new Hashtable(); + this.globalTexturesHash["sun_texture_id"] = this.SunTexture; + this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture; + this.globalTexturesHash["moon_texture_id"] = this.MoonTexture; + this.globalTextures.Add(this.globalTexturesHash); + // this.eventCategories.Add(this.eventCategoriesHash); + + this.AddToUIConfig("allow_first_life", this.allowFirstLife); + this.uiConfig.Add(this.uiConfigHash); + + responseData["sim_port"] =(Int32) this.SimPort; + responseData["sim_ip"] = this.SimAddress; + + responseData["agent_id"] = this.AgentID.ToStringHyphenated(); + responseData["session_id"] = this.SessionID.ToStringHyphenated(); + responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated(); + responseData["circuit_code"] = this.CircuitCode; + responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = this.loginFlags; + responseData["global-textures"] = this.globalTextures; + responseData["seed_capability"] = this.seedCapability; + + responseData["event_categories"] = this.eventCategories; + responseData["event_notifications"] = new ArrayList(); // todo + responseData["classified_categories"] = this.classifiedCategories; + responseData["ui-config"] = this.uiConfig; + + responseData["inventory-skeleton"] = this.agentInventory; + responseData["inventory-skel-lib"] = this.inventoryLibrary; + responseData["inventory-root"] = this.inventoryRoot; + responseData["gestures"] = new ArrayList(); // todo + responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; + responseData["initial-outfit"] = this.initialOutfit; + responseData["start_location"] = this.startLocation; + responseData["seed_capability"] = this.seedCapability; + responseData["home"] = this.home; + responseData["look_at"] = this.lookAt; + responseData["message"] = this.welcomeMessage; + responseData["region_x"] = (Int32)this.RegionX * 256; + responseData["region_y"] = (Int32)this.RegionY * 256; + + //responseData["inventory-lib-root"] = new ArrayList(); // todo + //responseData["buddy-list"] = new ArrayList(); // todo + + responseData["login"] = "true"; + this.xmlRpcResponse.Value = responseData; + + return (this.xmlRpcResponse); + } + catch (Exception e) + { + MainLog.Instance.Warn( + "CLIENT", + "LoginResponse: Error creating XML-RPC Response: " + e.Message + ); + return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); + + } + + } // ToXmlRpcResponse + + public void SetEventCategories(string category, string value) + { + // this.eventCategoriesHash[category] = value; + //TODO + } // SetEventCategories + + public void AddToUIConfig(string itemName, string item) + { + this.uiConfigHash[itemName] = item; + } // SetUIConfig + + public void AddClassifiedCategory(Int32 ID, string categoryName) + { + Hashtable hash = new Hashtable(); + hash["category_name"] = categoryName; + hash["category_id"] = ID; + this.classifiedCategories.Add(hash); + // this.classifiedCategoriesHash.Clear(); + } // SetClassifiedCategory + + #region Properties + public string Login + { + get + { + return this.login; + } + set + { + this.login = value; + } + } // Login + + public string DST + { + get + { + return this.dst; + } + set + { + this.dst = value; + } + } // DST + + public string StipendSinceLogin + { + get + { + return this.stipendSinceLogin; + } + set + { + this.stipendSinceLogin = value; + } + } // StipendSinceLogin + + public string Gendered + { + get + { + return this.gendered; + } + set + { + this.gendered = value; + } + } // Gendered + + public string EverLoggedIn + { + get + { + return this.everLoggedIn; + } + set + { + this.everLoggedIn = value; + } + } // EverLoggedIn + + public int SimPort + { + get + { + return this.simPort; + } + set + { + this.simPort = value; + } + } // SimPort + + public string SimAddress + { + get + { + return this.simAddress; + } + set + { + this.simAddress = value; + } + } // SimAddress + + public LLUUID AgentID + { + get + { + return this.agentID; + } + set + { + this.agentID = value; + } + } // AgentID + + public LLUUID SessionID + { + get + { + return this.sessionID; + } + set + { + this.sessionID = value; + } + } // SessionID + + public LLUUID SecureSessionID + { + get + { + return this.secureSessionID; + } + set + { + this.secureSessionID = value; + } + } // SecureSessionID + + public Int32 CircuitCode + { + get + { + return this.circuitCode; + } + set + { + this.circuitCode = value; + } + } // CircuitCode + + public uint RegionX + { + get + { + return this.regionX; + } + set + { + this.regionX = value; + } + } // RegionX + + public uint RegionY + { + get + { + return this.regionY; + } + set + { + this.regionY = value; + } + } // RegionY + + public string SunTexture + { + get + { + return this.sunTexture; + } + set + { + this.sunTexture = value; + } + } // SunTexture + + public string CloudTexture + { + get + { + return this.cloudTexture; + } + set + { + this.cloudTexture = value; + } + } // CloudTexture + + public string MoonTexture + { + get + { + return this.moonTexture; + } + set + { + this.moonTexture = value; + } + } // MoonTexture + + public string Firstname + { + get + { + return this.firstname; + } + set + { + this.firstname = value; + } + } // Firstname + + public string Lastname + { + get + { + return this.lastname; + } + set + { + this.lastname = value; + } + } // Lastname + + public string AgentAccess + { + get + { + return this.agentAccess; + } + set + { + this.agentAccess = value; + } + } + + public string StartLocation + { + get + { + return this.startLocation; + } + set + { + this.startLocation = value; + } + } // StartLocation + + public string LookAt + { + get + { + return this.lookAt; + } + set + { + this.lookAt = value; + } + } + + public string SeedCapability + { + get + { + return this.seedCapability; + } + set + { + this.seedCapability = value; + } + } // SeedCapability + + public string ErrorReason + { + get + { + return this.errorReason; + } + set + { + this.errorReason = value; + } + } // ErrorReason + + public string ErrorMessage + { + get + { + return this.errorMessage; + } + set + { + this.errorMessage = value; + } + } // ErrorMessage + + public ArrayList InventoryRoot + { + get + { + return this.inventoryRoot; + } + set + { + this.inventoryRoot = value; + } + } + + public ArrayList InventorySkeleton + { + get + { + return this.agentInventory; + } + set + { + this.agentInventory = value; + } + } + + public ArrayList InventoryLibrary + { + get + { + return this.inventoryLibrary; + } + set + { + this.inventoryLibrary = value; + } + } + + public ArrayList InventoryLibraryOwner + { + get + { + return this.inventoryLibraryOwner; + } + set + { + this.inventoryLibraryOwner = value; + } + } + + public string Home + { + get + { + return this.home; + } + set + { + this.home = value; + } + } + + public string Message + { + get + { + return this.welcomeMessage; + } + set + { + this.welcomeMessage = value; + } + } + #endregion + + + public class UserInfo + { + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + } + } +} + diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs new file mode 100644 index 0000000..8e7cf80 --- /dev/null +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -0,0 +1,287 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) + { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + System.Console.WriteLine("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + System.Console.WriteLine(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) + { + System.Console.WriteLine(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs new file mode 100644 index 0000000..d1bbde1 --- /dev/null +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -0,0 +1,379 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Configuration; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.UserManagement +{ + public abstract class UserManagerBase : IUserServices + { + public UserConfig _config; + Dictionary _plugins = new Dictionary(); + + /// + /// Adds a new user server plugin - user servers will be requested in the order they were loaded. + /// + /// The filename to the user server plugin DLL + public void AddPlugin(string FileName) + { + if (!String.IsNullOrEmpty(FileName)) + { + MainLog.Instance.Verbose("Userstorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + MainLog.Instance.Verbose("Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IUserData", true); + + if (typeInterface != null) + { + IUserData plug = + (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + AddPlugin(plug); + } + } + } + } + } + + public void AddPlugin(IUserData plug) + { + plug.Initialise(); + this._plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); + } + + #region Get UserProfile + /// + /// Loads a user profile from a database by UUID + /// + /// The target UUID + /// A user profile + public UserProfileData GetUserProfile(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.GetUserByUUID(uuid); + profile.currentAgent = getUserAgent(profile.UUID); + return profile; + } + catch (Exception e) + { + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + + /// + /// Loads a user profile by name + /// + /// The target name + /// A user profile + public UserProfileData GetUserProfile(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.GetUserByName(name); + profile.currentAgent = getUserAgent(profile.UUID); + return profile; + } + catch (Exception e) + { + System.Console.WriteLine("EEK!"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user profile by name + /// + /// First name + /// Last name + /// A user profile + public UserProfileData GetUserProfile(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.GetUserByName(fname,lname); + + profile.currentAgent = getUserAgent(profile.UUID); + + return profile; + } + catch (Exception e) + { + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Set's user profile from object + /// + /// First name + /// Last name + /// A user profile + public bool setUserProfile(UserProfileData data) + { + foreach (KeyValuePair plugin in _plugins) + { + try { + plugin.Value.UpdateUserProfile(data); + return true; + } catch (Exception e) { + MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return false; + } + + #endregion + + #region Get UserAgent + /// + /// Loads a user agent by uuid (not called directly) + /// + /// The agents UUID + /// Agent profiles + public UserAgentData getUserAgent(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAgentByUUID(uuid); + } + catch (Exception e) + { + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user agent by name (not called directly) + /// + /// The agents name + /// A user agent + public UserAgentData getUserAgent(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAgentByName(name); + } + catch (Exception e) + { + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + // TODO: document + public void clearUserAgent(LLUUID agentID) + { + UserProfileData profile = GetUserProfile(agentID); + profile.currentAgent = null; + setUserProfile(profile); + } + + + /// + /// Loads a user agent by name (not called directly) + /// + /// The agents firstname + /// The agents lastname + /// A user agent + public UserAgentData getUserAgent(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAgentByName(fname,lname); + } + catch (Exception e) + { + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + #endregion + + #region CreateAgent + /// + /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB + /// + /// The users profile + /// The users loginrequest + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + UserAgentData agent = new UserAgentData(); + + // User connection + agent.agentOnline = true; + + // Generate sessions + RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); + byte[] randDataS = new byte[16]; + byte[] randDataSS = new byte[16]; + rand.GetBytes(randDataS); + rand.GetBytes(randDataSS); + + agent.secureSessionID = new LLUUID(randDataSS, 0); + agent.sessionID = new LLUUID(randDataS, 0); + + // Profile UUID + agent.UUID = profile.UUID; + + // Current position (from Home) + agent.currentHandle = profile.homeRegion; + agent.currentPos = profile.homeLocation; + + // If user specified additional start, use that + if (requestData.ContainsKey("start")) + { + string startLoc = ((string)requestData["start"]).Trim(); + if (!(startLoc == "last" || startLoc == "home")) + { + // Format: uri:Ahern&162&213&34 + try + { + string[] parts = startLoc.Remove(0, 4).Split('&'); + string region = parts[0]; + + //////////////////////////////////////////////////// + //SimProfile SimInfo = new SimProfile(); + //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); + } + catch (Exception) + { + + } + } + } + + // What time did the user login? + agent.loginTime = Util.UnixTimeSinceEpoch(); + agent.logoutTime = 0; + + // Current location + agent.regionID = new LLUUID(); // Fill in later + agent.currentRegion = new LLUUID(); // Fill in later + + profile.currentAgent = agent; + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + #endregion + + /// + /// + /// + /// + public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + { + UserProfileData user = new UserProfileData(); + user.homeLocation = new LLVector3(128, 128, 100); + user.UUID = LLUUID.Random(); + user.username = firstName; + user.surname = lastName; + user.passwordHash = pass; + user.passwordSalt = ""; + user.created = Util.UnixTimeSinceEpoch(); + user.homeLookAt = new LLVector3(100, 100, 100); + user.homeRegionX = regX; + user.homeRegionY = regY; + + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.AddNewUserProfile(user); + + } + catch (Exception e) + { + MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + + public abstract UserProfileData SetupMasterUser(string firstName, string lastName); + public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); + } +} -- cgit v1.1 From eb8640f368ab43b27395690404e845f09366c652 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 25 Sep 2007 06:33:18 +0000 Subject: * Now the OGS1GridServices has a LocalBackEndServices that it forwards intra-instance requests to * Every Scene has a ClientManager (as every dog it's day) since two scenes can have the same circuit as client. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 4853c3a..a1afe8d 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -34,6 +34,6 @@ namespace OpenSim.Framework.Communications { bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); - bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID); + bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); } } -- cgit v1.1 From 8143c597fc5f62ec0d931d2d5b887730e06aec04 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Sep 2007 13:25:45 +0000 Subject: * Tleiades grid mode inventory (#444) - thanx Tleiades! * updated to rev 1413 on libsecondlife.dll and libsecondlife.dll.config (#423) --- OpenSim/Framework/Communications/CAPSService.cs | 1 - .../Communications/Cache/CachedUserInfo.cs | 14 +- .../Communications/Cache/InventoryFolder.cs | 12 +- .../Communications/Cache/UserProfileCache.cs | 32 ++- .../Framework/Communications/IInventoryServices.cs | 16 +- .../Communications/InventoryServiceBase.cs | 255 ++++++++++++++++----- OpenSim/Framework/Communications/LoginResponse.cs | 48 ++-- OpenSim/Framework/Communications/LoginService.cs | 134 +++++------ 8 files changed, 347 insertions(+), 165 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index a8eac26..40d8d37 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -8,7 +8,6 @@ using Nwc.XmlRpc; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 99dc45a..9e8c239 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -38,7 +38,7 @@ using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications.Caches { - public class CachedUserInfo + public class CachedUserInfo : MarshalByRefObject { private CommunicationsManager m_parentCommsManager; // Fields @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Caches } // Methods - public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) + public void FolderReceive(LLUUID userID, InventoryFolderBase folderInfo) { if (userID == this.UserProfile.UUID) { @@ -59,19 +59,19 @@ namespace OpenSim.Framework.Communications.Caches { if (folderInfo.parentID == LLUUID.Zero) { - this.RootFolder = folderInfo; + this.RootFolder = new InventoryFolder(folderInfo); } } else if (this.RootFolder.folderID == folderInfo.parentID) { - this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + this.RootFolder.SubFolders.Add(folderInfo.folderID, new InventoryFolder(folderInfo)); } else { InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { - folder.SubFolders.Add(folderInfo.folderID, folderInfo); + folder.SubFolders.Add(folderInfo.folderID, new InventoryFolder(folderInfo)); } } } @@ -131,3 +131,7 @@ namespace OpenSim.Framework.Communications.Caches } + + + + diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 885cffc..a212614 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -35,6 +35,9 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Data; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; + +using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications.Caches { @@ -60,7 +63,7 @@ namespace OpenSim.Framework.Communications.Caches } // Methods - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type, InventoryCategory category) { InventoryFolder subFold = new InventoryFolder(); subFold.name = folderName; @@ -68,7 +71,12 @@ namespace OpenSim.Framework.Communications.Caches subFold.type = (short) type; subFold.parentID = this.folderID; subFold.agentID = this.agentID; - this.SubFolders.Add(subFold.folderID, subFold); + subFold.category = category; + if (!SubFolders.ContainsKey(subFold.folderID)) + this.SubFolders.Add(subFold.folderID, subFold); + else + MainLog.Instance.Warn("INVENTORYCACHE", "Attempt to create a duplicate folder {0} {1}", folderName, folderID); + return subFold; } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 390b938..3dadf9c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -35,10 +35,11 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Data; +using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications.Caches { - public class UserProfileCache + public class UserProfileCache : MarshalByRefObject { // Fields private CommunicationsManager m_parent; @@ -103,7 +104,7 @@ namespace OpenSim.Framework.Communications.Caches CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType, InventoryCategory.User); if (createdFolder != null) { this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); @@ -114,7 +115,7 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); if (folder != null) { - folder.CreateNewSubFolder(folderID, folderName, folderType); + folder.CreateNewSubFolder(folderID, folderName, folderType, InventoryCategory.User); } } } @@ -124,16 +125,21 @@ namespace OpenSim.Framework.Communications.Caches public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { InventoryFolder fold = null; + if (folderID == libraryRoot.folderID ) { + // we are looking for the root of the shared inventory remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); } else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) { + // we are looking for a sub folder of the shared inventory remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); } else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { + //if we get here, we are looking the inventory of an agent in this sim + //now we need to see if we already have the inventory cached if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) { CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; @@ -153,9 +159,23 @@ namespace OpenSim.Framework.Communications.Caches } } } + else + { + //nope, inventory wasn't cached, so go to the inventory server and ask for the inventory + m_parent.InventoryService.RequestInventoryForUser(remoteClient.AgentId, ReceiveFolderInfo, ReceiveItemInfo); + } } } + public void ReceiveFolderInfo(LLUUID userID, InventoryFolderBase folderInfo) + { + } + + public void ReceiveItemInfo(LLUUID userID, InventoryItemBase itemInfo) + { + } + + public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) { if (ownerID == libraryRoot.agentID) @@ -181,7 +201,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -221,3 +241,7 @@ namespace OpenSim.Framework.Communications.Caches } } + + + + diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 80c2e64..7b2948f 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,29 +1,31 @@ using System; -using System.Collections.Generic; using System.Text; -using OpenSim.Framework.Data; +using System.Collections.Generic; + using libsecondlife; +using OpenSim.Framework.Data; using OpenSim.Framework.Communications.Caches; -using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications { - public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); + public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderBase folderInfo); public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); - void CreateNewUserInventory(LLUUID user); + void CreateNewUserInventory(LLUUID libraryRootId, LLUUID user); + void GetRootFoldersForUser(LLUUID user, out LLUUID libraryFolder, out LLUUID personalFolder); /// /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) /// /// /// - List RequestFirstLevelFolders(LLUUID userID); + List RequestFirstLevelFolders(LLUUID folderID); + List RequestFolderItems(LLUUID folderID); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index da7a0ce..6283b60 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -1,4 +1,9 @@ using System; +using System.Text; +using System.IO; +using System.Xml; +using System.Xml.Serialization; +using System.Collections; using System.Collections.Generic; using System.Reflection; using libsecondlife; @@ -6,21 +11,20 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; +using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications { - public abstract class InventoryServiceBase : IInventoryServices + public abstract class InventoryServiceBase : MarshalByRefObject, IInventoryServices { - protected Dictionary m_plugins = new Dictionary(); - //protected IAssetServer m_assetServer; + protected IInventoryData _databasePlugin; public InventoryServiceBase() { - //m_assetServer = assetServer; } /// - /// Adds a new user server plugin - plugins will be requested in the order they were loaded. + /// Adds a new inventory data server plugin /// /// The filename to the user server plugin DLL public void AddPlugin(string FileName) @@ -41,8 +45,13 @@ namespace OpenSim.Framework.Communications IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - this.m_plugins.Add(plug.getName(), plug); + this._databasePlugin = plug; + + //TODO! find a better place to create inventory skeletons + loadInventoryFromXmlFile(InventoryCategory.Library, "Inventory_Library.xml"); + loadInventoryFromXmlFile(InventoryCategory.Default, "Inventory_Default.xml"); MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); + break; } } } @@ -54,20 +63,20 @@ namespace OpenSim.Framework.Communications /// /// /// - public List RequestFirstLevelFolders(LLUUID userID) + public List RequestFirstLevelFolders(LLUUID folderID) { - List inventoryList = new List(); - foreach (KeyValuePair plugin in m_plugins) + InventoryFolderBase root = _databasePlugin.getInventoryFolder(folderID); + + List folders = new List(); + if (root != null) { - InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID); - if (rootFolder != null) - { - inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); - inventoryList.Insert(0, rootFolder); - return inventoryList; - } + folders.Add(root); + + List subFolders = _databasePlugin.getInventoryFolders(root.folderID); + foreach (InventoryFolderBase f in subFolders) + folders.Add(f); } - return inventoryList; + return folders; } /// @@ -75,11 +84,7 @@ namespace OpenSim.Framework.Communications /// public InventoryFolderBase RequestUsersRoot(LLUUID userID) { - foreach (KeyValuePair plugin in m_plugins) - { - return plugin.Value.getUserRootFolder(userID); - } - return null; + return _databasePlugin.getInventoryFolder(userID); // the id of the root folder, is the user id } /// @@ -89,47 +94,27 @@ namespace OpenSim.Framework.Communications /// public List RequestSubFolders(LLUUID parentFolderID) { - List inventoryList = new List(); - foreach (KeyValuePair plugin in m_plugins) - { - return plugin.Value.getInventoryFolders(parentFolderID); - } - return inventoryList; + return _databasePlugin.getInventoryFolders(parentFolderID); } public List RequestFolderItems(LLUUID folderID) { - List itemsList = new List(); - foreach (KeyValuePair plugin in m_plugins) - { - itemsList = plugin.Value.getInventoryInFolder(folderID); - return itemsList; - } - return itemsList; + return _databasePlugin.getInventoryInFolder(folderID); } public void AddFolder(InventoryFolderBase folder) { - foreach (KeyValuePair plugin in m_plugins) - { - plugin.Value.addInventoryFolder(folder); - } + _databasePlugin.addInventoryFolder(folder); } public void AddItem(InventoryItemBase item) { - foreach (KeyValuePair plugin in m_plugins) - { - plugin.Value.addInventoryItem(item); - } + _databasePlugin.addInventoryItem(item); } public void deleteItem(InventoryItemBase item) { - foreach (KeyValuePair plugin in m_plugins) - { - plugin.Value.deleteInventoryItem(item); - } + _databasePlugin.deleteInventoryItem(item); } /// @@ -144,11 +129,53 @@ namespace OpenSim.Framework.Communications } } - public void CreateNewUserInventory(LLUUID user) + public void CreateNewUserInventory(LLUUID defaultFolders, LLUUID user) { - UsersInventory inven = new UsersInventory(); - inven.CreateNewInventorySet(user); - this.AddNewInventorySet(inven); + try + { + // Get Default folder set from the database + //TODO! We need to get the whole hierachy and not just one level down + List folders = this.RequestFirstLevelFolders(LLUUID.Parse("00000112-000f-0000-0000-000100bba000")); + + // create an index list, where each of the elements has the index of its parent in the hierachy + // this algorithm is pretty shoddy O(n^2), but it is only executed once per user. + int[] parentIdx = new int[folders.Count]; + for (int i = 0; i < folders.Count; i++) + parentIdx[i] = -1; + + for (int i = 0; i < folders.Count; i++) + for (int j = 0; j < folders.Count; j++) + if (folders[i].folderID == folders[j].parentID) + parentIdx[j] = i; + + + //assign a new owerid and a new to the folders + foreach (InventoryFolderBase ifb in folders) + { + if (ifb.parentID == LLUUID.Zero) + ifb.folderID = user; + else + ifb.folderID = LLUUID.Random(); + + ifb.agentID = user; + ifb.category = InventoryCategory.User; + } + + // correct the parent id + for (int i = 0; i < folders.Count; i++) + { + if (folders[i].parentID != LLUUID.Zero) + folders[i].parentID = folders[parentIdx[i]].folderID; // root folder id is the same as the user id + } + + // the list is structurally sound, using new folder id's, so save it + foreach (InventoryFolderBase ifb in folders) + _databasePlugin.addInventoryFolder(ifb); + } + catch (Exception e) + { + MainLog.Instance.Error(e.ToString()); + } } public class UsersInventory @@ -166,10 +193,11 @@ namespace OpenSim.Framework.Communications InventoryFolderBase folder = new InventoryFolderBase(); folder.parentID = LLUUID.Zero; folder.agentID = user; - folder.folderID = LLUUID.Random(); + folder.folderID = user; // id of root folder is the same as the agent id folder.name = "My Inventory"; folder.type = 8; folder.version = 1; + folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); LLUUID rootFolder = folder.folderID; @@ -181,6 +209,7 @@ namespace OpenSim.Framework.Communications folder.name = "Textures"; folder.type = 0; folder.version = 1; + folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); folder = new InventoryFolderBase(); @@ -190,6 +219,7 @@ namespace OpenSim.Framework.Communications folder.name = "Objects"; folder.type = 6; folder.version = 1; + folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); folder = new InventoryFolderBase(); @@ -199,13 +229,130 @@ namespace OpenSim.Framework.Communications folder.name = "Clothes"; folder.type = 5; folder.version = 1; + folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); } } + + public void GetRootFoldersForUser(LLUUID user, out LLUUID libraryFolder, out LLUUID personalFolder) + { + List folders = _databasePlugin.getUserRootFolders(user); + libraryFolder = LLUUID.Zero; + personalFolder = LLUUID.Zero; + + for (int i = 0; i < folders.Count; i++) + { + if (folders[i].category == InventoryCategory.Library) + libraryFolder = folders[i].folderID; + else if (folders[i].category == InventoryCategory.User) + personalFolder = folders[i].folderID; + } + } + + /* + * Dot net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder + * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize + * into this simpler class, and then use that. + */ + [XmlRoot(ElementName = "inventory", IsNullable = true)] + public class SerializedInventory + { + [XmlRoot(ElementName = "folder", IsNullable = true)] + public class SerializedFolder : InventoryFolderBase + { + [XmlArray(ElementName = "folders", IsNullable = true)] + [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof(SerializedFolder))] + public ArrayList SubFolders; + + [XmlArray(ElementName = "items", IsNullable = true)] + [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof(InventoryItemBase))] + public ArrayList Items; + } + + [XmlElement(ElementName = "folder", IsNullable = true)] + public SerializedFolder root; + } + + public void uploadInventory(SerializedInventory.SerializedFolder folder) + { + foreach (InventoryItemBase iib in folder.Items) + { + // assign default values, if they haven't assigned + iib.avatarID = folder.agentID; + if (iib.assetID == LLUUID.Zero) + iib.assetID = LLUUID.Random(); + if (iib.creatorsID == LLUUID.Zero) + iib.creatorsID = folder.agentID; + if (iib.inventoryID == LLUUID.Zero) + iib.inventoryID = LLUUID.Random(); + if (iib.inventoryName == null || iib.inventoryName.Length == 0) + iib.inventoryName = "new item"; + iib.parentFolderID = folder.folderID; + + _databasePlugin.addInventoryItem(iib); + } + + foreach (SerializedInventory.SerializedFolder sf in folder.SubFolders) + { + // assign default values, if they haven't assigned + sf.agentID = folder.agentID; + sf.category = folder.category; + if (sf.folderID == LLUUID.Zero) + sf.folderID = LLUUID.Random(); + if (sf.name == null || sf.name.Length == 0) + sf.name = "new folder"; + sf.parentID = folder.folderID; + + _databasePlugin.addInventoryFolder(sf); + uploadInventory(sf); + } + } + + public void loadInventoryFromXmlFile(InventoryCategory inventoryCategory, string fileName) + { + _databasePlugin.deleteInventoryCategory(inventoryCategory); + + FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); + XmlReader reader = new XmlTextReader(fs); + XmlSerializer x = new XmlSerializer(typeof(SerializedInventory)); + SerializedInventory inventory = (SerializedInventory)x.Deserialize(reader); + + // the library and default inventories has no owner, so we use a random guid. + if (inventory.root.category == InventoryCategory.Library || inventory.root.category == InventoryCategory.Default) + { + if (inventory.root.folderID != LLUUID.Zero) + inventory.root.agentID = inventory.root.folderID; + else + inventory.root.agentID = LLUUID.Random(); + } + else if (inventory.root.category == InventoryCategory.User) + { + if (inventory.root.agentID == LLUUID.Zero) + inventory.root.agentID = LLUUID.Random(); + } + + inventory.root.folderID = inventory.root.agentID; // the root folder always has the same id as the owning agent + inventory.root.parentID = LLUUID.Zero; + inventory.root.version = 0; + inventory.root.category = inventoryCategory; + + _databasePlugin.addInventoryFolder(inventory.root); + uploadInventory(inventory.root); + } + + protected void saveInventoryToXmlFile(SerializedInventory inventory, string fileName) + { + FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); + XmlTextWriter writer = new XmlTextWriter(fs, Encoding.UTF8); + writer.Formatting = Formatting.Indented; + XmlSerializer x = new XmlSerializer(typeof(SerializedInventory)); + x.Serialize(writer, inventory); + } + public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b5a4184..b4280e7 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -26,9 +26,10 @@ namespace OpenSim.Framework.UserManagement private ArrayList classifiedCategories; private ArrayList inventoryRoot; private ArrayList initialOutfit; - private ArrayList agentInventory; + private ArrayList inventorySkeleton; private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibrary; + private ArrayList inventoryLibraryRoot; + private ArrayList inventoryLibrarySkeleton; private UserInfo userProfile; @@ -86,11 +87,13 @@ namespace OpenSim.Framework.UserManagement this.defaultXmlRpcResponse = new XmlRpcResponse(); this.userProfile = new UserInfo(); - this.inventoryRoot = new ArrayList(); + this.initialOutfit = new ArrayList(); - this.agentInventory = new ArrayList(); - this.inventoryLibrary = new ArrayList(); + this.inventoryRoot = new ArrayList(); + this.inventorySkeleton = new ArrayList(); + this.inventoryLibrarySkeleton = new ArrayList(); this.inventoryLibraryOwner = new ArrayList(); + this.inventoryLibraryRoot = new ArrayList(); this.xmlRpcResponse = new XmlRpcResponse(); this.defaultXmlRpcResponse = new XmlRpcResponse(); @@ -237,12 +240,15 @@ namespace OpenSim.Framework.UserManagement responseData["classified_categories"] = this.classifiedCategories; responseData["ui-config"] = this.uiConfig; - responseData["inventory-skeleton"] = this.agentInventory; - responseData["inventory-skel-lib"] = this.inventoryLibrary; + responseData["inventory-skeleton"] = this.inventorySkeleton; + responseData["inventory-skel-lib"] = this.inventoryLibrarySkeleton; responseData["inventory-root"] = this.inventoryRoot; - responseData["gestures"] = new ArrayList(); // todo responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; + responseData["inventory-lib-root"] = this.inventoryLibraryRoot; + + responseData["gestures"] = new ArrayList(); // todo responseData["initial-outfit"] = this.initialOutfit; + responseData["start_location"] = this.startLocation; responseData["seed_capability"] = this.seedCapability; responseData["home"] = this.home; @@ -596,23 +602,23 @@ namespace OpenSim.Framework.UserManagement { get { - return this.agentInventory; + return this.inventorySkeleton; } set { - this.agentInventory = value; + this.inventorySkeleton = value; } } - public ArrayList InventoryLibrary + public ArrayList InventoryLibrarySkeleton { get { - return this.inventoryLibrary; + return this.inventoryLibrarySkeleton; } set { - this.inventoryLibrary = value; + this.inventoryLibrarySkeleton = value; } } @@ -628,6 +634,18 @@ namespace OpenSim.Framework.UserManagement } } + public ArrayList InventoryLibraryRoot + { + get + { + return this.inventoryLibraryRoot; + } + set + { + this.inventoryLibraryRoot = value; + } + } + public string Home { get @@ -665,3 +683,7 @@ namespace OpenSim.Framework.UserManagement } } + + + + diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8e7cf80..64e323d 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -8,11 +8,10 @@ using Nwc.XmlRpc; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; - +using OpenSim.Framework.Communications; using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + namespace OpenSim.Framework.UserManagement { @@ -20,10 +19,12 @@ namespace OpenSim.Framework.UserManagement { protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; + protected IInventoryServices m_inventoryServer = null; - public LoginService(UserManagerBase userManager, string welcomeMess) + public LoginService(UserManagerBase userManager, IInventoryServices inventoryServer, string welcomeMess) { m_userManager = userManager; + m_inventoryServer = inventoryServer; if (welcomeMess != "") { m_welcomeMessage = welcomeMess; @@ -37,7 +38,6 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - System.Console.WriteLine("Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; @@ -85,15 +85,41 @@ namespace OpenSim.Framework.UserManagement { LLUUID agentID = userProfile.UUID; - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; + LLUUID libraryFolderID; + LLUUID personalFolderID; + + m_inventoryServer.GetRootFoldersForUser(agentID, out libraryFolderID, out personalFolderID); + if (personalFolderID == LLUUID.Zero) + { + m_inventoryServer.CreateNewUserInventory(libraryFolderID, agentID); + m_inventoryServer.GetRootFoldersForUser(agentID, out libraryFolderID, out personalFolderID); + } + + // The option "inventory-lib-owner" requires that we return the id of the + // owner of the library inventory. + Hashtable dynamicStruct = new Hashtable(); + dynamicStruct["agent_id"] = libraryFolderID.ToStringHyphenated(); + logResponse.InventoryLibraryOwner.Add(dynamicStruct); + + // The option "inventory-lib-root" requires that we return the id of the + // root folder of the library inventory. + dynamicStruct = new Hashtable(); + dynamicStruct["folder_id"] = libraryFolderID.ToStringHyphenated(); + logResponse.InventoryLibraryRoot.Add(dynamicStruct); - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; + // The option "inventory-root" requires that we return the id of the + // root folder of the users inventory. + dynamicStruct = new Hashtable(); + dynamicStruct["folder_id"] = personalFolderID.ToStringHyphenated(); + logResponse.InventoryRoot.Add(dynamicStruct); + + // The option "inventory-skeleton" requires that we return the structure of the + // users folder hierachy + logResponse.InventorySkeleton = GetInventorySkeleton(personalFolderID); + + // The option "inventory-skel-lib" requires that we return the structure of the + // library folder hierachy + logResponse.InventoryLibrarySkeleton = GetInventorySkeleton(libraryFolderID); // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); @@ -103,10 +129,6 @@ namespace OpenSim.Framework.UserManagement logResponse.AgentID = agentID.ToStringHyphenated(); logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten @@ -212,76 +234,30 @@ namespace OpenSim.Framework.UserManagement } /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// + /// Create a structure of the generic inventory structure of a specified folder /// /// - protected virtual ArrayList GetLibraryOwner() + protected virtual ArrayList GetInventorySkeleton(LLUUID folderID) { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); + List folders = m_inventoryServer.RequestFirstLevelFolders(folderID); - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + ArrayList temp = new ArrayList(); + foreach (InventoryFolderBase ifb in folders) { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); + LLUUID tempFolderID = ifb.folderID; + LLUUID tempParentID = ifb.parentID; + + Hashtable TempHash = new Hashtable(); + TempHash["folder_id"] = tempFolderID.ToStringHyphenated(); + TempHash["name"] = ifb.name; + TempHash["parent_id"] = tempParentID.ToStringHyphenated(); + TempHash["type_default"] = ifb.type; + TempHash["version"] = ifb.version+1; + temp.Add(TempHash); } - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } + return temp; } } } -- cgit v1.1 From 3ddf9da1f417f50f9e5b10afa963ea7e74a1d885 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Sep 2007 13:51:16 +0000 Subject: * Tleiades patch #445 - the inventory folders displayed does not show the expected folder icons Tahnx, Tleiades; keep up the good work! --- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 64e323d..4e6aa80 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -252,8 +252,8 @@ namespace OpenSim.Framework.UserManagement TempHash["folder_id"] = tempFolderID.ToStringHyphenated(); TempHash["name"] = ifb.name; TempHash["parent_id"] = tempParentID.ToStringHyphenated(); - TempHash["type_default"] = ifb.type; - TempHash["version"] = ifb.version+1; + TempHash["type_default"] = (Int32)ifb.type; + TempHash["version"] = (Int32)ifb.version+1; temp.Add(TempHash); } -- cgit v1.1 From 863195612bdef56165f2b4354bab280c371618b9 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Sep 2007 14:57:43 +0000 Subject: Reverting back to 2017 since 2018 were causing Linux breakage; reopening Tleiades patch 444 and 445. --- OpenSim/Framework/Communications/CAPSService.cs | 1 + .../Communications/Cache/CachedUserInfo.cs | 14 +- .../Communications/Cache/InventoryFolder.cs | 12 +- .../Communications/Cache/UserProfileCache.cs | 32 +-- .../Framework/Communications/IInventoryServices.cs | 16 +- .../Communications/InventoryServiceBase.cs | 255 +++++---------------- OpenSim/Framework/Communications/LoginResponse.cs | 48 ++-- OpenSim/Framework/Communications/LoginService.cs | 134 ++++++----- 8 files changed, 165 insertions(+), 347 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index 40d8d37..a8eac26 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -8,6 +8,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9e8c239..99dc45a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -38,7 +38,7 @@ using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications.Caches { - public class CachedUserInfo : MarshalByRefObject + public class CachedUserInfo { private CommunicationsManager m_parentCommsManager; // Fields @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Caches } // Methods - public void FolderReceive(LLUUID userID, InventoryFolderBase folderInfo) + public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) { if (userID == this.UserProfile.UUID) { @@ -59,19 +59,19 @@ namespace OpenSim.Framework.Communications.Caches { if (folderInfo.parentID == LLUUID.Zero) { - this.RootFolder = new InventoryFolder(folderInfo); + this.RootFolder = folderInfo; } } else if (this.RootFolder.folderID == folderInfo.parentID) { - this.RootFolder.SubFolders.Add(folderInfo.folderID, new InventoryFolder(folderInfo)); + this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); } else { InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { - folder.SubFolders.Add(folderInfo.folderID, new InventoryFolder(folderInfo)); + folder.SubFolders.Add(folderInfo.folderID, folderInfo); } } } @@ -131,7 +131,3 @@ namespace OpenSim.Framework.Communications.Caches } - - - - diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index a212614..885cffc 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -35,9 +35,6 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Data; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; - -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications.Caches { @@ -63,7 +60,7 @@ namespace OpenSim.Framework.Communications.Caches } // Methods - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type, InventoryCategory category) + public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { InventoryFolder subFold = new InventoryFolder(); subFold.name = folderName; @@ -71,12 +68,7 @@ namespace OpenSim.Framework.Communications.Caches subFold.type = (short) type; subFold.parentID = this.folderID; subFold.agentID = this.agentID; - subFold.category = category; - if (!SubFolders.ContainsKey(subFold.folderID)) - this.SubFolders.Add(subFold.folderID, subFold); - else - MainLog.Instance.Warn("INVENTORYCACHE", "Attempt to create a duplicate folder {0} {1}", folderName, folderID); - + this.SubFolders.Add(subFold.folderID, subFold); return subFold; } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 3dadf9c..390b938 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -35,11 +35,10 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Data; -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications.Caches { - public class UserProfileCache : MarshalByRefObject + public class UserProfileCache { // Fields private CommunicationsManager m_parent; @@ -104,7 +103,7 @@ namespace OpenSim.Framework.Communications.Caches CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType, InventoryCategory.User); + InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); if (createdFolder != null) { this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); @@ -115,7 +114,7 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); if (folder != null) { - folder.CreateNewSubFolder(folderID, folderName, folderType, InventoryCategory.User); + folder.CreateNewSubFolder(folderID, folderName, folderType); } } } @@ -125,21 +124,16 @@ namespace OpenSim.Framework.Communications.Caches public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { InventoryFolder fold = null; - if (folderID == libraryRoot.folderID ) { - // we are looking for the root of the shared inventory remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); } else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) { - // we are looking for a sub folder of the shared inventory remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); } else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) { - //if we get here, we are looking the inventory of an agent in this sim - //now we need to see if we already have the inventory cached if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) { CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; @@ -159,23 +153,9 @@ namespace OpenSim.Framework.Communications.Caches } } } - else - { - //nope, inventory wasn't cached, so go to the inventory server and ask for the inventory - m_parent.InventoryService.RequestInventoryForUser(remoteClient.AgentId, ReceiveFolderInfo, ReceiveItemInfo); - } } } - public void ReceiveFolderInfo(LLUUID userID, InventoryFolderBase folderInfo) - { - } - - public void ReceiveItemInfo(LLUUID userID, InventoryItemBase itemInfo) - { - } - - public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) { if (ownerID == libraryRoot.agentID) @@ -201,7 +181,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -241,7 +221,3 @@ namespace OpenSim.Framework.Communications.Caches } } - - - - diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 7b2948f..80c2e64 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,31 +1,29 @@ using System; -using System.Text; using System.Collections.Generic; - -using libsecondlife; +using System.Text; using OpenSim.Framework.Data; +using libsecondlife; using OpenSim.Framework.Communications.Caches; +using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications { - public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderBase folderInfo); + public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); - void CreateNewUserInventory(LLUUID libraryRootId, LLUUID user); - void GetRootFoldersForUser(LLUUID user, out LLUUID libraryFolder, out LLUUID personalFolder); + void CreateNewUserInventory(LLUUID user); /// /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) /// /// /// - List RequestFirstLevelFolders(LLUUID folderID); - List RequestFolderItems(LLUUID folderID); + List RequestFirstLevelFolders(LLUUID userID); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 6283b60..da7a0ce 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -1,9 +1,4 @@ using System; -using System.Text; -using System.IO; -using System.Xml; -using System.Xml.Serialization; -using System.Collections; using System.Collections.Generic; using System.Reflection; using libsecondlife; @@ -11,20 +6,21 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; namespace OpenSim.Framework.Communications { - public abstract class InventoryServiceBase : MarshalByRefObject, IInventoryServices + public abstract class InventoryServiceBase : IInventoryServices { - protected IInventoryData _databasePlugin; + protected Dictionary m_plugins = new Dictionary(); + //protected IAssetServer m_assetServer; public InventoryServiceBase() { + //m_assetServer = assetServer; } /// - /// Adds a new inventory data server plugin + /// 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) @@ -45,13 +41,8 @@ namespace OpenSim.Framework.Communications IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - this._databasePlugin = plug; - - //TODO! find a better place to create inventory skeletons - loadInventoryFromXmlFile(InventoryCategory.Library, "Inventory_Library.xml"); - loadInventoryFromXmlFile(InventoryCategory.Default, "Inventory_Default.xml"); + this.m_plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); - break; } } } @@ -63,20 +54,20 @@ namespace OpenSim.Framework.Communications /// /// /// - public List RequestFirstLevelFolders(LLUUID folderID) + public List RequestFirstLevelFolders(LLUUID userID) { - InventoryFolderBase root = _databasePlugin.getInventoryFolder(folderID); - - List folders = new List(); - if (root != null) + List inventoryList = new List(); + foreach (KeyValuePair plugin in m_plugins) { - folders.Add(root); - - List subFolders = _databasePlugin.getInventoryFolders(root.folderID); - foreach (InventoryFolderBase f in subFolders) - folders.Add(f); + InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID); + if (rootFolder != null) + { + inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); + inventoryList.Insert(0, rootFolder); + return inventoryList; + } } - return folders; + return inventoryList; } /// @@ -84,7 +75,11 @@ namespace OpenSim.Framework.Communications /// public InventoryFolderBase RequestUsersRoot(LLUUID userID) { - return _databasePlugin.getInventoryFolder(userID); // the id of the root folder, is the user id + foreach (KeyValuePair plugin in m_plugins) + { + return plugin.Value.getUserRootFolder(userID); + } + return null; } /// @@ -94,27 +89,47 @@ namespace OpenSim.Framework.Communications /// public List RequestSubFolders(LLUUID parentFolderID) { - return _databasePlugin.getInventoryFolders(parentFolderID); + List inventoryList = new List(); + foreach (KeyValuePair plugin in m_plugins) + { + return plugin.Value.getInventoryFolders(parentFolderID); + } + return inventoryList; } public List RequestFolderItems(LLUUID folderID) { - return _databasePlugin.getInventoryInFolder(folderID); + List itemsList = new List(); + foreach (KeyValuePair plugin in m_plugins) + { + itemsList = plugin.Value.getInventoryInFolder(folderID); + return itemsList; + } + return itemsList; } public void AddFolder(InventoryFolderBase folder) { - _databasePlugin.addInventoryFolder(folder); + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.addInventoryFolder(folder); + } } public void AddItem(InventoryItemBase item) { - _databasePlugin.addInventoryItem(item); + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.addInventoryItem(item); + } } public void deleteItem(InventoryItemBase item) { - _databasePlugin.deleteInventoryItem(item); + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.deleteInventoryItem(item); + } } /// @@ -129,53 +144,11 @@ namespace OpenSim.Framework.Communications } } - public void CreateNewUserInventory(LLUUID defaultFolders, LLUUID user) + public void CreateNewUserInventory(LLUUID user) { - try - { - // Get Default folder set from the database - //TODO! We need to get the whole hierachy and not just one level down - List folders = this.RequestFirstLevelFolders(LLUUID.Parse("00000112-000f-0000-0000-000100bba000")); - - // create an index list, where each of the elements has the index of its parent in the hierachy - // this algorithm is pretty shoddy O(n^2), but it is only executed once per user. - int[] parentIdx = new int[folders.Count]; - for (int i = 0; i < folders.Count; i++) - parentIdx[i] = -1; - - for (int i = 0; i < folders.Count; i++) - for (int j = 0; j < folders.Count; j++) - if (folders[i].folderID == folders[j].parentID) - parentIdx[j] = i; - - - //assign a new owerid and a new to the folders - foreach (InventoryFolderBase ifb in folders) - { - if (ifb.parentID == LLUUID.Zero) - ifb.folderID = user; - else - ifb.folderID = LLUUID.Random(); - - ifb.agentID = user; - ifb.category = InventoryCategory.User; - } - - // correct the parent id - for (int i = 0; i < folders.Count; i++) - { - if (folders[i].parentID != LLUUID.Zero) - folders[i].parentID = folders[parentIdx[i]].folderID; // root folder id is the same as the user id - } - - // the list is structurally sound, using new folder id's, so save it - foreach (InventoryFolderBase ifb in folders) - _databasePlugin.addInventoryFolder(ifb); - } - catch (Exception e) - { - MainLog.Instance.Error(e.ToString()); - } + UsersInventory inven = new UsersInventory(); + inven.CreateNewInventorySet(user); + this.AddNewInventorySet(inven); } public class UsersInventory @@ -193,11 +166,10 @@ namespace OpenSim.Framework.Communications InventoryFolderBase folder = new InventoryFolderBase(); folder.parentID = LLUUID.Zero; folder.agentID = user; - folder.folderID = user; // id of root folder is the same as the agent id + folder.folderID = LLUUID.Random(); folder.name = "My Inventory"; folder.type = 8; folder.version = 1; - folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); LLUUID rootFolder = folder.folderID; @@ -209,7 +181,6 @@ namespace OpenSim.Framework.Communications folder.name = "Textures"; folder.type = 0; folder.version = 1; - folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); folder = new InventoryFolderBase(); @@ -219,7 +190,6 @@ namespace OpenSim.Framework.Communications folder.name = "Objects"; folder.type = 6; folder.version = 1; - folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); folder = new InventoryFolderBase(); @@ -229,130 +199,13 @@ namespace OpenSim.Framework.Communications folder.name = "Clothes"; folder.type = 5; folder.version = 1; - folder.category = InventoryCategory.User; Folders.Add(folder.folderID, folder); } } - - public void GetRootFoldersForUser(LLUUID user, out LLUUID libraryFolder, out LLUUID personalFolder) - { - List folders = _databasePlugin.getUserRootFolders(user); - libraryFolder = LLUUID.Zero; - personalFolder = LLUUID.Zero; - - for (int i = 0; i < folders.Count; i++) - { - if (folders[i].category == InventoryCategory.Library) - libraryFolder = folders[i].folderID; - else if (folders[i].category == InventoryCategory.User) - personalFolder = folders[i].folderID; - } - } - - /* - * Dot net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder - * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize - * into this simpler class, and then use that. - */ - [XmlRoot(ElementName = "inventory", IsNullable = true)] - public class SerializedInventory - { - [XmlRoot(ElementName = "folder", IsNullable = true)] - public class SerializedFolder : InventoryFolderBase - { - [XmlArray(ElementName = "folders", IsNullable = true)] - [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof(SerializedFolder))] - public ArrayList SubFolders; - - [XmlArray(ElementName = "items", IsNullable = true)] - [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof(InventoryItemBase))] - public ArrayList Items; - } - - [XmlElement(ElementName = "folder", IsNullable = true)] - public SerializedFolder root; - } - - public void uploadInventory(SerializedInventory.SerializedFolder folder) - { - foreach (InventoryItemBase iib in folder.Items) - { - // assign default values, if they haven't assigned - iib.avatarID = folder.agentID; - if (iib.assetID == LLUUID.Zero) - iib.assetID = LLUUID.Random(); - if (iib.creatorsID == LLUUID.Zero) - iib.creatorsID = folder.agentID; - if (iib.inventoryID == LLUUID.Zero) - iib.inventoryID = LLUUID.Random(); - if (iib.inventoryName == null || iib.inventoryName.Length == 0) - iib.inventoryName = "new item"; - iib.parentFolderID = folder.folderID; - - _databasePlugin.addInventoryItem(iib); - } - - foreach (SerializedInventory.SerializedFolder sf in folder.SubFolders) - { - // assign default values, if they haven't assigned - sf.agentID = folder.agentID; - sf.category = folder.category; - if (sf.folderID == LLUUID.Zero) - sf.folderID = LLUUID.Random(); - if (sf.name == null || sf.name.Length == 0) - sf.name = "new folder"; - sf.parentID = folder.folderID; - - _databasePlugin.addInventoryFolder(sf); - uploadInventory(sf); - } - } - - public void loadInventoryFromXmlFile(InventoryCategory inventoryCategory, string fileName) - { - _databasePlugin.deleteInventoryCategory(inventoryCategory); - - FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); - XmlReader reader = new XmlTextReader(fs); - XmlSerializer x = new XmlSerializer(typeof(SerializedInventory)); - SerializedInventory inventory = (SerializedInventory)x.Deserialize(reader); - - // the library and default inventories has no owner, so we use a random guid. - if (inventory.root.category == InventoryCategory.Library || inventory.root.category == InventoryCategory.Default) - { - if (inventory.root.folderID != LLUUID.Zero) - inventory.root.agentID = inventory.root.folderID; - else - inventory.root.agentID = LLUUID.Random(); - } - else if (inventory.root.category == InventoryCategory.User) - { - if (inventory.root.agentID == LLUUID.Zero) - inventory.root.agentID = LLUUID.Random(); - } - - inventory.root.folderID = inventory.root.agentID; // the root folder always has the same id as the owning agent - inventory.root.parentID = LLUUID.Zero; - inventory.root.version = 0; - inventory.root.category = inventoryCategory; - - _databasePlugin.addInventoryFolder(inventory.root); - uploadInventory(inventory.root); - } - - protected void saveInventoryToXmlFile(SerializedInventory inventory, string fileName) - { - FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); - XmlTextWriter writer = new XmlTextWriter(fs, Encoding.UTF8); - writer.Formatting = Formatting.Indented; - XmlSerializer x = new XmlSerializer(typeof(SerializedInventory)); - x.Serialize(writer, inventory); - } - public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b4280e7..b5a4184 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -26,10 +26,9 @@ namespace OpenSim.Framework.UserManagement private ArrayList classifiedCategories; private ArrayList inventoryRoot; private ArrayList initialOutfit; - private ArrayList inventorySkeleton; + private ArrayList agentInventory; private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibraryRoot; - private ArrayList inventoryLibrarySkeleton; + private ArrayList inventoryLibrary; private UserInfo userProfile; @@ -87,13 +86,11 @@ namespace OpenSim.Framework.UserManagement this.defaultXmlRpcResponse = new XmlRpcResponse(); this.userProfile = new UserInfo(); - - this.initialOutfit = new ArrayList(); this.inventoryRoot = new ArrayList(); - this.inventorySkeleton = new ArrayList(); - this.inventoryLibrarySkeleton = new ArrayList(); + this.initialOutfit = new ArrayList(); + this.agentInventory = new ArrayList(); + this.inventoryLibrary = new ArrayList(); this.inventoryLibraryOwner = new ArrayList(); - this.inventoryLibraryRoot = new ArrayList(); this.xmlRpcResponse = new XmlRpcResponse(); this.defaultXmlRpcResponse = new XmlRpcResponse(); @@ -240,15 +237,12 @@ namespace OpenSim.Framework.UserManagement responseData["classified_categories"] = this.classifiedCategories; responseData["ui-config"] = this.uiConfig; - responseData["inventory-skeleton"] = this.inventorySkeleton; - responseData["inventory-skel-lib"] = this.inventoryLibrarySkeleton; + responseData["inventory-skeleton"] = this.agentInventory; + responseData["inventory-skel-lib"] = this.inventoryLibrary; responseData["inventory-root"] = this.inventoryRoot; - responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; - responseData["inventory-lib-root"] = this.inventoryLibraryRoot; - responseData["gestures"] = new ArrayList(); // todo + responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; responseData["initial-outfit"] = this.initialOutfit; - responseData["start_location"] = this.startLocation; responseData["seed_capability"] = this.seedCapability; responseData["home"] = this.home; @@ -602,23 +596,23 @@ namespace OpenSim.Framework.UserManagement { get { - return this.inventorySkeleton; + return this.agentInventory; } set { - this.inventorySkeleton = value; + this.agentInventory = value; } } - public ArrayList InventoryLibrarySkeleton + public ArrayList InventoryLibrary { get { - return this.inventoryLibrarySkeleton; + return this.inventoryLibrary; } set { - this.inventoryLibrarySkeleton = value; + this.inventoryLibrary = value; } } @@ -634,18 +628,6 @@ namespace OpenSim.Framework.UserManagement } } - public ArrayList InventoryLibraryRoot - { - get - { - return this.inventoryLibraryRoot; - } - set - { - this.inventoryLibraryRoot = value; - } - } - public string Home { get @@ -683,7 +665,3 @@ namespace OpenSim.Framework.UserManagement } } - - - - diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 4e6aa80..8e7cf80 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -8,10 +8,11 @@ using Nwc.XmlRpc; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Configuration; +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; namespace OpenSim.Framework.UserManagement { @@ -19,12 +20,10 @@ namespace OpenSim.Framework.UserManagement { protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; - protected IInventoryServices m_inventoryServer = null; - public LoginService(UserManagerBase userManager, IInventoryServices inventoryServer, string welcomeMess) + public LoginService(UserManagerBase userManager, string welcomeMess) { m_userManager = userManager; - m_inventoryServer = inventoryServer; if (welcomeMess != "") { m_welcomeMessage = welcomeMess; @@ -38,6 +37,7 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { + System.Console.WriteLine("Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; @@ -85,41 +85,15 @@ namespace OpenSim.Framework.UserManagement { LLUUID agentID = userProfile.UUID; - LLUUID libraryFolderID; - LLUUID personalFolderID; - - m_inventoryServer.GetRootFoldersForUser(agentID, out libraryFolderID, out personalFolderID); - if (personalFolderID == LLUUID.Zero) - { - m_inventoryServer.CreateNewUserInventory(libraryFolderID, agentID); - m_inventoryServer.GetRootFoldersForUser(agentID, out libraryFolderID, out personalFolderID); - } - - // The option "inventory-lib-owner" requires that we return the id of the - // owner of the library inventory. - Hashtable dynamicStruct = new Hashtable(); - dynamicStruct["agent_id"] = libraryFolderID.ToStringHyphenated(); - logResponse.InventoryLibraryOwner.Add(dynamicStruct); - - // The option "inventory-lib-root" requires that we return the id of the - // root folder of the library inventory. - dynamicStruct = new Hashtable(); - dynamicStruct["folder_id"] = libraryFolderID.ToStringHyphenated(); - logResponse.InventoryLibraryRoot.Add(dynamicStruct); + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; - // The option "inventory-root" requires that we return the id of the - // root folder of the users inventory. - dynamicStruct = new Hashtable(); - dynamicStruct["folder_id"] = personalFolderID.ToStringHyphenated(); - logResponse.InventoryRoot.Add(dynamicStruct); - - // The option "inventory-skeleton" requires that we return the structure of the - // users folder hierachy - logResponse.InventorySkeleton = GetInventorySkeleton(personalFolderID); - - // The option "inventory-skel-lib" requires that we return the structure of the - // library folder hierachy - logResponse.InventoryLibrarySkeleton = GetInventorySkeleton(libraryFolderID); + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); @@ -129,6 +103,10 @@ namespace OpenSim.Framework.UserManagement logResponse.AgentID = agentID.ToStringHyphenated(); logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten @@ -234,30 +212,76 @@ namespace OpenSim.Framework.UserManagement } /// - /// Create a structure of the generic inventory structure of a specified folder + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// /// /// - protected virtual ArrayList GetInventorySkeleton(LLUUID folderID) + protected virtual ArrayList GetLibraryOwner() { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } - List folders = m_inventoryServer.RequestFirstLevelFolders(folderID); + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); - ArrayList temp = new ArrayList(); - foreach (InventoryFolderBase ifb in folders) + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) { - LLUUID tempFolderID = ifb.folderID; - LLUUID tempParentID = ifb.parentID; - - Hashtable TempHash = new Hashtable(); - TempHash["folder_id"] = tempFolderID.ToStringHyphenated(); - TempHash["name"] = ifb.name; - TempHash["parent_id"] = tempParentID.ToStringHyphenated(); - TempHash["type_default"] = (Int32)ifb.type; - TempHash["version"] = (Int32)ifb.version+1; - temp.Add(TempHash); + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); } - return temp; + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } } } } -- cgit v1.1 From 9b1eefbcdeb21e42e0feb5336c0a084def2b4aa8 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 3 Oct 2007 06:20:00 +0000 Subject: Some continuation of lbsa71's refactoring of the CommunicationsManager. --- .../Communications/CommunicationsManager.cs | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6ea3c29..cd5d901 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Caches; @@ -32,6 +33,8 @@ using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; +using OpenSim.Framework.Console; +using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications { @@ -93,6 +96,58 @@ namespace OpenSim.Framework.Communications m_transactionsManager = new AssetTransactionManager(this); } + public void doCreate(string[] cmmdParams) + { + switch (cmmdParams[0]) + { + case "user": + string firstName; + string lastName; + string password; + uint regX = 1000; + uint regY = 1000; + + if (cmmdParams.Length < 2) + { + + firstName = MainLog.Instance.CmdPrompt("First name", "Default"); + lastName = MainLog.Instance.CmdPrompt("Last name", "User"); + password = MainLog.Instance.PasswdPrompt("Password"); + regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000")); + regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000")); + } + else + { + firstName = cmmdParams[1]; + lastName = cmmdParams[2]; + password = cmmdParams[3]; + regX = Convert.ToUInt32(cmmdParams[4]); + regY = Convert.ToUInt32(cmmdParams[5]); + + } + + AddUser(firstName, lastName, password, regX, regY); + break; + } + } + + public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) + { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + ""); + + m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); + UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); + if (userProf == null) + { + return LLUUID.Zero; + } + else + { + this.m_inventoryService.CreateNewUserInventory(userProf.UUID); + System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); + return userProf.UUID; + } + } #region Packet Handlers -- cgit v1.1 From 10c36a2573caefaf653f18b0b60403a9a597a348 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 5 Oct 2007 09:41:41 +0000 Subject: * Renamed IUserServices to IUserService --- .../Communications/CommunicationsManager.cs | 4 +- OpenSim/Framework/Communications/IUserService.cs | 49 ++++++++++++++++++++++ OpenSim/Framework/Communications/IUserServices.cs | 49 ---------------------- .../Framework/Communications/UserManagerBase.cs | 2 +- 4 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 OpenSim/Framework/Communications/IUserService.cs delete mode 100644 OpenSim/Framework/Communications/IUserServices.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index cd5d901..e266b90 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -40,8 +40,8 @@ namespace OpenSim.Framework.Communications { public class CommunicationsManager { - protected IUserServices m_userService; - public IUserServices UserService + protected IUserService m_userService; + public IUserService UserService { get { return m_userService; } } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs new file mode 100644 index 0000000..55c006f --- /dev/null +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using libsecondlife; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.Communications +{ + public interface IUserService + { + UserProfileData GetUserProfile(string firstName, string lastName); + UserProfileData GetUserProfile(string name); + UserProfileData GetUserProfile(LLUUID avatarID); + void clearUserAgent(LLUUID avatarID); + + UserProfileData SetupMasterUser(string firstName, string lastName); + UserProfileData SetupMasterUser(string firstName, string lastName, string password); + + /// + /// + /// + /// + void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + } +} diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs deleted file mode 100644 index 13dd378..0000000 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using libsecondlife; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications -{ - public interface IUserServices - { - UserProfileData GetUserProfile(string firstName, string lastName); - UserProfileData GetUserProfile(string name); - UserProfileData GetUserProfile(LLUUID avatarID); - void clearUserAgent(LLUUID avatarID); - - UserProfileData SetupMasterUser(string firstName, string lastName); - UserProfileData SetupMasterUser(string firstName, string lastName, string password); - - /// - /// - /// - /// - void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); - } -} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d1bbde1..4dad82e 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -41,7 +41,7 @@ using OpenSim.Framework.Utilities; namespace OpenSim.Framework.UserManagement { - public abstract class UserManagerBase : IUserServices + public abstract class UserManagerBase : IUserService { public UserConfig _config; Dictionary _plugins = new Dictionary(); -- cgit v1.1 From 342a813bd70056946cefefc772a833778cb55729 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 5 Oct 2007 09:45:39 +0000 Subject: * Moved IUserService to OpenSim.Framework.Interfaces --- OpenSim/Framework/Communications/IUserService.cs | 49 ---------------------- .../Framework/Communications/UserManagerBase.cs | 2 +- 2 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IUserService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs deleted file mode 100644 index 55c006f..0000000 --- a/OpenSim/Framework/Communications/IUserService.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using libsecondlife; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications -{ - public interface IUserService - { - UserProfileData GetUserProfile(string firstName, string lastName); - UserProfileData GetUserProfile(string name); - UserProfileData GetUserProfile(LLUUID avatarID); - void clearUserAgent(LLUUID avatarID); - - UserProfileData SetupMasterUser(string firstName, string lastName); - UserProfileData SetupMasterUser(string firstName, string lastName, string password); - - /// - /// - /// - /// - void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); - } -} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 4dad82e..bbda054 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -33,10 +33,10 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework.Communications; using OpenSim.Framework.Configuration; using OpenSim.Framework.Console; using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; using OpenSim.Framework.Utilities; namespace OpenSim.Framework.UserManagement -- cgit v1.1 From 5a6552120395611e66a88821ce848a06c9ea4720 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 5 Oct 2007 10:14:42 +0000 Subject: == The "right name and place" commit == * Moved InventoryData to Framework.Types/InventoryItemBase.cs * Moved UserData to Framework.Interfaces/IUserData.cs * Moved UserProfileData to Framework/Types/UserProfileData.cs * Deleted ass-backwards Framework dependency on Framework.Data (now it's the other way round) * Changed some namespaces to reflect file structure --- .../Communications/Cache/AssetTransactions.cs | 2 +- .../Framework/Communications/Cache/CachedUserInfo.cs | 18 ++++-------------- .../Framework/Communications/Cache/InventoryFolder.cs | 1 - .../Communications/Cache/LibraryRootFolder.cs | 2 +- .../Framework/Communications/Cache/UserProfileCache.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 - .../Framework/Communications/CommunicationsManager.cs | 1 - OpenSim/Framework/Communications/IInventoryServices.cs | 2 +- .../Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- OpenSim/Framework/Communications/UserManagerBase.cs | 1 + 11 files changed, 11 insertions(+), 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index d0507d0..51fc462 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -32,10 +32,10 @@ using System.Text; using System.IO; using libsecondlife; using libsecondlife.Packets; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 99dc45a..b1432ff 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -25,22 +25,15 @@ * 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.Interfaces; using OpenSim.Framework.Types; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; +using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class CachedUserInfo { - private CommunicationsManager m_parentCommsManager; + private readonly CommunicationsManager m_parentCommsManager; // Fields public InventoryFolder RootFolder = null; public UserProfileData UserProfile = null; @@ -127,7 +120,4 @@ namespace OpenSim.Framework.Communications.Caches return result; } } - - -} - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 885cffc..fbe1bd0 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -32,7 +32,6 @@ using System.Text; using System.IO; using libsecondlife; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Data; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index deef028..38fad68 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -3,8 +3,8 @@ using System.IO; using System.Collections.Generic; using System.Text; using libsecondlife; +using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; using Nini.Config; namespace OpenSim.Framework.Communications.Caches diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 390b938..9e32ea5 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -31,10 +31,10 @@ using System.Collections.Generic; using System.Text; using System.IO; using libsecondlife; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; namespace OpenSim.Framework.Communications.Caches { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 59c6d7c..4ed59c7 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -35,7 +35,6 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities { diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e266b90..5af07f7 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -29,7 +29,6 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Caches; -using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 80c2e64..980bb27 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Text; -using OpenSim.Framework.Data; using libsecondlife; using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Types; using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index da7a0ce..7536429 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -4,7 +4,7 @@ using System.Reflection; using libsecondlife; using OpenSim.Framework.Communications; using OpenSim.Framework.Console; -using OpenSim.Framework.Data; +using OpenSim.Framework.Types; using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8e7cf80..06abb69 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -6,9 +6,9 @@ using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Inventory; +using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Configuration; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bbda054..56ed959 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -37,6 +37,7 @@ using OpenSim.Framework.Configuration; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; namespace OpenSim.Framework.UserManagement -- cgit v1.1 From ed6168b96b687a2f44177af8200d13b427089099 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 5 Oct 2007 11:27:46 +0000 Subject: * UserProfileData meets code conventions --- .../Communications/CommunicationsManager.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 572 ++++++++++----------- .../Framework/Communications/UserManagerBase.cs | 32 +- 3 files changed, 304 insertions(+), 304 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5af07f7..010d5ce 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -162,8 +162,8 @@ namespace OpenSim.Framework.Communications if (profileData != null) { LLUUID profileId = profileData.UUID; - string firstname = profileData.username; - string lastname = profileData.surname; + string firstname = profileData.Firstname; + string lastname = profileData.Lastname; remote_client.SendNameReply(profileId, firstname, lastname); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 06abb69..31c9363 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,287 +1,287 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - -namespace OpenSim.Framework.UserManagement -{ - public class LoginService - { - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected UserManagerBase m_userManager = null; - - public LoginService(UserManagerBase userManager, string welcomeMess) - { - m_userManager = userManager; - if (welcomeMess != "") - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - - System.Console.WriteLine("Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - if (GoodXML) - { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); - - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } - - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) - { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - - try - { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); - - try - { - this.CustomiseResponse(logResponse, userProfile); - } - catch (Exception e) - { - System.Console.WriteLine(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); - } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); - - } - - catch (Exception E) - { - System.Console.WriteLine(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - - MainLog.Instance.Verbose( - "Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - this.m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return this.m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - } -} +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) + { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + System.Console.WriteLine("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderId = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.Lastname; + logResponse.Firstname = userProfile.Firstname; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + System.Console.WriteLine(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) + { + System.Console.WriteLine(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.Firstname + " " + profile.Lastname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + + return profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 56ed959..d04101c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.UserManagement try { UserProfileData profile = plugin.Value.GetUserByUUID(uuid); - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.UUID); return profile; } catch (Exception e) @@ -121,7 +121,7 @@ namespace OpenSim.Framework.UserManagement try { UserProfileData profile = plugin.Value.GetUserByName(name); - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.UUID); return profile; } catch (Exception e) @@ -148,7 +148,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData profile = plugin.Value.GetUserByName(fname,lname); - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.UUID); return profile; } @@ -233,7 +233,7 @@ namespace OpenSim.Framework.UserManagement public void clearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); - profile.currentAgent = null; + profile.CurrentAgent = null; setUserProfile(profile); } @@ -292,8 +292,8 @@ namespace OpenSim.Framework.UserManagement agent.UUID = profile.UUID; // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; + agent.currentHandle = profile.HomeRegion; + agent.currentPos = profile.HomeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) @@ -326,7 +326,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = new LLUUID(); // Fill in later agent.currentRegion = new LLUUID(); // Fill in later - profile.currentAgent = agent; + profile.CurrentAgent = agent; } /// @@ -349,16 +349,16 @@ namespace OpenSim.Framework.UserManagement public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); - user.homeLocation = new LLVector3(128, 128, 100); + user.HomeLocation = new LLVector3(128, 128, 100); user.UUID = LLUUID.Random(); - user.username = firstName; - user.surname = lastName; - user.passwordHash = pass; - user.passwordSalt = ""; - user.created = Util.UnixTimeSinceEpoch(); - user.homeLookAt = new LLVector3(100, 100, 100); - user.homeRegionX = regX; - user.homeRegionY = regY; + user.Firstname = firstName; + user.Lastname = lastName; + user.PasswordHash = pass; + user.PasswordSalt = ""; + user.Created = Util.UnixTimeSinceEpoch(); + user.HomeLookAt = new LLVector3(100, 100, 100); + user.HomeRegionX = regX; + user.HomeRegionY = regY; foreach (KeyValuePair plugin in _plugins) { -- cgit v1.1 From d4a4aafaf15360c0f5db22145a60bae87e6bb9c6 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 5 Oct 2007 13:54:16 +0000 Subject: * So, ok, maybe renaming serialized fields on a friday wasn't the smartest of things. Reverting 2056. --- .../Communications/CommunicationsManager.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 572 ++++++++++----------- .../Framework/Communications/UserManagerBase.cs | 32 +- 3 files changed, 304 insertions(+), 304 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 010d5ce..5af07f7 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -162,8 +162,8 @@ namespace OpenSim.Framework.Communications if (profileData != null) { LLUUID profileId = profileData.UUID; - string firstname = profileData.Firstname; - string lastname = profileData.Lastname; + string firstname = profileData.username; + string lastname = profileData.surname; remote_client.SendNameReply(profileId, firstname, lastname); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 31c9363..06abb69 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,287 +1,287 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - -namespace OpenSim.Framework.UserManagement -{ - public class LoginService - { - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected UserManagerBase m_userManager = null; - - public LoginService(UserManagerBase userManager, string welcomeMess) - { - m_userManager = userManager; - if (welcomeMess != "") - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - - System.Console.WriteLine("Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - if (GoodXML) - { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); - - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } - - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) - { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - - try - { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderId = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.Lastname; - logResponse.Firstname = userProfile.Firstname; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); - - try - { - this.CustomiseResponse(logResponse, userProfile); - } - catch (Exception e) - { - System.Console.WriteLine(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); - } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); - - } - - catch (Exception E) - { - System.Console.WriteLine(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - - MainLog.Instance.Verbose( - "Authenticating " + profile.Firstname + " " + profile.Lastname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - - return profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - this.m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return this.m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - } -} +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) + { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + System.Console.WriteLine("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + System.Console.WriteLine(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) + { + System.Console.WriteLine(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d04101c..56ed959 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.UserManagement try { UserProfileData profile = plugin.Value.GetUserByUUID(uuid); - profile.CurrentAgent = getUserAgent(profile.UUID); + profile.currentAgent = getUserAgent(profile.UUID); return profile; } catch (Exception e) @@ -121,7 +121,7 @@ namespace OpenSim.Framework.UserManagement try { UserProfileData profile = plugin.Value.GetUserByName(name); - profile.CurrentAgent = getUserAgent(profile.UUID); + profile.currentAgent = getUserAgent(profile.UUID); return profile; } catch (Exception e) @@ -148,7 +148,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData profile = plugin.Value.GetUserByName(fname,lname); - profile.CurrentAgent = getUserAgent(profile.UUID); + profile.currentAgent = getUserAgent(profile.UUID); return profile; } @@ -233,7 +233,7 @@ namespace OpenSim.Framework.UserManagement public void clearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); - profile.CurrentAgent = null; + profile.currentAgent = null; setUserProfile(profile); } @@ -292,8 +292,8 @@ namespace OpenSim.Framework.UserManagement agent.UUID = profile.UUID; // Current position (from Home) - agent.currentHandle = profile.HomeRegion; - agent.currentPos = profile.HomeLocation; + agent.currentHandle = profile.homeRegion; + agent.currentPos = profile.homeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) @@ -326,7 +326,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = new LLUUID(); // Fill in later agent.currentRegion = new LLUUID(); // Fill in later - profile.CurrentAgent = agent; + profile.currentAgent = agent; } /// @@ -349,16 +349,16 @@ namespace OpenSim.Framework.UserManagement public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); - user.HomeLocation = new LLVector3(128, 128, 100); + user.homeLocation = new LLVector3(128, 128, 100); user.UUID = LLUUID.Random(); - user.Firstname = firstName; - user.Lastname = lastName; - user.PasswordHash = pass; - user.PasswordSalt = ""; - user.Created = Util.UnixTimeSinceEpoch(); - user.HomeLookAt = new LLVector3(100, 100, 100); - user.HomeRegionX = regX; - user.HomeRegionY = regY; + user.username = firstName; + user.surname = lastName; + user.passwordHash = pass; + user.passwordSalt = ""; + user.created = Util.UnixTimeSinceEpoch(); + user.homeLookAt = new LLVector3(100, 100, 100); + user.homeRegionX = regX; + user.homeRegionY = regY; foreach (KeyValuePair plugin in _plugins) { -- cgit v1.1 From c3d8f1f4253f72484100394940e62f2912cbc4ff Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 5 Oct 2007 15:45:45 +0000 Subject: getting all our line endings consistant again --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 06abb69..fddfb17 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -8,7 +8,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Inventory; -using OpenSim.Framework.Types; +using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Configuration; -- cgit v1.1 From 4c25008850f92bcc79502c71a0e4d34c883d27d0 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 8 Oct 2007 10:30:15 +0000 Subject: Applied patch 485, inventory patch from tleiades (thanks again). --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 7536429..366b110 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.Communications { foreach (KeyValuePair plugin in m_plugins) { - plugin.Value.deleteInventoryItem(item); + plugin.Value.deleteInventoryItem(item.inventoryID); } } @@ -208,4 +208,4 @@ namespace OpenSim.Framework.Communications public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} \ No newline at end of file +} -- cgit v1.1 From e41b0feb5895365e8f4b41b13facf6d07e6a6a44 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 12 Oct 2007 13:50:11 +0000 Subject: Turn a few of the writelines into mainlog entries so failed logins can be more easily analyzed. --- OpenSim/Framework/Communications/LoginService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index fddfb17..029c0a6e 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -36,9 +36,9 @@ namespace OpenSim.Framework.UserManagement /// The XMLRPC request /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - - System.Console.WriteLine("Attempting login now..."); + { + + MainLog.Instance.Verbose("Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; @@ -121,8 +121,8 @@ namespace OpenSim.Framework.UserManagement this.CustomiseResponse(logResponse, userProfile); } catch (Exception e) - { - System.Console.WriteLine(e.ToString()); + { + MainLog.Instance.Verbose(e.ToString()); return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } @@ -132,8 +132,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception E) - { - System.Console.WriteLine(E.ToString()); + { + MainLog.Instance.Verbose(E.ToString()); } //} } -- cgit v1.1 From 4c8d1755640b2bc299cf3378ca9f79ca054e2978 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 12 Oct 2007 19:31:29 +0000 Subject: I broke the build and am reverting until I can get the MainLog call proper. --- OpenSim/Framework/Communications/LoginService.cs | 566 +++++++++++------------ 1 file changed, 283 insertions(+), 283 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 029c0a6e..8778f6f 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,287 +1,287 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - -namespace OpenSim.Framework.UserManagement -{ - public class LoginService - { - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected UserManagerBase m_userManager = null; - - public LoginService(UserManagerBase userManager, string welcomeMess) - { - m_userManager = userManager; - if (welcomeMess != "") - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + MainLog.Instance.Verbose("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); - MainLog.Instance.Verbose("Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - if (GoodXML) - { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); - - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } - - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) - { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - - try - { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); - - try - { - this.CustomiseResponse(logResponse, userProfile); - } - catch (Exception e) + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) { - MainLog.Instance.Verbose(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); - } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); - - } - - catch (Exception E) + MainLog.Instance.Verbose(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) { - MainLog.Instance.Verbose(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - - MainLog.Instance.Verbose( - "Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - this.m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return this.m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - } -} + MainLog.Instance.Verbose(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} -- cgit v1.1 From 1232eb1c587ffdc06c26a1c5b1b4fa5f22848754 Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Sat, 13 Oct 2007 07:26:21 +0000 Subject: Asset server implementation. Again one of these "plumbing" releases, where no real functionality has been introduced, but ground work has been made, enabling the asset server, and preparing the sim server to query the asset server. Introduced an "IPlugin" interface, which plugins can inherit from. --- .../Communications/Cache/SQLAssetServer.cs | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index a64d195..2a38307 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,16 +44,16 @@ namespace OpenSim.Framework.Communications.Caches private IAssetReceiver _receiver; private BlockingQueue _assetRequests; private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; + protected IAssetProvider m_assetProviderPlugin; private object syncLock = new object(); - public SQLAssetServer() + public SQLAssetServer(string pluginName) { - System.Console.WriteLine("Starting sqlite asset storage system"); - _assetRequests = new BlockingQueue(); - AddPlugin("OpenSim.Framework.Data.SQLite.dll"); - this.SetUpAssetDatabase(); + _assetRequests = new BlockingQueue(); + AddPlugin(pluginName); + + SetUpAssetDatabase(); this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); this._localAssetServerThread.IsBackground = true; @@ -63,7 +63,7 @@ namespace OpenSim.Framework.Communications.Caches public void AddPlugin(string FileName) { - //MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -75,10 +75,10 @@ namespace OpenSim.Framework.Communications.Caches if (typeInterface != null) { IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_plugin = plug; - m_plugin.Initialise("AssetStorage.db", ""); - - //MainLog.Instance.Verbose("AssetStorage: Added IAssetProvider Interface"); + m_assetProviderPlugin = plug; + m_assetProviderPlugin.Initialise(); + + MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); } typeInterface = null; @@ -105,8 +105,8 @@ namespace OpenSim.Framework.Communications.Caches { lock (syncLock) { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); + m_assetProviderPlugin.UpdateAsset(asset); + m_assetProviderPlugin.CommitAssets(); } } @@ -114,8 +114,8 @@ namespace OpenSim.Framework.Communications.Caches { lock (syncLock) { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); + m_assetProviderPlugin.CreateAsset(asset); + m_assetProviderPlugin.CommitAssets(); } } @@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications.Caches } public void Close() { - m_plugin.CommitAssets(); + m_assetProviderPlugin.CommitAssets(); } private void RunRequests() @@ -140,7 +140,7 @@ namespace OpenSim.Framework.Communications.Caches AssetBase asset = null; lock (syncLock) { - asset = m_plugin.FetchAsset(req.AssetID); + asset = m_assetProviderPlugin.FetchAsset(req.AssetID); } if (asset != null) { @@ -163,67 +163,67 @@ namespace OpenSim.Framework.Communications.Caches Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); Image.Name = "Bricks"; this.LoadAsset(Image, true, "bricks.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); Image.Name = "Plywood"; this.LoadAsset(Image, true, "plywood.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); Image.Name = "Rocks"; this.LoadAsset(Image, true, "rocks.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); Image.Name = "Granite"; this.LoadAsset(Image, true, "granite.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); Image.Name = "Hardwood"; this.LoadAsset(Image, true, "hardwood.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); Image.Name = "Prim Base Texture"; this.LoadAsset(Image, true, "plywood.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); Image.Name = "Map Base Texture"; this.LoadAsset(Image, true, "map_base.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); Image.Name = "Map Texture"; this.LoadAsset(Image, true, "map1.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); Image.Name = "Female Body Texture"; this.LoadAsset(Image, true, "femalebody.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); Image.Name = "Female Bottom Texture"; this.LoadAsset(Image, true, "femalebottom.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); Image.Name = "Female Face Texture"; this.LoadAsset(Image, true, "femaleface.jp2"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Caches Image.Type = 13; Image.InvType = 13; this.LoadAsset(Image, false, "base_skin.dat"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); @@ -239,7 +239,7 @@ namespace OpenSim.Framework.Communications.Caches Image.Type = 13; Image.InvType = 13; this.LoadAsset(Image, false, "base_shape.dat"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); @@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Caches Image.Type = 5; Image.InvType = 18; this.LoadAsset(Image, false, "newshirt.dat"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); Image = new AssetBase(); Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); @@ -255,7 +255,7 @@ namespace OpenSim.Framework.Communications.Caches Image.Type = 5; Image.InvType = 18; this.LoadAsset(Image, false, "newpants.dat"); - m_plugin.CreateAsset(Image); + m_assetProviderPlugin.CreateAsset(Image); string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); if (File.Exists(filePath)) @@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications.Caches ReadAssetDetails(source); } - m_plugin.CommitAssets(); + m_assetProviderPlugin.CommitAssets(); } protected void ReadAssetDetails(IConfigSource source) @@ -282,7 +282,7 @@ namespace OpenSim.Framework.Communications.Caches { MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); this.LoadAsset(newAsset, false, fileName); - m_plugin.CreateAsset(newAsset); + m_assetProviderPlugin.CreateAsset(newAsset); } } } -- cgit v1.1 From 8b01821dbacf1c54fd1d729d4fba6558564c1904 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 15 Oct 2007 04:27:52 +0000 Subject: * normalized line endings --- .../Communications/Cache/SQLAssetServer.cs | 610 ++++++++++----------- 1 file changed, 305 insertions(+), 305 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 2a38307..082a240 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -1,310 +1,310 @@ -/* -* 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.IO; -using System.Threading; -using System.Reflection; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class SQLAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private Thread _localAssetServerThread; - protected IAssetProvider m_assetProviderPlugin; - private object syncLock = new object(); - - - public SQLAssetServer(string pluginName) - { +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Caches +{ + + public class SQLAssetServer : IAssetServer + { + private IAssetReceiver _receiver; + private BlockingQueue _assetRequests; + private Thread _localAssetServerThread; + protected IAssetProvider m_assetProviderPlugin; + private object syncLock = new object(); + + + public SQLAssetServer(string pluginName) + { _assetRequests = new BlockingQueue(); AddPlugin(pluginName); - SetUpAssetDatabase(); - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - - } - - public void AddPlugin(string FileName) - { - MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); - - if (typeInterface != null) - { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_assetProviderPlugin = plug; + SetUpAssetDatabase(); + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void AddPlugin(string FileName) + { + MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + + if (typeInterface != null) + { + IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); - } - - typeInterface = null; - } - } - - pluginAssembly = null; - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - lock (syncLock) - { - m_assetProviderPlugin.UpdateAsset(asset); - m_assetProviderPlugin.CommitAssets(); - } - } - - public void CreateAsset(AssetBase asset) - { - lock (syncLock) - { - m_assetProviderPlugin.CreateAsset(asset); - m_assetProviderPlugin.CommitAssets(); - } - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() - { - m_assetProviderPlugin.CommitAssets(); - } - - private void RunRequests() - { - - while (true) - { - ARequest req = this._assetRequests.Dequeue(); - - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = null; - lock (syncLock) - { - asset = m_assetProviderPlugin.FetchAsset(req.AssetID); - } - if (asset != null) - { - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - private void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - - m_assetProviderPlugin.CommitAssets(); - } - - protected void ReadAssetDetails(IConfigSource source) - { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); - this.LoadAsset(newAsset, false, fileName); - m_assetProviderPlugin.CreateAsset(newAsset); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - } - -} + MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + lock (syncLock) + { + m_assetProviderPlugin.UpdateAsset(asset); + m_assetProviderPlugin.CommitAssets(); + } + } + + public void CreateAsset(AssetBase asset) + { + lock (syncLock) + { + m_assetProviderPlugin.CreateAsset(asset); + m_assetProviderPlugin.CommitAssets(); + } + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + public void Close() + { + m_assetProviderPlugin.CommitAssets(); + } + + private void RunRequests() + { + + while (true) + { + ARequest req = this._assetRequests.Dequeue(); + + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_assetProviderPlugin.FetchAsset(req.AssetID); + } + if (asset != null) + { + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("Setting up asset database"); + + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); + Image.Name = "Female Body Texture"; + this.LoadAsset(Image, true, "femalebody.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); + Image.Name = "Female Bottom Texture"; + this.LoadAsset(Image, true, "femalebottom.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); + Image.Name = "Female Face Texture"; + this.LoadAsset(Image, true, "femaleface.jp2"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); + Image.Name = "Skin"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_skin.dat"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + Image.Type = 13; + Image.InvType = 13; + this.LoadAsset(Image, false, "base_shape.dat"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newshirt.dat"); + m_assetProviderPlugin.CreateAsset(Image); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); + Image.Name = "Shirt"; + Image.Type = 5; + Image.InvType = 18; + this.LoadAsset(Image, false, "newpants.dat"); + m_assetProviderPlugin.CreateAsset(Image); + + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadAssetDetails(source); + } + + m_assetProviderPlugin.CommitAssets(); + } + + protected void ReadAssetDetails(IConfigSource source) + { + AssetBase newAsset = null; + for (int i = 0; i < source.Configs.Count; i++) + { + newAsset = new AssetBase(); + newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + newAsset.Name = source.Configs[i].GetString("name", ""); + newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); + newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + if (fileName != "") + { + MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); + this.LoadAsset(newAsset, false, fileName); + m_assetProviderPlugin.CreateAsset(newAsset); + } + } + } + + private void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + } + +} -- cgit v1.1 From 849eaffbe5fc59015adb7795e76b0b039e2c5cb0 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 15 Oct 2007 07:10:21 +0000 Subject: * Applied patch #418 : copyright-r2012.patch - some errors, but got most thru --- OpenSim/Framework/Communications/CAPSService.cs | 28 +++++++++++++++++++++ .../Communications/Cache/LibraryRootFolder.cs | 28 +++++++++++++++++++++ .../Capabilities/LLSDAssetUploadRequest.cs | 28 +++++++++++++++++++++ .../Capabilities/LLSDAssetUploadResponse.cs | 28 +++++++++++++++++++++ .../Communications/Capabilities/LLSDCapsDetails.cs | 29 ++++++++++++++++++++++ .../Communications/Capabilities/LLSDItemUpdate.cs | 28 +++++++++++++++++++++ .../Communications/Capabilities/LLSDMapRequest.cs | 28 +++++++++++++++++++++ .../Communications/Capabilities/LLSDMethod.cs | 28 +++++++++++++++++++++ .../Capabilities/LLSDStreamHandler.cs | 28 +++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 28 +++++++++++++++++++++ .../Communications/InventoryServiceBase.cs | 28 +++++++++++++++++++++ OpenSim/Framework/Communications/LoginResponse.cs | 29 ++++++++++++++++++++++ OpenSim/Framework/Communications/LoginService.cs | 28 +++++++++++++++++++++ 13 files changed, 366 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index a8eac26..6f65551 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 38fad68..13ce39e 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.IO; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 0096fb1..3a2fe20 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 2a2a5d1..c7a9ee6 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index af20468..3184792 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] @@ -20,3 +48,4 @@ namespace OpenSim.Region.Capabilities } + diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 19220ac..57fc9e8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 8ac7943..5fa08c9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index 068d539..67253ee 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index d98e23f..894b276 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 980bb27..bfc3ee7 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 366b110..65eb509 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.Reflection; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b5a4184..38bc016 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections; using libsecondlife; @@ -665,3 +693,4 @@ namespace OpenSim.Framework.UserManagement } } + diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8778f6f..85af5db 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections; using System.Collections.Generic; -- cgit v1.1 From 26b8018bccbcb0f6a296adbb11bdc66733aa9e12 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 17 Oct 2007 10:58:19 +0000 Subject: * Some asset loading refactoring --- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 082a240..35ec1cf 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -61,6 +61,11 @@ namespace OpenSim.Framework.Communications.Caches } + public SQLAssetServer( IAssetProvider assetProvider ) + { + m_assetProviderPlugin = assetProvider; + } + public void AddPlugin(string FileName) { MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); -- cgit v1.1 From 05df8571323c535b5c1ce1b0532e88236b143b7e Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Thu, 18 Oct 2007 15:10:43 +0000 Subject: Possible fix for: Remoting exceptions with adjacent non-running sims. Bugs 449, 454, 408, 244, 197 implemented InformClientOfNeighbours as an asynchroneous process, handling timeouts without blocking the main thread. Improved logging of errors, removed catch all in try catch --- OpenSim/Framework/Communications/IGridServices.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index d538e23..4167b65 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -27,6 +27,9 @@ */ using System.Collections.Generic; +using System.Net; +using libsecondlife; + using OpenSim.Framework.Types; namespace OpenSim.Framework.Communications @@ -34,7 +37,7 @@ namespace OpenSim.Framework.Communications public interface IGridServices { RegionCommsListener RegisterRegion(RegionInfo regionInfos); - List RequestNeighbours(RegionInfo regionInfo); + List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -- cgit v1.1 From 46700d3b7d5bd71d880b3cc0dd0e2d6edd701195 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 19 Oct 2007 07:46:03 +0000 Subject: * Total refactoring of Asset Server for massive win * There is now a AssetServerBase * lolcat in ur assets --- .../Framework/Communications/Cache/AssetCache.cs | 9 +- .../Framework/Communications/Cache/AssetServer.cs | 501 ++++++--------------- .../Communications/Cache/AssetServerBase.cs | 180 ++++++++ .../Communications/Cache/SQLAssetServer.cs | 206 +-------- 4 files changed, 331 insertions(+), 565 deletions(-) create mode 100644 OpenSim/Framework/Communications/Cache/AssetServerBase.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4ae8595..17829b2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -91,7 +91,12 @@ namespace OpenSim.Framework.Communications.Cache { System.Console.WriteLine("Creating Asset cache"); _assetServer = this.LoadAssetDll(assetServerDLLName); + + + // TODO: This actually does nothing to no IAssetServer implementor. Delete? _assetServer.SetServerInfo(assetServerURL, assetServerKey); + + _assetServer.SetReceiver(this); Assets = new Dictionary(); Textures = new Dictionary(); @@ -159,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache { //texture TextureImage textur = new TextureImage(asset); this.Textures.Add(textur.FullID, textur); - this._assetServer.CreateAsset(asset); + this._assetServer.StoreAndCommitAsset(asset); } else { @@ -173,7 +178,7 @@ namespace OpenSim.Framework.Communications.Cache { AssetInfo assetInf = new AssetInfo(asset); this.Assets.Add(assetInf.FullID, assetInf); - this._assetServer.CreateAsset(asset); + this._assetServer.StoreAndCommitAsset(asset); } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index e5329ec..a374df2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -24,370 +24,137 @@ * (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.IO; -using System.Threading; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Caches -{ - - public class LocalAssetServer : IAssetServer - { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private IObjectContainer db; - private Thread _localAssetServerThread; - - public LocalAssetServer() - { - System.Console.WriteLine("Starting Db4o asset storage system"); - bool yapfile; - this._assetRequests = new BlockingQueue(); - yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); - - MainLog.Instance.Verbose("Local Asset Server class created"); - db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); - - if (!yapfile) - { - this.SetUpAssetDatabase(); - } - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - - } - - public void CreateAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - db.Commit(); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() - { - if (db != null) - { - MainLog.Instance.Verbose("Closing local asset server database"); - db.Close(); - } - } - - private void RunRequests() - { - while (true) - { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage)result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - private void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - AssetStorage store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - } - - protected void ReadAssetDetails(IConfigSource source) - { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - this.LoadAsset(newAsset, false, fileName); - AssetStorage store = new AssetStorage(); - store.Data = newAsset.Data; - store.Name = newAsset.Name; - store.UUID = newAsset.FullID; - db.Set(store); - db.Commit(); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - } - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; - - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } - } - -} - +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Cache +{ + public class LocalAssetServer : AssetServerBase + { + private IObjectContainer db; + + public LocalAssetServer() + { + bool yapfile; + yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); + + db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); + MainLog.Instance.Verbose("Db4 Asset database creation"); + + if (!yapfile) + { + SetUpAssetDatabase(); + } + + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + + } + + public void CreateAndCommitAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + override public void Close() + { + if (db != null) + { + MainLog.Instance.Verbose("Closing local asset server database"); + db.Close(); + } + } + + private void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + override protected void StoreAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + + CommitAssets(); + } + + protected override void CommitAssets() + { + db.Commit(); + } + + private void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); + + ForEachDefaultAsset(this, StoreAsset); + ForEachXmlAsset(this, StoreAsset); + } + } + + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs new file mode 100644 index 0000000..7073000 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Cache +{ + public abstract class AssetServerBase : IAssetServer + { + protected IAssetReceiver _receiver; + protected BlockingQueue _assetRequests; + protected Thread _localAssetServerThread; + protected IAssetProvider m_assetProviderPlugin; + protected object syncLock = new object(); + + protected abstract void StoreAsset(AssetBase asset); + protected abstract void CommitAssets(); + + public void LoadDefaultAssets() + { + MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); + + ForEachDefaultAsset( this, StoreAsset ); + ForEachXmlAsset( this, StoreAsset ); + + CommitAssets(); + } + + + public static AssetBase CreateAsset(IAssetServer assetServer, string assetIdStr, string name, string filename, bool isImage) + { + AssetBase asset = new AssetBase( + new LLUUID(assetIdStr), + name + ); + + if (!String.IsNullOrEmpty(filename)) + { + MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); + + assetServer.LoadAsset(asset, isImage, filename); + } + else + { + MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); + } + + return asset; + } + + private static AssetBase CreateImageAsset(IAssetServer assetServer, string assetIdStr, string name, string filename) + { + return CreateAsset(assetServer, assetIdStr, name, filename, true); + } + + public static List GetDefaultAssets(IAssetServer assetServer) + { + List assets = new List(); + + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); + assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); + + assets.Add(CreateAsset(assetServer, "77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); + assets.Add(CreateAsset(assetServer, "66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); + assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); + assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); + + return assets; + } + + public static void ForEachDefaultAsset(IAssetServer assetServer, Action action) + { + List assets = GetDefaultAssets(assetServer); + assets.ForEach(action); + } + + public AssetServerBase() + { + System.Console.WriteLine("Starting Db4o asset storage system"); + this._assetRequests = new BlockingQueue(); + } + + public void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + + public static void ForEachXmlAsset(IAssetServer assetServer, Action action) + { + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + + for (int i = 0; i < source.Configs.Count; i++) + { + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string name = source.Configs[i].GetString("name", ""); + sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + + AssetBase newAsset = CreateAsset(assetServer, assetIdStr, name, fileName, false); + + newAsset.Type = type; + newAsset.InvType = invType; + + } + } + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + lock (syncLock) + { + m_assetProviderPlugin.UpdateAsset(asset); + m_assetProviderPlugin.CommitAssets(); + } + } + + public void StoreAndCommitAsset(AssetBase asset) + { + lock (syncLock) + { + StoreAsset(asset); + CommitAssets(); + } + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + + public abstract void Close(); + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 35ec1cf..cf54b81 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -36,32 +36,22 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { - - public class SQLAssetServer : IAssetServer + public class SQLAssetServer : AssetServerBase { - private IAssetReceiver _receiver; - private BlockingQueue _assetRequests; - private Thread _localAssetServerThread; - protected IAssetProvider m_assetProviderPlugin; - private object syncLock = new object(); - - public SQLAssetServer(string pluginName) { _assetRequests = new BlockingQueue(); AddPlugin(pluginName); - SetUpAssetDatabase(); - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); this._localAssetServerThread.IsBackground = true; this._localAssetServerThread.Start(); } - public SQLAssetServer( IAssetProvider assetProvider ) + public SQLAssetServer(IAssetProvider assetProvider) { m_assetProviderPlugin = assetProvider; } @@ -93,49 +83,15 @@ namespace OpenSim.Framework.Communications.Caches pluginAssembly = null; } - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - lock (syncLock) - { - m_assetProviderPlugin.UpdateAsset(asset); - m_assetProviderPlugin.CommitAssets(); - } - } - public void CreateAsset(AssetBase asset) - { - lock (syncLock) - { - m_assetProviderPlugin.CreateAsset(asset); - m_assetProviderPlugin.CommitAssets(); - } - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - public void Close() + public override void Close() { m_assetProviderPlugin.CommitAssets(); } private void RunRequests() { - + while (true) { ARequest req = this._assetRequests.Dequeue(); @@ -160,156 +116,14 @@ namespace OpenSim.Framework.Communications.Caches } - private void SetUpAssetDatabase() + protected override void StoreAsset(AssetBase asset) { - MainLog.Instance.Verbose("Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); - Image.Name = "Female Body Texture"; - this.LoadAsset(Image, true, "femalebody.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); - Image.Name = "Female Bottom Texture"; - this.LoadAsset(Image, true, "femalebottom.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); - Image.Name = "Female Face Texture"; - this.LoadAsset(Image, true, "femaleface.jp2"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - Image.Name = "Skin"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_skin.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - Image.Type = 13; - Image.InvType = 13; - this.LoadAsset(Image, false, "base_shape.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newshirt.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - Image.Name = "Shirt"; - Image.Type = 5; - Image.InvType = 18; - this.LoadAsset(Image, false, "newpants.dat"); - m_assetProviderPlugin.CreateAsset(Image); - - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadAssetDetails(source); - } - - m_assetProviderPlugin.CommitAssets(); + m_assetProviderPlugin.CreateAsset(asset); } - protected void ReadAssetDetails(IConfigSource source) + protected override void CommitAssets() { - AssetBase newAsset = null; - for (int i = 0; i < source.Configs.Count; i++) - { - newAsset = new AssetBase(); - newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); - newAsset.Name = source.Configs[i].GetString("name", ""); - newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); - newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - if (fileName != "") - { - MainLog.Instance.Verbose("Creating new asset: " + newAsset.Name); - this.LoadAsset(newAsset, false, fileName); - m_assetProviderPlugin.CreateAsset(newAsset); - } - } - } - - private void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; + m_assetProviderPlugin.CommitAssets(); } } - -} +} \ No newline at end of file -- cgit v1.1 From 656c72befc1d1b3d2aa29c09dd8f75ee2ef5ef8a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 19 Oct 2007 08:57:30 +0000 Subject: * some more refactoring + bugfix --- .../Framework/Communications/Cache/AssetServer.cs | 67 ++++---- .../Communications/Cache/AssetServerBase.cs | 176 +++++++++++---------- .../Communications/Cache/SQLAssetServer.cs | 10 +- 3 files changed, 127 insertions(+), 126 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index a374df2..b17f65a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,29 +1,29 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* */ using System; using System.Collections.Generic; @@ -57,11 +57,6 @@ namespace OpenSim.Framework.Communications.Cache { SetUpAssetDatabase(); } - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - } public void CreateAndCommitAsset(AssetBase asset) @@ -76,6 +71,8 @@ namespace OpenSim.Framework.Communications.Cache override public void Close() { + base.Close(); + if (db != null) { MainLog.Instance.Verbose("Closing local asset server database"); @@ -83,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache } } - private void RunRequests() + override protected void RunRequests() { while (true) { @@ -135,12 +132,12 @@ namespace OpenSim.Framework.Communications.Cache db.Commit(); } - private void SetUpAssetDatabase() + protected virtual void SetUpAssetDatabase() { MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); - ForEachDefaultAsset(this, StoreAsset); - ForEachXmlAsset(this, StoreAsset); + ForEachDefaultAsset(StoreAsset); + ForEachXmlAsset(StoreAsset); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7073000..858019f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -22,78 +22,27 @@ namespace OpenSim.Framework.Communications.Cache protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); + protected abstract void RunRequests(); + public void LoadDefaultAssets() { MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); - ForEachDefaultAsset( this, StoreAsset ); - ForEachXmlAsset( this, StoreAsset ); + ForEachDefaultAsset(StoreAsset ); + ForEachXmlAsset(StoreAsset ); CommitAssets(); } - public static AssetBase CreateAsset(IAssetServer assetServer, string assetIdStr, string name, string filename, bool isImage) - { - AssetBase asset = new AssetBase( - new LLUUID(assetIdStr), - name - ); - - if (!String.IsNullOrEmpty(filename)) - { - MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); - - assetServer.LoadAsset(asset, isImage, filename); - } - else - { - MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); - } - - return asset; - } - - private static AssetBase CreateImageAsset(IAssetServer assetServer, string assetIdStr, string name, string filename) - { - return CreateAsset(assetServer, assetIdStr, name, filename, true); - } - - public static List GetDefaultAssets(IAssetServer assetServer) - { - List assets = new List(); - - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); - assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); - - assets.Add(CreateAsset(assetServer, "77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); - assets.Add(CreateAsset(assetServer, "66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); - assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); - assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); - - return assets; - } - - public static void ForEachDefaultAsset(IAssetServer assetServer, Action action) - { - List assets = GetDefaultAssets(assetServer); - assets.ForEach(action); - } - public AssetServerBase() { System.Console.WriteLine("Starting Db4o asset storage system"); this._assetRequests = new BlockingQueue(); + + this._localAssetServerThread = new Thread( RunRequests ); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); } public void LoadAsset(AssetBase info, bool image, string filename) @@ -115,30 +64,6 @@ namespace OpenSim.Framework.Communications.Cache //info.loaded=true; } - public static void ForEachXmlAsset(IAssetServer assetServer, Action action) - { - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - - for (int i = 0; i < source.Configs.Count; i++) - { - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); - string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - - AssetBase newAsset = CreateAsset(assetServer, assetIdStr, name, fileName, false); - - newAsset.Type = type; - newAsset.InvType = invType; - - } - } - } - public void SetReceiver(IAssetReceiver receiver) { this._receiver = receiver; @@ -170,11 +95,94 @@ namespace OpenSim.Framework.Communications.Cache } } + public virtual void Close() + { + _localAssetServerThread.Abort( ); + } + public void SetServerInfo(string ServerUrl, string ServerKey) { } - public abstract void Close(); + public virtual List GetDefaultAssets() + { + List assets = new List(); + + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); + + assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); + assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); + assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); + assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); + + return assets; + } + + public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) + { + return CreateAsset(assetIdStr, name, filename, true); + } + + public void ForEachDefaultAsset(Action action) + { + List assets = GetDefaultAssets(); + assets.ForEach(action); + } + + public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) + { + AssetBase asset = new AssetBase( + new LLUUID(assetIdStr), + name + ); + + if (!String.IsNullOrEmpty(filename)) + { + MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); + + LoadAsset(asset, isImage, filename); + } + else + { + MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); + } + + return asset; + } + + public void ForEachXmlAsset(Action action) + { + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + + for (int i = 0; i < source.Configs.Count; i++) + { + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string name = source.Configs[i].GetString("name", ""); + sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + + AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); + + newAsset.Type = type; + newAsset.InvType = invType; + + } + } + } } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index cf54b81..379d609 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,11 +44,6 @@ namespace OpenSim.Framework.Communications.Cache { _assetRequests = new BlockingQueue(); AddPlugin(pluginName); - - this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - } public SQLAssetServer(IAssetProvider assetProvider) @@ -86,12 +81,13 @@ namespace OpenSim.Framework.Communications.Cache public override void Close() { + base.Close(); + m_assetProviderPlugin.CommitAssets(); } - private void RunRequests() + override protected void RunRequests() { - while (true) { ARequest req = this._assetRequests.Dequeue(); -- cgit v1.1 From d4bb430f78d9a70137957c8fe42de8fa620597ef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 19 Oct 2007 20:28:18 +0000 Subject: get rid of all the ^M line endings --- .../Framework/Communications/Cache/AssetServer.cs | 312 +++++----- .../Communications/Cache/AssetServerBase.cs | 374 ++++++------ .../Communications/Cache/SQLAssetServer.cs | 248 ++++---- OpenSim/Framework/Communications/LoginService.cs | 630 ++++++++++----------- 4 files changed, 782 insertions(+), 782 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index b17f65a..22bdc5c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,157 +1,157 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Cache -{ - public class LocalAssetServer : AssetServerBase - { - private IObjectContainer db; - - public LocalAssetServer() - { - bool yapfile; - yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); - - db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); - - if (!yapfile) - { - SetUpAssetDatabase(); - } - } - - public void CreateAndCommitAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - db.Commit(); - } - - override public void Close() - { - base.Close(); - - if (db != null) - { - MainLog.Instance.Verbose("Closing local asset server database"); - db.Close(); - } - } - - override protected void RunRequests() - { - while (true) - { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage)result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - override protected void StoreAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - - CommitAssets(); - } - - protected override void CommitAssets() - { - db.Commit(); - } - - protected virtual void SetUpAssetDatabase() - { - MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); - - ForEachDefaultAsset(StoreAsset); - ForEachXmlAsset(StoreAsset); - } - } - - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; - - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } - } +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Cache +{ + public class LocalAssetServer : AssetServerBase + { + private IObjectContainer db; + + public LocalAssetServer() + { + bool yapfile; + yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); + + db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); + MainLog.Instance.Verbose("Db4 Asset database creation"); + + if (!yapfile) + { + SetUpAssetDatabase(); + } + } + + public void CreateAndCommitAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + db.Commit(); + } + + override public void Close() + { + base.Close(); + + if (db != null) + { + MainLog.Instance.Verbose("Closing local asset server database"); + db.Close(); + } + } + + override protected void RunRequests() + { + while (true) + { + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + ARequest req = this._assetRequests.Dequeue(); + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) + { + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + override protected void StoreAsset(AssetBase asset) + { + AssetStorage store = new AssetStorage(); + store.Data = asset.Data; + store.Name = asset.Name; + store.UUID = asset.FullID; + db.Set(store); + + CommitAssets(); + } + + protected override void CommitAssets() + { + db.Commit(); + } + + protected virtual void SetUpAssetDatabase() + { + MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); + + ForEachDefaultAsset(StoreAsset); + ForEachXmlAsset(StoreAsset); + } + } + + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; + + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 858019f..08d5b87 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -1,188 +1,188 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Cache -{ - public abstract class AssetServerBase : IAssetServer - { - protected IAssetReceiver _receiver; - protected BlockingQueue _assetRequests; - protected Thread _localAssetServerThread; - protected IAssetProvider m_assetProviderPlugin; - protected object syncLock = new object(); - - protected abstract void StoreAsset(AssetBase asset); - protected abstract void CommitAssets(); - - protected abstract void RunRequests(); - - public void LoadDefaultAssets() - { - MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); - - ForEachDefaultAsset(StoreAsset ); - ForEachXmlAsset(StoreAsset ); - - CommitAssets(); - } - - - public AssetServerBase() - { - System.Console.WriteLine("Starting Db4o asset storage system"); - this._assetRequests = new BlockingQueue(); - - this._localAssetServerThread = new Thread( RunRequests ); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); - } - - public void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - - public void SetReceiver(IAssetReceiver receiver) - { - this._receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - ARequest req = new ARequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); - } - - public void UpdateAsset(AssetBase asset) - { - lock (syncLock) - { - m_assetProviderPlugin.UpdateAsset(asset); - m_assetProviderPlugin.CommitAssets(); - } - } - - public void StoreAndCommitAsset(AssetBase asset) - { - lock (syncLock) - { - StoreAsset(asset); - CommitAssets(); - } - } - - public virtual void Close() - { - _localAssetServerThread.Abort( ); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - - } - - public virtual List GetDefaultAssets() - { - List assets = new List(); - - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); - - assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); - assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); - assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); - assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); - - return assets; - } - - public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) - { - return CreateAsset(assetIdStr, name, filename, true); - } - - public void ForEachDefaultAsset(Action action) - { - List assets = GetDefaultAssets(); - assets.ForEach(action); - } - - public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) - { - AssetBase asset = new AssetBase( - new LLUUID(assetIdStr), - name - ); - - if (!String.IsNullOrEmpty(filename)) - { - MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); - - LoadAsset(asset, isImage, filename); - } - else - { - MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); - } - - return asset; - } - - public void ForEachXmlAsset(Action action) - { - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - XmlConfigSource source = new XmlConfigSource(filePath); - - for (int i = 0; i < source.Configs.Count; i++) - { - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); - string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - - AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); - - newAsset.Type = type; - newAsset.InvType = invType; - - } - } - } - } +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Cache +{ + public abstract class AssetServerBase : IAssetServer + { + protected IAssetReceiver _receiver; + protected BlockingQueue _assetRequests; + protected Thread _localAssetServerThread; + protected IAssetProvider m_assetProviderPlugin; + protected object syncLock = new object(); + + protected abstract void StoreAsset(AssetBase asset); + protected abstract void CommitAssets(); + + protected abstract void RunRequests(); + + public void LoadDefaultAssets() + { + MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); + + ForEachDefaultAsset(StoreAsset ); + ForEachXmlAsset(StoreAsset ); + + CommitAssets(); + } + + + public AssetServerBase() + { + System.Console.WriteLine("Starting Db4o asset storage system"); + this._assetRequests = new BlockingQueue(); + + this._localAssetServerThread = new Thread( RunRequests ); + this._localAssetServerThread.IsBackground = true; + this._localAssetServerThread.Start(); + } + + public void LoadAsset(AssetBase info, bool image, string filename) + { + //should request Asset from storage manager + //but for now read from file + + string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; + string fileName = Path.Combine(dataPath, filename); + FileInfo fInfo = new FileInfo(fileName); + long numBytes = fInfo.Length; + FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + byte[] idata = new byte[numBytes]; + BinaryReader br = new BinaryReader(fStream); + idata = br.ReadBytes((int)numBytes); + br.Close(); + fStream.Close(); + info.Data = idata; + //info.loaded=true; + } + + public void SetReceiver(IAssetReceiver receiver) + { + this._receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + ARequest req = new ARequest(); + req.AssetID = assetID; + req.IsTexture = isTexture; + this._assetRequests.Enqueue(req); + } + + public void UpdateAsset(AssetBase asset) + { + lock (syncLock) + { + m_assetProviderPlugin.UpdateAsset(asset); + m_assetProviderPlugin.CommitAssets(); + } + } + + public void StoreAndCommitAsset(AssetBase asset) + { + lock (syncLock) + { + StoreAsset(asset); + CommitAssets(); + } + } + + public virtual void Close() + { + _localAssetServerThread.Abort( ); + } + + public void SetServerInfo(string ServerUrl, string ServerKey) + { + + } + + public virtual List GetDefaultAssets() + { + List assets = new List(); + + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); + assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); + + assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); + assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); + assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); + assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); + + return assets; + } + + public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) + { + return CreateAsset(assetIdStr, name, filename, true); + } + + public void ForEachDefaultAsset(Action action) + { + List assets = GetDefaultAssets(); + assets.ForEach(action); + } + + public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) + { + AssetBase asset = new AssetBase( + new LLUUID(assetIdStr), + name + ); + + if (!String.IsNullOrEmpty(filename)) + { + MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); + + LoadAsset(asset, isImage, filename); + } + else + { + MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); + } + + return asset; + } + + public void ForEachXmlAsset(Action action) + { + string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); + if (File.Exists(filePath)) + { + XmlConfigSource source = new XmlConfigSource(filePath); + + for (int i = 0; i < source.Configs.Count; i++) + { + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string name = source.Configs[i].GetString("name", ""); + sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + + AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); + + newAsset.Type = type; + newAsset.InvType = invType; + + } + } + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 379d609..69f83d2 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -1,125 +1,125 @@ -/* -* 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.IO; -using System.Threading; -using System.Reflection; -using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Framework.Communications.Cache -{ - public class SQLAssetServer : AssetServerBase - { - public SQLAssetServer(string pluginName) - { - _assetRequests = new BlockingQueue(); - AddPlugin(pluginName); - } - - public SQLAssetServer(IAssetProvider assetProvider) - { - m_assetProviderPlugin = assetProvider; - } - - public void AddPlugin(string FileName) - { - MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); - - if (typeInterface != null) - { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_assetProviderPlugin = plug; - m_assetProviderPlugin.Initialise(); - - MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); - } - - typeInterface = null; - } - } - - pluginAssembly = null; - } - - - public override void Close() - { - base.Close(); - - m_assetProviderPlugin.CommitAssets(); - } - - override protected void RunRequests() - { - while (true) - { - ARequest req = this._assetRequests.Dequeue(); - - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = null; - lock (syncLock) - { - asset = m_assetProviderPlugin.FetchAsset(req.AssetID); - } - if (asset != null) - { - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - _receiver.AssetNotFound(req.AssetID); - } - - } - - } - - protected override void StoreAsset(AssetBase asset) - { - m_assetProviderPlugin.CreateAsset(asset); - } - - protected override void CommitAssets() - { - m_assetProviderPlugin.CommitAssets(); - } - } +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.Communications.Cache +{ + public class SQLAssetServer : AssetServerBase + { + public SQLAssetServer(string pluginName) + { + _assetRequests = new BlockingQueue(); + AddPlugin(pluginName); + } + + public SQLAssetServer(IAssetProvider assetProvider) + { + m_assetProviderPlugin = assetProvider; + } + + public void AddPlugin(string FileName) + { + MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + + if (typeInterface != null) + { + IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + m_assetProviderPlugin = plug; + m_assetProviderPlugin.Initialise(); + + MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + + public override void Close() + { + base.Close(); + + m_assetProviderPlugin.CommitAssets(); + } + + override protected void RunRequests() + { + while (true) + { + ARequest req = this._assetRequests.Dequeue(); + + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_assetProviderPlugin.FetchAsset(req.AssetID); + } + if (asset != null) + { + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + _receiver.AssetNotFound(req.AssetID); + } + + } + + } + + protected override void StoreAsset(AssetBase asset) + { + m_assetProviderPlugin.CreateAsset(asset); + } + + protected override void CommitAssets() + { + m_assetProviderPlugin.CommitAssets(); + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 85af5db..674c746 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,315 +1,315 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; - -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; - -namespace OpenSim.Framework.UserManagement -{ - public class LoginService - { - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected UserManagerBase m_userManager = null; - - public LoginService(UserManagerBase userManager, string welcomeMess) - { - m_userManager = userManager; - if (welcomeMess != "") - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// Main user login function - /// - /// The XMLRPC request - /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - - MainLog.Instance.Verbose("Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); - bool GoodLogin = false; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - if (GoodXML) - { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); - - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } - - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) - { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); - } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - - try - { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); - - try - { - this.CustomiseResponse(logResponse, userProfile); - } - catch (Exception e) - { - MainLog.Instance.Verbose(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); - } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); - - } - - catch (Exception E) - { - MainLog.Instance.Verbose(E.ToString()); - } - //} - } - return response; - - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - // Saves the agent to database - return true; - } - - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - - MainLog.Instance.Verbose( - "Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - this.m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return this.m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - /// - /// - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - return temp; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; - - public InventoryData(ArrayList invList, LLUUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Security.Cryptography; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; + +using OpenSim.Framework.Configuration; +using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; + +namespace OpenSim.Framework.UserManagement +{ + public class LoginService + { + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected UserManagerBase m_userManager = null; + + public LoginService(UserManagerBase userManager, string welcomeMess) + { + m_userManager = userManager; + if (welcomeMess != "") + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + + MainLog.Instance.Verbose("Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = this.CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = this.GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + MainLog.Instance.Verbose(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); + + } + + catch (Exception E) + { + MainLog.Instance.Verbose(E.ToString()); + } + //} + } + return response; + + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + + MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + this.m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return this.m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + /// + /// + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + //return new ArrayList(); + Hashtable TempHash = new Hashtable(); + TempHash["name"] = "OpenSim Library"; + TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList temp = new ArrayList(); + temp.Add(TempHash); + + TempHash = new Hashtable(); + TempHash["name"] = "Texture Library"; + TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; + TempHash["version"] = 1; + TempHash["type_default"] = -1; + TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; + temp.Add(TempHash); + return temp; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + protected virtual InventoryData CreateInventoryData(LLUUID userID) + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public LLUUID RootFolderID = LLUUID.Zero; + + public InventoryData(ArrayList invList, LLUUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + } +} -- cgit v1.1 From 4dc8e7e0f8f0165fc242802864f39d9aab2f72d3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 21 Oct 2007 22:53:54 +0000 Subject: * Added a lock to the user profile cache to prevent simultaneous duplicate additions to the database. (Attempting to fix bug reported by nebadon) --- .../Communications/Cache/UserProfileCache.cs | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 9e32ea5..362ab17 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -59,18 +59,22 @@ namespace OpenSim.Framework.Communications.Caches /// public void AddNewUser(LLUUID userID) { - if (!this.UserProfiles.ContainsKey(userID)) + // Potential fix - Multithreading issue. + lock (UserProfiles) { - CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); - userInfo.UserProfile = this.RequestUserProfileForUser(userID); - if (userInfo.UserProfile != null) + if (!this.UserProfiles.ContainsKey(userID)) { - this.RequestInventoryForUser(userID, userInfo); - this.UserProfiles.Add(userID, userInfo); - } - else - { - System.Console.WriteLine("CACHE", "User profile for user not found"); + CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); + userInfo.UserProfile = this.RequestUserProfileForUser(userID); + if (userInfo.UserProfile != null) + { + this.RequestInventoryForUser(userID, userInfo); + this.UserProfiles.Add(userID, userInfo); + } + else + { + System.Console.WriteLine("CACHE", "User profile for user not found"); + } } } } -- cgit v1.1 From c4707a284ffecf81e8ca60a1019e234339222631 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 22 Oct 2007 15:23:48 +0000 Subject: * Major ass commit. * Sqlite Storage Engine now supports terrain -- however be aware that every terrain revision stored will at 512KB to your database file. At the moment it is storing every revision from the first. * Fixed an issue where by noverbose mode would display lots of useless junk. Noverbose mode is now quite usable. * Fixed a whole bunch of console message issues such as naming and categorisation --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServer.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 4 ++-- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 17829b2..9dbd50e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - System.Console.WriteLine("Creating Asset cache"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary(); @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) { - System.Console.WriteLine("Creating Asset cache"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); _assetServer = this.LoadAssetDll(assetServerDLLName); diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 22bdc5c..aebda00 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); + MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); if (!yapfile) { @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Cache if (db != null) { - MainLog.Instance.Verbose("Closing local asset server database"); + MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); db.Close(); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 08d5b87..685c0b9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -36,8 +36,8 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() - { - System.Console.WriteLine("Starting Db4o asset storage system"); + { + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting Db4o asset storage system"); this._assetRequests = new BlockingQueue(); this._localAssetServerThread = new Thread( RunRequests ); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 69f83d2..580e5c4 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); } typeInterface = null; @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 65eb509..06a1ca8 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); + MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface"); } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 674c746..f4648df 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.UserManagement public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - MainLog.Instance.Verbose("Attempting login now..."); + MainLog.Instance.Verbose("LOGIN","Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 6acaabefc32525aed7ded45fc15e6152895d5382 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 22 Oct 2007 15:37:54 +0000 Subject: revert r2162 as it completely clobbered all the work on the ChatModule by MW and myself. Couldn't find Adam online after that rev went in. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServer.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 4 ++-- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 9dbd50e..17829b2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); + System.Console.WriteLine("Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary(); @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); + System.Console.WriteLine("Creating Asset cache"); _assetServer = this.LoadAssetDll(assetServerDLLName); diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index aebda00..22bdc5c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); + MainLog.Instance.Verbose("Db4 Asset database creation"); if (!yapfile) { @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Cache if (db != null) { - MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); + MainLog.Instance.Verbose("Closing local asset server database"); db.Close(); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 685c0b9..08d5b87 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -36,8 +36,8 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() - { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting Db4o asset storage system"); + { + System.Console.WriteLine("Starting Db4o asset storage system"); this._assetRequests = new BlockingQueue(); this._localAssetServerThread = new Thread( RunRequests ); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 580e5c4..69f83d2 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); } typeInterface = null; @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 06a1ca8..65eb509 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface"); + MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f4648df..674c746 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.UserManagement public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - MainLog.Instance.Verbose("LOGIN","Attempting login now..."); + MainLog.Instance.Verbose("Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 5dad0ed7296b4abfe2c934a8404022a4d2189051 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 22 Oct 2007 21:57:32 +0000 Subject: * Return of R2162. /Take that SVN!/ --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServer.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 2 +- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 4 ++-- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 17829b2..9dbd50e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - System.Console.WriteLine("Creating Asset cache"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary(); @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) { - System.Console.WriteLine("Creating Asset cache"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); _assetServer = this.LoadAssetDll(assetServerDLLName); diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 22bdc5c..aebda00 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("Db4 Asset database creation"); + MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); if (!yapfile) { @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Cache if (db != null) { - MainLog.Instance.Verbose("Closing local asset server database"); + MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); db.Close(); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 08d5b87..a3ec346 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -37,7 +37,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { - System.Console.WriteLine("Starting Db4o asset storage system"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting Db4o asset storage system"); this._assetRequests = new BlockingQueue(); this._localAssetServerThread = new Thread( RunRequests ); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 69f83d2..580e5c4 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); } typeInterface = null; @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 65eb509..06a1ca8 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); + MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface"); } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 674c746..f4648df 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.UserManagement public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - MainLog.Instance.Verbose("Attempting login now..."); + MainLog.Instance.Verbose("LOGIN","Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 3143768468e7fc5a6443c2cde398d8b9fade76de Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 22 Oct 2007 22:37:39 +0000 Subject: * Removed plenty more untagged console messages. Everything now has shiny groups. :) --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 4ed59c7..899fb61 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.Capabilities /// public void RegisterHandlers() { - Console.WriteLine("registering CAPS handlers"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("CAPS","Registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; try { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f4648df..77b9283 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -199,8 +199,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { - MainLog.Instance.Verbose( - "Authenticating " + profile.username + " " + profile.surname); + MainLog.Instance.Verbose("LOGIN","Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ -- cgit v1.1 From 44ee28d9639008f68c9bf3fdf1d676611aac26b4 Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Wed, 24 Oct 2007 04:07:41 +0000 Subject: Part of supporting gridwide assetss. A little premature release, but I'm tired of conflicts. --- .../Framework/Communications/Cache/AssetCache.cs | 24 +--------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 9dbd50e..271934f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -87,28 +87,6 @@ namespace OpenSim.Framework.Communications.Cache } - public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) - { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); - _assetServer = this.LoadAssetDll(assetServerDLLName); - - - // TODO: This actually does nothing to no IAssetServer implementor. Delete? - _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(); - - this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders)); - this.TextureSenderThread.IsBackground = true; - this.TextureSenderThread.Start(); - } - /// /// /// @@ -796,4 +774,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} -- cgit v1.1 From 60e45418654975d27633a683b57c7013b98a23e3 Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Thu, 25 Oct 2007 09:26:47 +0000 Subject: Created a generic RESTClient component, which simplifies querying for resources from REST based web-services. Currently it supports a barebones scheme for specifying the path of the resource and querying asynchroneously. POST method is still wacky and a good solid scheme for handling timeout still remain. --- .../RestClient/GenericAsyncResult.cs | 163 ++++++++++ .../Communications/RestClient/RestClient.cs | 328 +++++++++++++++++++++ 2 files changed, 491 insertions(+) create mode 100644 OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs create mode 100644 OpenSim/Framework/Communications/RestClient/RestClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs new file mode 100644 index 0000000..4be459d --- /dev/null +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; + +namespace OpenSim.Framework.RestClient +{ + internal class SimpleAsyncResult : IAsyncResult + { + + private readonly AsyncCallback m_callback; + + /// + /// Is process completed? + /// + /// Should really be boolean, but VolatileRead has no boolean method + private byte m_completed; + + /// + /// Did process complete synchroneously? + /// + /// I have a hard time imagining a scenario where this is the case, again, same issue about + /// booleans and VolatileRead as m_completed + /// + private byte m_completedSynchronously; + + private readonly object m_asyncState; + private ManualResetEvent m_waitHandle; + private Exception m_exception; + + internal SimpleAsyncResult(AsyncCallback cb, object state) + { + m_callback = cb; + m_asyncState = state; + m_completed = 0; + m_completedSynchronously = 1; + } + + + #region IAsyncResult Members + + public object AsyncState + { + get { return m_asyncState; } + } + + + + public WaitHandle AsyncWaitHandle + { + get + { + if (m_waitHandle == null) + { + bool done = IsCompleted; + ManualResetEvent mre = new ManualResetEvent(done); + if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) + { + mre.Close(); + } + else + { + if (!done && IsCompleted) + { + m_waitHandle.Set(); + } + } + } + return m_waitHandle; + } + } + + + public bool CompletedSynchronously + { + get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } + } + + + public bool IsCompleted + { + get { return Thread.VolatileRead(ref m_completed) == 1; } + } + + + #endregion + + + #region class Methods + internal void SetAsCompleted(bool completedSynchronously) + { + m_completed = 1; + if(completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + + SignalCompletion(); + } + + internal void HandleException(Exception e, bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + m_exception = e; + + SignalCompletion(); + } + + private void SignalCompletion() + { + if(m_waitHandle != null) m_waitHandle.Set(); + + if(m_callback != null) m_callback(this); + } + + public void EndInvoke() + { + // This method assumes that only 1 thread calls EndInvoke + if (!IsCompleted) + { + // If the operation isn't done, wait for it + AsyncWaitHandle.WaitOne(); + AsyncWaitHandle.Close(); + m_waitHandle = null; // Allow early GC + } + + // Operation is done: if an exception occured, throw it + if (m_exception != null) throw m_exception; + } + + #endregion + } + + internal class AsyncResult : SimpleAsyncResult + { + private T m_result = default(T); + + public AsyncResult(AsyncCallback asyncCallback, Object state) : + base(asyncCallback, state) { } + + + public void SetAsCompleted(T result, bool completedSynchronously) + { + // Save the asynchronous operation's result + m_result = result; + + // Tell the base class that the operation completed + // sucessfully (no exception) + base.SetAsCompleted(completedSynchronously); + } + + new public T EndInvoke() + { + base.EndInvoke(); + return m_result; + } + + } +} diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs new file mode 100644 index 0000000..ccf8376 --- /dev/null +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -0,0 +1,328 @@ +using System; +using System.IO; +using System.Net; +using System.Web; +using System.Text; +using System.Collections.Generic; +using System.Threading; + +namespace OpenSim.Framework.RestClient +{ + /// + /// Implementation of a generic REST client + /// + /// + /// This class is a generic implementation of a REST (Representational State Transfer) web service. This + /// class is designed to execute both synchroneously and asynchroneously. + /// + /// Internally the implementation works as a two stage asynchroneous web-client. + /// When the request is initiated, RestClient will query asynchroneously for for a web-response, + /// sleeping until the initial response is returned by the server. Once the initial response is retrieved + /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response + /// object into a memorystream as a sequence of asynchroneous reads. + /// + /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing + /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be + /// invoked by the caller in either synchroneous mode or asynchroneous mode. + /// + public class RestClient + { + /// + /// The base Uri of the web-service e.g. http://www.google.com + /// + private string _url; + + /// + /// Path elements of the query + /// + private List _pathElements = new List(); + + /// + /// Parameter elements of the query, e.g. min=34 + /// + private Dictionary _parameterElements = new Dictionary(); + + /// + /// Request method. E.g. GET, POST, PUT or DELETE + /// + private string _method; + + /// + /// Temporary buffer used to store bytes temporarily as they come in from the server + /// + private byte[] _readbuf; + + /// + /// MemoryStream representing the resultiong resource + /// + MemoryStream _resource; + + /// + /// WebRequest object, held as a member variable + /// + private HttpWebRequest _request; + + /// + /// WebResponse object, held as a member variable, so we can close it + /// + private HttpWebResponse _response; + + /// + /// This flag will help block the main synchroneous method, in case we run in synchroneous mode + /// + public static ManualResetEvent _allDone = new ManualResetEvent(false); + + /// + /// Default time out period + /// + const int DefaultTimeout = 10 * 1000; // 10 seconds timeout + + /// + /// Default Buffer size of a block requested from the web-server + /// + const int BufferSize = 4096; // Read blocks of 4 KB. + + + /// + /// if an exception occours during async processing, we need to save it, so it can be + /// rethrown on the primary thread; + /// + private Exception _asyncException; + + /// + /// Instantiate a new RestClient + /// + /// Web-service to query, e.g. http://osgrid.org:8003 + public RestClient(string url) + { + _url = url; + _readbuf = new byte[BufferSize]; + _resource = new MemoryStream(); + _request = null; + _response = null; + } + + /// + /// Add a path element to the query, e.g. assets + /// + /// path entry + public void AddResourcePath(string element) + { + if(isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length-1)); + else + _pathElements.Add(element); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + /// Value of the parameter, e.g. 42 + public void AddQueryParameter(string name, string value) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + } + + /// + /// Web-Request method, e.g. GET, PUT, POST, DELETE + /// + public string RequestMethod + { + get { return _method; } + set { _method = value; } + } + + /// + /// True if string contains a trailing slash '/' + /// + /// string to be examined + /// true if slash is present + private bool isSlashed(string s) + { + return s.Substring(s.Length - 1, 1) == "/"; + } + + /// + /// return a slash or blank. A slash will be returned if the string does not contain one + /// + /// stromg to be examined + /// slash '/' if not already present + private string slash(string s) + { + return isSlashed(s) ? "" : "/"; + } + + /// + /// Build a Uri based on the intial Url, path elements and parameters + /// + /// fully constructed Uri + Uri buildUri() + { + StringBuilder sb = new StringBuilder(); + sb.Append(_url); + + foreach (string e in _pathElements) + { + sb.Append("/"); + sb.Append(e); + } + + bool firstElement = true; + foreach (KeyValuePair kv in _parameterElements) + { + if (firstElement) + { + sb.Append("?"); + firstElement = false; + } else + sb.Append("&"); + + sb.Append(kv.Key); + if (kv.Value != null && kv.Value.Length != 0) + { + sb.Append("="); + sb.Append(kv.Value); + } + } + return new Uri(sb.ToString()); + } + + /// + /// Async method, invoked when a block of data has been received from the service + /// + /// + private void StreamIsReadyDelegate(IAsyncResult ar) + { + try + { + Stream s = (Stream)ar.AsyncState; + int read = s.EndRead(ar); + + // Read the HTML page and then print it to the console. + if (read > 0) + { + _resource.Write(_readbuf, 0, read); + IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + return; + } + else + { + s.Close(); + _allDone.Set(); + } + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + /// + /// Async method, invoked when the intial response if received from the server + /// + /// + private void ResponseIsReadyDelegate(IAsyncResult ar) + { + try + { + // grab response + WebRequest wr = (WebRequest)ar.AsyncState; + _response = (HttpWebResponse)wr.EndGetResponse(ar); + + // get response stream, and setup async reading + Stream s = _response.GetResponseStream(); + IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + // wait until completed, or we timed out + // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + // Abort the request if the timer fires. + private static void TimeoutCallback(object state, bool timedOut) + { + if (timedOut) + { + HttpWebRequest request = state as HttpWebRequest; + if (request != null) + { + request.Abort(); + } + } + } + + /// + /// Perform synchroneous request + /// + public Stream Request() + { + _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "text/html"; + _request.Timeout = 200; + _asyncException = null; + + IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + + _allDone.WaitOne(); + if(_response != null) + _response.Close(); + if (_asyncException != null) + throw _asyncException; + return _resource; + } + + #region Async Invocation + public IAsyncResult BeginRequest(AsyncCallback callback, object state) + { + /// + /// In case, we are invoked asynchroneously this object will keep track of the state + /// + AsyncResult ar = new AsyncResult(callback, state); + ThreadPool.QueueUserWorkItem(RequestHelper, ar); + return ar; + } + + public Stream EndRequest(IAsyncResult asyncResult) + { + AsyncResult ar = (AsyncResult)asyncResult; + + // Wait for operation to complete, then return result or + // throw exception + return ar.EndInvoke(); + } + + private void RequestHelper(Object asyncResult) + { + // We know that it's really an AsyncResult object + AsyncResult ar = (AsyncResult)asyncResult; + try + { + // Perform the operation; if sucessful set the result + Stream s = Request(); + ar.SetAsCompleted(s, false); + } + catch (Exception e) + { + // If operation fails, set the exception + ar.HandleException(e, false); + } + } + #endregion Async Invocation + } +} -- cgit v1.1 From 461eaf188e953096360abfa8baf9cbe8bdef3a8a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 25 Oct 2007 15:43:48 +0000 Subject: fix line endings --- .../RestClient/GenericAsyncResult.cs | 326 +++++----- .../Communications/RestClient/RestClient.cs | 656 ++++++++++----------- 2 files changed, 491 insertions(+), 491 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index 4be459d..55456ae 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -1,163 +1,163 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace OpenSim.Framework.RestClient -{ - internal class SimpleAsyncResult : IAsyncResult - { - - private readonly AsyncCallback m_callback; - - /// - /// Is process completed? - /// - /// Should really be boolean, but VolatileRead has no boolean method - private byte m_completed; - - /// - /// Did process complete synchroneously? - /// - /// I have a hard time imagining a scenario where this is the case, again, same issue about - /// booleans and VolatileRead as m_completed - /// - private byte m_completedSynchronously; - - private readonly object m_asyncState; - private ManualResetEvent m_waitHandle; - private Exception m_exception; - - internal SimpleAsyncResult(AsyncCallback cb, object state) - { - m_callback = cb; - m_asyncState = state; - m_completed = 0; - m_completedSynchronously = 1; - } - - - #region IAsyncResult Members - - public object AsyncState - { - get { return m_asyncState; } - } - - - - public WaitHandle AsyncWaitHandle - { - get - { - if (m_waitHandle == null) - { - bool done = IsCompleted; - ManualResetEvent mre = new ManualResetEvent(done); - if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) - { - mre.Close(); - } - else - { - if (!done && IsCompleted) - { - m_waitHandle.Set(); - } - } - } - return m_waitHandle; - } - } - - - public bool CompletedSynchronously - { - get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } - } - - - public bool IsCompleted - { - get { return Thread.VolatileRead(ref m_completed) == 1; } - } - - - #endregion - - - #region class Methods - internal void SetAsCompleted(bool completedSynchronously) - { - m_completed = 1; - if(completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - - SignalCompletion(); - } - - internal void HandleException(Exception e, bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - m_exception = e; - - SignalCompletion(); - } - - private void SignalCompletion() - { - if(m_waitHandle != null) m_waitHandle.Set(); - - if(m_callback != null) m_callback(this); - } - - public void EndInvoke() - { - // This method assumes that only 1 thread calls EndInvoke - if (!IsCompleted) - { - // If the operation isn't done, wait for it - AsyncWaitHandle.WaitOne(); - AsyncWaitHandle.Close(); - m_waitHandle = null; // Allow early GC - } - - // Operation is done: if an exception occured, throw it - if (m_exception != null) throw m_exception; - } - - #endregion - } - - internal class AsyncResult : SimpleAsyncResult - { - private T m_result = default(T); - - public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) { } - - - public void SetAsCompleted(T result, bool completedSynchronously) - { - // Save the asynchronous operation's result - m_result = result; - - // Tell the base class that the operation completed - // sucessfully (no exception) - base.SetAsCompleted(completedSynchronously); - } - - new public T EndInvoke() - { - base.EndInvoke(); - return m_result; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; + +namespace OpenSim.Framework.RestClient +{ + internal class SimpleAsyncResult : IAsyncResult + { + + private readonly AsyncCallback m_callback; + + /// + /// Is process completed? + /// + /// Should really be boolean, but VolatileRead has no boolean method + private byte m_completed; + + /// + /// Did process complete synchroneously? + /// + /// I have a hard time imagining a scenario where this is the case, again, same issue about + /// booleans and VolatileRead as m_completed + /// + private byte m_completedSynchronously; + + private readonly object m_asyncState; + private ManualResetEvent m_waitHandle; + private Exception m_exception; + + internal SimpleAsyncResult(AsyncCallback cb, object state) + { + m_callback = cb; + m_asyncState = state; + m_completed = 0; + m_completedSynchronously = 1; + } + + + #region IAsyncResult Members + + public object AsyncState + { + get { return m_asyncState; } + } + + + + public WaitHandle AsyncWaitHandle + { + get + { + if (m_waitHandle == null) + { + bool done = IsCompleted; + ManualResetEvent mre = new ManualResetEvent(done); + if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) + { + mre.Close(); + } + else + { + if (!done && IsCompleted) + { + m_waitHandle.Set(); + } + } + } + return m_waitHandle; + } + } + + + public bool CompletedSynchronously + { + get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } + } + + + public bool IsCompleted + { + get { return Thread.VolatileRead(ref m_completed) == 1; } + } + + + #endregion + + + #region class Methods + internal void SetAsCompleted(bool completedSynchronously) + { + m_completed = 1; + if(completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + + SignalCompletion(); + } + + internal void HandleException(Exception e, bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + m_exception = e; + + SignalCompletion(); + } + + private void SignalCompletion() + { + if(m_waitHandle != null) m_waitHandle.Set(); + + if(m_callback != null) m_callback(this); + } + + public void EndInvoke() + { + // This method assumes that only 1 thread calls EndInvoke + if (!IsCompleted) + { + // If the operation isn't done, wait for it + AsyncWaitHandle.WaitOne(); + AsyncWaitHandle.Close(); + m_waitHandle = null; // Allow early GC + } + + // Operation is done: if an exception occured, throw it + if (m_exception != null) throw m_exception; + } + + #endregion + } + + internal class AsyncResult : SimpleAsyncResult + { + private T m_result = default(T); + + public AsyncResult(AsyncCallback asyncCallback, Object state) : + base(asyncCallback, state) { } + + + public void SetAsCompleted(T result, bool completedSynchronously) + { + // Save the asynchronous operation's result + m_result = result; + + // Tell the base class that the operation completed + // sucessfully (no exception) + base.SetAsCompleted(completedSynchronously); + } + + new public T EndInvoke() + { + base.EndInvoke(); + return m_result; + } + + } +} diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index ccf8376..25fc61a 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -1,328 +1,328 @@ -using System; -using System.IO; -using System.Net; -using System.Web; -using System.Text; -using System.Collections.Generic; -using System.Threading; - -namespace OpenSim.Framework.RestClient -{ - /// - /// Implementation of a generic REST client - /// - /// - /// This class is a generic implementation of a REST (Representational State Transfer) web service. This - /// class is designed to execute both synchroneously and asynchroneously. - /// - /// Internally the implementation works as a two stage asynchroneous web-client. - /// When the request is initiated, RestClient will query asynchroneously for for a web-response, - /// sleeping until the initial response is returned by the server. Once the initial response is retrieved - /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response - /// object into a memorystream as a sequence of asynchroneous reads. - /// - /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing - /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be - /// invoked by the caller in either synchroneous mode or asynchroneous mode. - /// - public class RestClient - { - /// - /// The base Uri of the web-service e.g. http://www.google.com - /// - private string _url; - - /// - /// Path elements of the query - /// - private List _pathElements = new List(); - - /// - /// Parameter elements of the query, e.g. min=34 - /// - private Dictionary _parameterElements = new Dictionary(); - - /// - /// Request method. E.g. GET, POST, PUT or DELETE - /// - private string _method; - - /// - /// Temporary buffer used to store bytes temporarily as they come in from the server - /// - private byte[] _readbuf; - - /// - /// MemoryStream representing the resultiong resource - /// - MemoryStream _resource; - - /// - /// WebRequest object, held as a member variable - /// - private HttpWebRequest _request; - - /// - /// WebResponse object, held as a member variable, so we can close it - /// - private HttpWebResponse _response; - - /// - /// This flag will help block the main synchroneous method, in case we run in synchroneous mode - /// - public static ManualResetEvent _allDone = new ManualResetEvent(false); - - /// - /// Default time out period - /// - const int DefaultTimeout = 10 * 1000; // 10 seconds timeout - - /// - /// Default Buffer size of a block requested from the web-server - /// - const int BufferSize = 4096; // Read blocks of 4 KB. - - - /// - /// if an exception occours during async processing, we need to save it, so it can be - /// rethrown on the primary thread; - /// - private Exception _asyncException; - - /// - /// Instantiate a new RestClient - /// - /// Web-service to query, e.g. http://osgrid.org:8003 - public RestClient(string url) - { - _url = url; - _readbuf = new byte[BufferSize]; - _resource = new MemoryStream(); - _request = null; - _response = null; - } - - /// - /// Add a path element to the query, e.g. assets - /// - /// path entry - public void AddResourcePath(string element) - { - if(isSlashed(element)) - _pathElements.Add(element.Substring(0, element.Length-1)); - else - _pathElements.Add(element); - } - - /// - /// Add a query parameter to the Url - /// - /// Name of the parameter, e.g. min - /// Value of the parameter, e.g. 42 - public void AddQueryParameter(string name, string value) - { - _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); - } - - /// - /// Web-Request method, e.g. GET, PUT, POST, DELETE - /// - public string RequestMethod - { - get { return _method; } - set { _method = value; } - } - - /// - /// True if string contains a trailing slash '/' - /// - /// string to be examined - /// true if slash is present - private bool isSlashed(string s) - { - return s.Substring(s.Length - 1, 1) == "/"; - } - - /// - /// return a slash or blank. A slash will be returned if the string does not contain one - /// - /// stromg to be examined - /// slash '/' if not already present - private string slash(string s) - { - return isSlashed(s) ? "" : "/"; - } - - /// - /// Build a Uri based on the intial Url, path elements and parameters - /// - /// fully constructed Uri - Uri buildUri() - { - StringBuilder sb = new StringBuilder(); - sb.Append(_url); - - foreach (string e in _pathElements) - { - sb.Append("/"); - sb.Append(e); - } - - bool firstElement = true; - foreach (KeyValuePair kv in _parameterElements) - { - if (firstElement) - { - sb.Append("?"); - firstElement = false; - } else - sb.Append("&"); - - sb.Append(kv.Key); - if (kv.Value != null && kv.Value.Length != 0) - { - sb.Append("="); - sb.Append(kv.Value); - } - } - return new Uri(sb.ToString()); - } - - /// - /// Async method, invoked when a block of data has been received from the service - /// - /// - private void StreamIsReadyDelegate(IAsyncResult ar) - { - try - { - Stream s = (Stream)ar.AsyncState; - int read = s.EndRead(ar); - - // Read the HTML page and then print it to the console. - if (read > 0) - { - _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - return; - } - else - { - s.Close(); - _allDone.Set(); - } - } - catch (Exception e) - { - _allDone.Set(); - _asyncException = e; - } - } - - /// - /// Async method, invoked when the intial response if received from the server - /// - /// - private void ResponseIsReadyDelegate(IAsyncResult ar) - { - try - { - // grab response - WebRequest wr = (WebRequest)ar.AsyncState; - _response = (HttpWebResponse)wr.EndGetResponse(ar); - - // get response stream, and setup async reading - Stream s = _response.GetResponseStream(); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - // wait until completed, or we timed out - // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - } - catch (Exception e) - { - _allDone.Set(); - _asyncException = e; - } - } - - // Abort the request if the timer fires. - private static void TimeoutCallback(object state, bool timedOut) - { - if (timedOut) - { - HttpWebRequest request = state as HttpWebRequest; - if (request != null) - { - request.Abort(); - } - } - } - - /// - /// Perform synchroneous request - /// - public Stream Request() - { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); - _request.KeepAlive = false; - _request.ContentType = "text/html"; - _request.Timeout = 200; - _asyncException = null; - - IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - - _allDone.WaitOne(); - if(_response != null) - _response.Close(); - if (_asyncException != null) - throw _asyncException; - return _resource; - } - - #region Async Invocation - public IAsyncResult BeginRequest(AsyncCallback callback, object state) - { - /// - /// In case, we are invoked asynchroneously this object will keep track of the state - /// - AsyncResult ar = new AsyncResult(callback, state); - ThreadPool.QueueUserWorkItem(RequestHelper, ar); - return ar; - } - - public Stream EndRequest(IAsyncResult asyncResult) - { - AsyncResult ar = (AsyncResult)asyncResult; - - // Wait for operation to complete, then return result or - // throw exception - return ar.EndInvoke(); - } - - private void RequestHelper(Object asyncResult) - { - // We know that it's really an AsyncResult object - AsyncResult ar = (AsyncResult)asyncResult; - try - { - // Perform the operation; if sucessful set the result - Stream s = Request(); - ar.SetAsCompleted(s, false); - } - catch (Exception e) - { - // If operation fails, set the exception - ar.HandleException(e, false); - } - } - #endregion Async Invocation - } -} +using System; +using System.IO; +using System.Net; +using System.Web; +using System.Text; +using System.Collections.Generic; +using System.Threading; + +namespace OpenSim.Framework.RestClient +{ + /// + /// Implementation of a generic REST client + /// + /// + /// This class is a generic implementation of a REST (Representational State Transfer) web service. This + /// class is designed to execute both synchroneously and asynchroneously. + /// + /// Internally the implementation works as a two stage asynchroneous web-client. + /// When the request is initiated, RestClient will query asynchroneously for for a web-response, + /// sleeping until the initial response is returned by the server. Once the initial response is retrieved + /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response + /// object into a memorystream as a sequence of asynchroneous reads. + /// + /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing + /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be + /// invoked by the caller in either synchroneous mode or asynchroneous mode. + /// + public class RestClient + { + /// + /// The base Uri of the web-service e.g. http://www.google.com + /// + private string _url; + + /// + /// Path elements of the query + /// + private List _pathElements = new List(); + + /// + /// Parameter elements of the query, e.g. min=34 + /// + private Dictionary _parameterElements = new Dictionary(); + + /// + /// Request method. E.g. GET, POST, PUT or DELETE + /// + private string _method; + + /// + /// Temporary buffer used to store bytes temporarily as they come in from the server + /// + private byte[] _readbuf; + + /// + /// MemoryStream representing the resultiong resource + /// + MemoryStream _resource; + + /// + /// WebRequest object, held as a member variable + /// + private HttpWebRequest _request; + + /// + /// WebResponse object, held as a member variable, so we can close it + /// + private HttpWebResponse _response; + + /// + /// This flag will help block the main synchroneous method, in case we run in synchroneous mode + /// + public static ManualResetEvent _allDone = new ManualResetEvent(false); + + /// + /// Default time out period + /// + const int DefaultTimeout = 10 * 1000; // 10 seconds timeout + + /// + /// Default Buffer size of a block requested from the web-server + /// + const int BufferSize = 4096; // Read blocks of 4 KB. + + + /// + /// if an exception occours during async processing, we need to save it, so it can be + /// rethrown on the primary thread; + /// + private Exception _asyncException; + + /// + /// Instantiate a new RestClient + /// + /// Web-service to query, e.g. http://osgrid.org:8003 + public RestClient(string url) + { + _url = url; + _readbuf = new byte[BufferSize]; + _resource = new MemoryStream(); + _request = null; + _response = null; + } + + /// + /// Add a path element to the query, e.g. assets + /// + /// path entry + public void AddResourcePath(string element) + { + if(isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length-1)); + else + _pathElements.Add(element); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + /// Value of the parameter, e.g. 42 + public void AddQueryParameter(string name, string value) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + } + + /// + /// Web-Request method, e.g. GET, PUT, POST, DELETE + /// + public string RequestMethod + { + get { return _method; } + set { _method = value; } + } + + /// + /// True if string contains a trailing slash '/' + /// + /// string to be examined + /// true if slash is present + private bool isSlashed(string s) + { + return s.Substring(s.Length - 1, 1) == "/"; + } + + /// + /// return a slash or blank. A slash will be returned if the string does not contain one + /// + /// stromg to be examined + /// slash '/' if not already present + private string slash(string s) + { + return isSlashed(s) ? "" : "/"; + } + + /// + /// Build a Uri based on the intial Url, path elements and parameters + /// + /// fully constructed Uri + Uri buildUri() + { + StringBuilder sb = new StringBuilder(); + sb.Append(_url); + + foreach (string e in _pathElements) + { + sb.Append("/"); + sb.Append(e); + } + + bool firstElement = true; + foreach (KeyValuePair kv in _parameterElements) + { + if (firstElement) + { + sb.Append("?"); + firstElement = false; + } else + sb.Append("&"); + + sb.Append(kv.Key); + if (kv.Value != null && kv.Value.Length != 0) + { + sb.Append("="); + sb.Append(kv.Value); + } + } + return new Uri(sb.ToString()); + } + + /// + /// Async method, invoked when a block of data has been received from the service + /// + /// + private void StreamIsReadyDelegate(IAsyncResult ar) + { + try + { + Stream s = (Stream)ar.AsyncState; + int read = s.EndRead(ar); + + // Read the HTML page and then print it to the console. + if (read > 0) + { + _resource.Write(_readbuf, 0, read); + IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + return; + } + else + { + s.Close(); + _allDone.Set(); + } + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + /// + /// Async method, invoked when the intial response if received from the server + /// + /// + private void ResponseIsReadyDelegate(IAsyncResult ar) + { + try + { + // grab response + WebRequest wr = (WebRequest)ar.AsyncState; + _response = (HttpWebResponse)wr.EndGetResponse(ar); + + // get response stream, and setup async reading + Stream s = _response.GetResponseStream(); + IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + // wait until completed, or we timed out + // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + // Abort the request if the timer fires. + private static void TimeoutCallback(object state, bool timedOut) + { + if (timedOut) + { + HttpWebRequest request = state as HttpWebRequest; + if (request != null) + { + request.Abort(); + } + } + } + + /// + /// Perform synchroneous request + /// + public Stream Request() + { + _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "text/html"; + _request.Timeout = 200; + _asyncException = null; + + IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + + _allDone.WaitOne(); + if(_response != null) + _response.Close(); + if (_asyncException != null) + throw _asyncException; + return _resource; + } + + #region Async Invocation + public IAsyncResult BeginRequest(AsyncCallback callback, object state) + { + /// + /// In case, we are invoked asynchroneously this object will keep track of the state + /// + AsyncResult ar = new AsyncResult(callback, state); + ThreadPool.QueueUserWorkItem(RequestHelper, ar); + return ar; + } + + public Stream EndRequest(IAsyncResult asyncResult) + { + AsyncResult ar = (AsyncResult)asyncResult; + + // Wait for operation to complete, then return result or + // throw exception + return ar.EndInvoke(); + } + + private void RequestHelper(Object asyncResult) + { + // We know that it's really an AsyncResult object + AsyncResult ar = (AsyncResult)asyncResult; + try + { + // Perform the operation; if sucessful set the result + Stream s = Request(); + ar.SetAsCompleted(s, false); + } + catch (Exception e) + { + // If operation fails, set the exception + ar.HandleException(e, false); + } + } + #endregion Async Invocation + } +} -- cgit v1.1 From 5e7dba726896fcb84882b53952651742926e6efb Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Fri, 26 Oct 2007 11:46:27 +0000 Subject: Very early first implementation of grid based assets. Run this on a major grid, and weep --- .../Framework/Communications/Cache/AssetCache.cs | 11 +- .../Communications/Cache/AssetServerBase.cs | 36 ++--- .../Communications/Cache/GridAssetClient.cs | 160 +++++++++++++++++++++ .../RestClient/GenericAsyncResult.cs | 2 +- .../Communications/RestClient/RestClient.cs | 101 +++++++++++-- 5 files changed, 272 insertions(+), 38 deletions(-) create mode 100644 OpenSim/Framework/Communications/Cache/GridAssetClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 271934f..95183ad 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -36,6 +36,7 @@ using libsecondlife.Packets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { @@ -319,17 +320,19 @@ namespace OpenSim.Framework.Communications.Cache public void AssetNotFound(LLUUID assetID) { - /* if (this.RequestedTextures.ContainsKey(assetID)) { + MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID); AssetRequest req = this.RequestedTextures[assetID]; ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); notFound.ImageID.ID = assetID; req.RequestUser.OutPacket(notFound); - //Console.WriteLine("sending image not found for " + assetID); - this.RequestedTextures.Remove(assetID); - }*/ + } + else + { + MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID); + } } #region Assets diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index a3ec346..53efa16 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -108,23 +108,23 @@ namespace OpenSim.Framework.Communications.Cache public virtual List GetDefaultAssets() { List assets = new List(); - - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); - assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); - - assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); - assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); - assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); - assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); + // These assets have been moved into the OpenSimAssetSet.XML file + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); + //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2")); + + //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); + //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); + //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); + //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); return assets; } @@ -185,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs new file mode 100644 index 0000000..fc77431 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -0,0 +1,160 @@ +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using System.Xml.Serialization; + +using libsecondlife; + +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Communications; + +namespace OpenSim.Framework.Communications.Cache +{ + public class GridAssetClient : IAssetServer + { + private string _assetServerUrl; + private IAssetReceiver _receiver; + + public GridAssetClient(string serverUrl) + { + _assetServerUrl = serverUrl; + } + + #region IAssetServer Members + + public void SetReceiver(IAssetReceiver receiver) + { + _receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + Stream s = null; + try + { + + MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(assetID.ToString()); + if (isTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + s = rc.Request(); + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + AssetBase asset = (AssetBase)xs.Deserialize(s); + + _receiver.AssetReceived(asset, isTexture); + } + else + { + MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); + _receiver.AssetNotFound(assetID); + } + } + catch (Exception e) + { + MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + } + } + + public void UpdateAsset(AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + public void StoreAndCommitAsset(AssetBase asset) + { + try + { + MemoryStream s = new MemoryStream(); + + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + xs.Serialize(s, asset); + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.RequestMethod = "POST"; + rc.Request(s); + } + catch (Exception e) + { + MainLog.Instance.Error("ASSETS", e.Message); + } + } + + public void Close() + { + throw new Exception("The method or operation is not implemented."); + } + + public void LoadAsset(AssetBase info, bool image, string filename) + { + throw new Exception("The method or operation is not implemented."); + } + + public System.Collections.Generic.List GetDefaultAssets() + { + throw new Exception("The method or operation is not implemented."); + } + + public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) + { + throw new Exception("The method or operation is not implemented."); + } + + public void ForEachDefaultAsset(Action action) + { + throw new Exception("The method or operation is not implemented."); + } + + public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) + { + throw new Exception("The method or operation is not implemented."); + } + + public void ForEachXmlAsset(Action action) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + } +} diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index 55456ae..c821fa4 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Threading; -namespace OpenSim.Framework.RestClient +namespace OpenSim.Framework.Communications { internal class SimpleAsyncResult : IAsyncResult { diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 25fc61a..392669f 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -6,7 +6,9 @@ using System.Text; using System.Collections.Generic; using System.Threading; -namespace OpenSim.Framework.RestClient +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Communications { /// /// Implementation of a generic REST client @@ -25,8 +27,11 @@ namespace OpenSim.Framework.RestClient /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be /// invoked by the caller in either synchroneous mode or asynchroneous mode. /// - public class RestClient + public class RestClient { + + string realuri; + #region member variables /// /// The base Uri of the web-service e.g. http://www.google.com /// @@ -55,7 +60,7 @@ namespace OpenSim.Framework.RestClient /// /// MemoryStream representing the resultiong resource /// - MemoryStream _resource; + Stream _resource; /// /// WebRequest object, held as a member variable @@ -89,6 +94,9 @@ namespace OpenSim.Framework.RestClient /// private Exception _asyncException; + #endregion member variables + + #region constructors /// /// Instantiate a new RestClient /// @@ -100,8 +108,12 @@ namespace OpenSim.Framework.RestClient _resource = new MemoryStream(); _request = null; _response = null; + _lock = new object(); } + object _lock; + #endregion constructors + /// /// Add a path element to the query, e.g. assets /// @@ -125,6 +137,15 @@ namespace OpenSim.Framework.RestClient } /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + public void AddQueryParameter(string name) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), null); + } + + /// /// Web-Request method, e.g. GET, PUT, POST, DELETE /// public string RequestMethod @@ -185,9 +206,10 @@ namespace OpenSim.Framework.RestClient sb.Append(kv.Value); } } + realuri = sb.ToString(); return new Uri(sb.ToString()); } - + #region Async communications with server /// /// Async method, invoked when a block of data has been received from the service /// @@ -199,7 +221,6 @@ namespace OpenSim.Framework.RestClient Stream s = (Stream)ar.AsyncState; int read = s.EndRead(ar); - // Read the HTML page and then print it to the console. if (read > 0) { _resource.Write(_readbuf, 0, read); @@ -207,7 +228,6 @@ namespace OpenSim.Framework.RestClient // TODO! Implement timeout, without killing the server //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - return; } else { @@ -261,32 +281,83 @@ namespace OpenSim.Framework.RestClient } } } + #endregion Async communications with server /// /// Perform synchroneous request /// public Stream Request() { + lock (_lock) + { + _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "application/xml"; + _request.Timeout = 200000; + _asyncException = null; + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + _response = (HttpWebResponse)_request.GetResponse(); + Stream src = _response.GetResponseStream(); + int length = src.Read(_readbuf, 0, BufferSize); + while(length > 0) + { + _resource.Write(_readbuf, 0, length); + length = src.Read(_readbuf, 0, BufferSize); + } + + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + +// _allDone.WaitOne(); + if (_response != null) + _response.Close(); + if (_asyncException != null) + throw _asyncException; + + if (_resource != null) + { + _resource.Flush(); + _resource.Seek(0, SeekOrigin.Begin); + } + + return _resource; + } + } + + public Stream Request(Stream src) + { _request = (HttpWebRequest)WebRequest.Create(buildUri()); _request.KeepAlive = false; - _request.ContentType = "text/html"; - _request.Timeout = 200; + _request.ContentType = "application/xml"; + _request.Timeout = 900000; + _request.Method = RequestMethod; _asyncException = null; + _request.ContentLength = src.Length; - IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + src.Seek(0, SeekOrigin.Begin); + Stream dst = _request.GetRequestStream(); + byte[] buf = new byte[1024]; + int length = src.Read(buf,0, 1024); + while (length > 0) + { + dst.Write(buf, 0, length); + length = src.Read(buf, 0, 1024); + } + _response = (HttpWebResponse)_request.GetResponse(); + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); // TODO! Implement timeout, without killing the server // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - _allDone.WaitOne(); - if(_response != null) - _response.Close(); - if (_asyncException != null) - throw _asyncException; - return _resource; + return null; } + #region Async Invocation public IAsyncResult BeginRequest(AsyncCallback callback, object state) { -- cgit v1.1 From 75be841839d0b4695625da5c2ce2c89b13758485 Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Fri, 26 Oct 2007 13:12:49 +0000 Subject: Region ground texture was not marked as temporary, when being created, and assetcache did not check if an asset was temporary prior to uploading the cache to the asset server. Consequently the asset server was constantly being swamped by temporary ground textures. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 95183ad..a950f51 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -139,25 +139,27 @@ namespace OpenSim.Framework.Communications.Cache if (asset.Type == 0) { //Console.WriteLine("which is a texture"); - if (!this.Textures.ContainsKey(asset.FullID)) + if (!Textures.ContainsKey(asset.FullID)) { //texture TextureImage textur = new TextureImage(asset); - this.Textures.Add(textur.FullID, textur); - this._assetServer.StoreAndCommitAsset(asset); + Textures.Add(textur.FullID, textur); + if(!asset.Temporary) + _assetServer.StoreAndCommitAsset(asset); } else { TextureImage textur = new TextureImage(asset); - this.Textures[asset.FullID] = textur; + Textures[asset.FullID] = textur; } } else { - if (!this.Assets.ContainsKey(asset.FullID)) + if (!Assets.ContainsKey(asset.FullID)) { AssetInfo assetInf = new AssetInfo(asset); - this.Assets.Add(assetInf.FullID, assetInf); - this._assetServer.StoreAndCommitAsset(asset); + Assets.Add(assetInf.FullID, assetInf); + if (!asset.Temporary) + _assetServer.StoreAndCommitAsset(asset); } } } -- cgit v1.1 From 070047ce1bc74cceebd5e817a0e042a7390c5f24 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 26 Oct 2007 14:08:36 +0000 Subject: * Added prototypical AvatarFactory module interface to load avatar parameters * Added dump_assets_to_file option to enable asset dumping for debug * normalized some namespaces * InventoryFolder renamed to InventoryFolderImpl to --- OpenSim/Framework/Communications/CAPSService.cs | 16 +------- .../Cache/AssetTransactionManager.cs | 14 +++---- .../Communications/Cache/AssetTransactions.cs | 28 ++++++++----- .../Communications/Cache/CachedUserInfo.cs | 9 ++--- .../Communications/Cache/InventoryFolder.cs | 26 ++++++------ .../Communications/Cache/LibraryRootFolder.cs | 10 ++--- .../Communications/Cache/UserProfileCache.cs | 23 ++++++----- .../Framework/Communications/Capabilities/Caps.cs | 46 +++++++++------------- .../Communications/CommunicationsManager.cs | 5 +-- .../Framework/Communications/IInventoryServices.cs | 7 ++-- .../Communications/InventoryServiceBase.cs | 4 +- 11 files changed, 87 insertions(+), 101 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index 6f65551..b60ef02 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -26,21 +26,9 @@ * */ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; -using libsecondlife; -using Nwc.XmlRpc; -using OpenSim.Framework.Console; -using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; using OpenSim.Framework.Servers; -namespace OpenSim.Framework.UserManagement +namespace OpenSim.Framework.Communications { public class CAPSService { @@ -63,4 +51,4 @@ namespace OpenSim.Framework.UserManagement return ""; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 42c0a8e..2c1e5c8 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -36,17 +36,19 @@ using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Data; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class AssetTransactionManager { // Fields public CommunicationsManager CommsManager; public Dictionary AgentTransactions = new Dictionary(); + private bool m_dumpAssetsToFile; - public AssetTransactionManager(CommunicationsManager commsManager) + public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile) { CommsManager = commsManager; + m_dumpAssetsToFile = dumpAssetsToFile; } // Methods @@ -54,7 +56,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this); + AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); this.AgentTransactions.Add(userID, transactions); return transactions; } @@ -82,7 +84,7 @@ namespace OpenSim.Framework.Communications.Caches public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) { - // Console.WriteLine("asset upload of " + assetID); + // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); if (transactions != null) { @@ -103,6 +105,4 @@ namespace OpenSim.Framework.Communications.Caches } } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 51fc462..581e300 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Utilities; using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class AgentAssetTransactions { @@ -49,12 +49,14 @@ namespace OpenSim.Framework.Communications.Caches public LLUUID UserID; public Dictionary XferUploaders = new Dictionary(); public AssetTransactionManager Manager; + private bool m_dumpAssetsToFile; // Methods - public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager) + public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) { this.UserID = agentID; Manager = manager; + m_dumpAssetsToFile = dumpAssetsToFile; } public AssetCapsUploader RequestCapsUploader() @@ -75,7 +77,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.XferUploaders.ContainsKey(transactionID)) { - AssetXferUploader uploader = new AssetXferUploader(this); + AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); this.XferUploaders.Add(transactionID, uploader); return uploader; @@ -122,14 +124,14 @@ namespace OpenSim.Framework.Communications.Caches private string m_assetName = ""; private LLUUID m_folderID; private LLUUID newAssetID; - private bool SaveImages = false; + private bool m_dumpImageToFile; private string uploaderPath = ""; // Events public event UpLoadedAsset OnUpLoad; // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) { this.m_assetName = assetName; this.m_assetDescription = assetDescription; @@ -138,6 +140,7 @@ namespace OpenSim.Framework.Communications.Caches this.inventoryItemID = inventoryItem; this.uploaderPath = path; this.httpListener = httpServer; + m_dumpImageToFile = dumpImageToFile; } private void SaveImageToFile(string filename, byte[] data) @@ -159,7 +162,7 @@ namespace OpenSim.Framework.Communications.Caches complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) + if (this.m_dumpImageToFile) { this.SaveImageToFile(this.m_assetName + ".jp2", data); } @@ -190,10 +193,12 @@ namespace OpenSim.Framework.Communications.Caches private bool m_createItem = false; private AgentAssetTransactions m_userTransactions; private bool m_storeLocal; + private bool m_dumpAssetToFile; - public AssetXferUploader(AgentAssetTransactions transactions) + public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) { this.m_userTransactions = transactions; + m_dumpAssetToFile = dumpAssetToFile; } // Methods @@ -278,9 +283,14 @@ namespace OpenSim.Framework.Communications.Caches this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); } - // Console.WriteLine("upload complete "+ this.TransactionID); - //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + // Console.WriteLine("upload complete "+ this.TransactionID); + + if (m_dumpAssetToFile) + { + SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + } } + private void SaveAssetToFile(string filename, byte[] data) { FileStream fs = File.Create(filename); diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b1432ff..92b21a8 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -27,7 +27,6 @@ */ using libsecondlife; using OpenSim.Framework.Types; -using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications.Cache { @@ -35,7 +34,7 @@ namespace OpenSim.Framework.Communications.Cache { private readonly CommunicationsManager m_parentCommsManager; // Fields - public InventoryFolder RootFolder = null; + public InventoryFolderImpl RootFolder = null; public UserProfileData UserProfile = null; public CachedUserInfo(CommunicationsManager commsManager) @@ -44,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache } // Methods - public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) + public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { if (userID == this.UserProfile.UUID) { @@ -61,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { folder.SubFolders.Add(folderInfo.folderID, folderInfo); @@ -80,7 +79,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { folder.Items.Add(itemInfo.inventoryID, itemInfo); diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index fbe1bd0..af3346f 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -35,15 +35,15 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { - public class InventoryFolder : InventoryFolderBase + public class InventoryFolderImpl : InventoryFolderBase { // Fields public Dictionary Items = new Dictionary(); - public Dictionary SubFolders = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); - public InventoryFolder(InventoryFolderBase folderbase) + public InventoryFolderImpl(InventoryFolderBase folderbase) { this.agentID = folderbase.agentID; this.folderID = folderbase.folderID; @@ -53,15 +53,15 @@ namespace OpenSim.Framework.Communications.Caches this.version = folderbase.version; } - public InventoryFolder() + public InventoryFolderImpl() { } // Methods - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { - InventoryFolder subFold = new InventoryFolder(); + InventoryFolderImpl subFold = new InventoryFolderImpl(); subFold.name = folderName; subFold.folderID = folderID; subFold.type = (short) type; @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Caches { return this.Items[itemID]; } - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { base2 = folder.HasItem(itemID); if (base2 != null) @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Caches Items.Remove(itemID); return true; } - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { found = folder.DeleteItem(itemID); if (found == true) @@ -109,16 +109,16 @@ namespace OpenSim.Framework.Communications.Caches } - public InventoryFolder HasSubFolder(LLUUID folderID) + public InventoryFolderImpl HasSubFolder(LLUUID folderID) { - InventoryFolder returnFolder = null; + InventoryFolderImpl returnFolder = null; if (this.SubFolders.ContainsKey(folderID)) { returnFolder = this.SubFolders[folderID]; } else { - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { returnFolder = folder.HasSubFolder(folderID); if (returnFolder != null) @@ -140,4 +140,4 @@ namespace OpenSim.Framework.Communications.Caches return itemList; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 13ce39e..86e26f0 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -35,16 +35,16 @@ using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using Nini.Config; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { /// /// Basically a hack to give us a Inventory library while we don't have a inventory server /// once the server is fully implemented then should read the data from that /// - public class LibraryRootFolder : InventoryFolder + public class LibraryRootFolder : Cache.InventoryFolderImpl { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - private InventoryFolder m_textureFolder; + private Cache.InventoryFolderImpl m_textureFolder; public LibraryRootFolder() { @@ -55,7 +55,7 @@ namespace OpenSim.Framework.Communications.Caches this.type = (short)-1; this.version = (ushort)1; - InventoryFolder folderInfo = new InventoryFolder(); + Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); folderInfo.name = "Texture Library"; @@ -242,4 +242,4 @@ namespace OpenSim.Framework.Communications.Caches } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 362ab17..bd7aeef 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -36,7 +36,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class UserProfileCache { @@ -107,15 +107,15 @@ namespace OpenSim.Framework.Communications.Caches CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - if (createdFolder != null) - { - this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); - } + InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + if (createdFolder != null) + { + this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + } } else { - InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); + InventoryFolderImpl folder = info.RootFolder.HasSubFolder(parentID); if (folder != null) { folder.CreateNewSubFolder(folderID, folderName, folderType); @@ -127,7 +127,7 @@ namespace OpenSim.Framework.Communications.Caches public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - InventoryFolder fold = null; + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID ) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications.Caches } else { - InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); + InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); if ((folder != null) && fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); @@ -185,7 +185,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -223,5 +223,4 @@ namespace OpenSim.Framework.Communications.Caches { } } -} - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 899fb61..095a5b1 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -61,8 +61,9 @@ namespace OpenSim.Region.Capabilities private Queue CapsEventQueue = new Queue(); public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; + private bool m_dumpAssetsToFile; - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { assetCache = assetCach; m_capsObjectPath = capsPath; @@ -70,6 +71,7 @@ namespace OpenSim.Region.Capabilities m_httpListenerHostName = httpListen; m_httpListenPort = httpPort; agentID = agent; + m_dumpAssetsToFile = dumpAssetsToFile; } /// @@ -250,7 +252,7 @@ namespace OpenSim.Region.Capabilities LLUUID newInvItem = llsdRequest.item_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener); + ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile ); uploader.OnUpLoad += this.ItemUpdated; httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); @@ -280,7 +282,7 @@ namespace OpenSim.Region.Capabilities LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -360,21 +362,14 @@ namespace OpenSim.Region.Capabilities private LLUUID inventoryItemID; private LLUUID parentFolder; private BaseHttpServer httpListener; - private bool SaveAssets = false; + private bool m_dumpAssetsToFile; private string m_assetName = ""; private string m_assetDes = ""; private string m_invType = ""; private string m_assetType = ""; - /// - /// - /// - /// - /// - /// - /// - public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer) + public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile) { m_assetName = assetName; m_assetDes = description; @@ -385,7 +380,7 @@ namespace OpenSim.Region.Capabilities parentFolder = parentFolderID; m_assetType = assetType; m_invType = invType; - + m_dumpAssetsToFile = dumpAssetsToFile; } /// @@ -408,8 +403,10 @@ namespace OpenSim.Region.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); - if(this.SaveAssets) + if (this.m_dumpAssetsToFile) + { this.SaveAssetToFile(m_assetName + ".jp2", data); + } if (OnUpLoad != null) { @@ -436,19 +433,12 @@ namespace OpenSim.Region.Capabilities private string uploaderPath = ""; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveAssets = false; - + private bool m_dumpAssetToFile; - /// - /// - /// - /// - /// - /// - /// - public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer) + public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { - + m_dumpAssetToFile = dumpAssetToFile; + inventoryItemID = inventoryItem; uploaderPath = path; httpListener = httpServer; @@ -481,8 +471,10 @@ namespace OpenSim.Region.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); - if (this.SaveAssets) - this.SaveAssetToFile("updateditem"+Util.RandomClass.Next(1,1000) + ".dat", data); + if (this.m_dumpAssetToFile) + { + this.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); + } return res; } diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5af07f7..7a157be 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,7 +28,6 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; @@ -87,12 +86,12 @@ namespace OpenSim.Framework.Communications get { return m_networkServersInfo; } } - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool dumpAssetsToFile) { m_networkServersInfo = serversInfo; m_assetCache = assetCache; m_userProfileCache = new UserProfileCache(this); - m_transactionsManager = new AssetTransactionManager(this); + m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile ); } public void doCreate(string[] cmmdParams) diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index bfc3ee7..5643d78 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -30,19 +30,18 @@ using System; using System.Collections.Generic; using System.Text; using libsecondlife; -using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Types; -using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications { - public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolder folderInfo); + public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); void CreateNewUserInventory(LLUUID user); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 06a1ca8..6549966 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -31,9 +31,9 @@ using System.Collections.Generic; using System.Reflection; using libsecondlife; using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; using OpenSim.Framework.Types; -using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications { @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Communications } public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -- cgit v1.1 From fb6aa6eafc476ff7c2987395cd8c9c8d8fb4e827 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sat, 27 Oct 2007 11:45:52 +0000 Subject: * Added 'Jim' and 'Goblin' shapes; not available in inventory yet though --- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 581e300..f23441d 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -287,7 +287,9 @@ namespace OpenSim.Framework.Communications.Cache if (m_dumpAssetToFile) { - SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + DateTime now = DateTime.Now; + string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type ); + SaveAssetToFile(filename, this.Asset.Data); } } -- cgit v1.1 From 7c6ef95f2f8a4fb06a1359e9625e80e4cb216a5d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 29 Oct 2007 07:57:38 +0000 Subject: normalized line endings --- .../Communications/Cache/GridAssetClient.cs | 320 ++++++++++----------- 1 file changed, 160 insertions(+), 160 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index fc77431..7483582 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -1,160 +1,160 @@ -/* -* 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.IO; -using System.Threading; -using System.Reflection; -using System.Xml.Serialization; - -using libsecondlife; - -using Nini.Config; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Communications; - -namespace OpenSim.Framework.Communications.Cache -{ - public class GridAssetClient : IAssetServer - { - private string _assetServerUrl; - private IAssetReceiver _receiver; - - public GridAssetClient(string serverUrl) - { - _assetServerUrl = serverUrl; - } - - #region IAssetServer Members - - public void SetReceiver(IAssetReceiver receiver) - { - _receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - Stream s = null; - try - { - - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); - - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(assetID.ToString()); - if (isTexture) - rc.AddQueryParameter("texture"); - - rc.RequestMethod = "GET"; - s = rc.Request(); - - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase asset = (AssetBase)xs.Deserialize(s); - - _receiver.AssetReceived(asset, isTexture); - } - else - { - MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); - _receiver.AssetNotFound(assetID); - } - } - catch (Exception e) - { - MainLog.Instance.Error("ASSETCACHE", e.Message); - MainLog.Instance.Error("ASSETCACHE", e.StackTrace); - } - } - - public void UpdateAsset(AssetBase asset) - { - throw new Exception("The method or operation is not implemented."); - } - - public void StoreAndCommitAsset(AssetBase asset) - { - try - { - MemoryStream s = new MemoryStream(); - - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - xs.Serialize(s, asset); - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.RequestMethod = "POST"; - rc.Request(s); - } - catch (Exception e) - { - MainLog.Instance.Error("ASSETS", e.Message); - } - } - - public void Close() - { - throw new Exception("The method or operation is not implemented."); - } - - public void LoadAsset(AssetBase info, bool image, string filename) - { - throw new Exception("The method or operation is not implemented."); - } - - public System.Collections.Generic.List GetDefaultAssets() - { - throw new Exception("The method or operation is not implemented."); - } - - public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachDefaultAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } - - public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachXmlAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } - - #endregion - } -} +/* +* 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.IO; +using System.Threading; +using System.Reflection; +using System.Xml.Serialization; + +using libsecondlife; + +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Communications; + +namespace OpenSim.Framework.Communications.Cache +{ + public class GridAssetClient : IAssetServer + { + private string _assetServerUrl; + private IAssetReceiver _receiver; + + public GridAssetClient(string serverUrl) + { + _assetServerUrl = serverUrl; + } + + #region IAssetServer Members + + public void SetReceiver(IAssetReceiver receiver) + { + _receiver = receiver; + } + + public void FetchAsset(LLUUID assetID, bool isTexture) + { + Stream s = null; + try + { + + MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(assetID.ToString()); + if (isTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + s = rc.Request(); + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + AssetBase asset = (AssetBase)xs.Deserialize(s); + + _receiver.AssetReceived(asset, isTexture); + } + else + { + MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); + _receiver.AssetNotFound(assetID); + } + } + catch (Exception e) + { + MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + } + } + + public void UpdateAsset(AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + public void StoreAndCommitAsset(AssetBase asset) + { + try + { + MemoryStream s = new MemoryStream(); + + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + xs.Serialize(s, asset); + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.RequestMethod = "POST"; + rc.Request(s); + } + catch (Exception e) + { + MainLog.Instance.Error("ASSETS", e.Message); + } + } + + public void Close() + { + throw new Exception("The method or operation is not implemented."); + } + + public void LoadAsset(AssetBase info, bool image, string filename) + { + throw new Exception("The method or operation is not implemented."); + } + + public System.Collections.Generic.List GetDefaultAssets() + { + throw new Exception("The method or operation is not implemented."); + } + + public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) + { + throw new Exception("The method or operation is not implemented."); + } + + public void ForEachDefaultAsset(Action action) + { + throw new Exception("The method or operation is not implemented."); + } + + public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) + { + throw new Exception("The method or operation is not implemented."); + } + + public void ForEachXmlAsset(Action action) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + } +} -- cgit v1.1 From 27f003b68314ea5136632d6f9d14057c96ade1e1 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 29 Oct 2007 09:51:23 +0000 Subject: Started the process of cleaning up AssetCache and moving most of the code into modules. Have moved TextureRequest handling (from the client) to a module. But even though to start with I just did a little bit of cleaning up of the existing code, it doesn't seem to work as good as the old code so I need to spend more time on it. So for now am committing my changes but with them not in use. So for now all Texture and asset requests are still handled by the old code in AssetCache. --- .../Framework/Communications/Cache/AssetCache.cs | 168 +++++++++++---------- 1 file changed, 91 insertions(+), 77 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index a950f51..4c18744 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -42,6 +42,8 @@ namespace OpenSim.Framework.Communications.Cache { public delegate void DownloadComplete(AssetCache.TextureSender sender); + public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); + /// /// Manages local cache of assets and their sending to viewers. /// @@ -63,6 +65,8 @@ namespace OpenSim.Framework.Communications.Cache private Dictionary> TimesTextureSent = new Dictionary>(); + public Dictionary RequestLists = new Dictionary(); + private IAssetServer _assetServer; private Thread _assetCacheThread; @@ -123,6 +127,46 @@ namespace OpenSim.Framework.Communications.Cache return asset; } + public void GetAsset(LLUUID assetID, AssetRequestCallback callback) + { + AssetBase asset = null; + if (this.Textures.ContainsKey(assetID)) + { + asset = this.Textures[assetID]; + } + else if (this.Assets.ContainsKey(assetID)) + { + asset = this.Assets[assetID]; + } + + if (asset != null) + { + callback(assetID, asset); + } + else + { + NewAssetRequest req = new NewAssetRequest(assetID, callback); + if (this.RequestLists.ContainsKey(assetID)) + { + lock (RequestLists) + { + RequestLists[assetID].Requests.Add(req); + } + } + else + { + AssetRequestsList reqList = new AssetRequestsList(assetID); + reqList.Requests.Add(req); + lock (RequestLists) + { + RequestLists.Add(assetID, reqList); + } + } + this._assetServer.FetchAsset(assetID, false); + } + } + + public AssetBase GetAsset(LLUUID assetID, bool isTexture) { AssetBase asset = GetAsset(assetID); @@ -135,7 +179,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddAsset(AssetBase asset) { - // System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); if (asset.Type == 0) { //Console.WriteLine("which is a texture"); @@ -207,26 +251,7 @@ namespace OpenSim.Framework.Communications.Cache while (true) { TextureSender sender = this.QueueTextures.Dequeue(); - /* if (TimesTextureSent.ContainsKey(sender.request.RequestUser.AgentId)) - { - if (TimesTextureSent[sender.request.RequestUser.AgentId].ContainsKey(sender.request.ImageInfo.FullID)) - { - TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID]++; - } - else - { - TimesTextureSent[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID, 1); - } - } - else - { - Dictionary UsersSent = new Dictionary(); - TimesTextureSent.Add(sender.request.RequestUser.AgentId, UsersSent ); - UsersSent.Add(sender.request.ImageInfo.FullID, 1); - - } - if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) - {*/ + bool finished = sender.SendTexture(); if (finished) { @@ -237,11 +262,7 @@ namespace OpenSim.Framework.Communications.Cache // Console.WriteLine("readding texture"); this.QueueTextures.Enqueue(sender); } - /* } - else - { - this.TextureSent(sender); - }*/ + } } @@ -317,6 +338,21 @@ namespace OpenSim.Framework.Communications.Cache } } } + + if (RequestLists.ContainsKey(asset.FullID)) + { + AssetRequestsList reqList = RequestLists[asset.FullID]; + foreach (NewAssetRequest req in reqList.Requests) + { + req.Callback(asset.FullID, asset); + } + + lock (RequestLists) + { + RequestLists.Remove(asset.FullID); + reqList.Requests.Clear(); + } + } } } @@ -508,17 +544,6 @@ namespace OpenSim.Framework.Communications.Cache } } - - 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 @@ -529,7 +554,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) { - //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); + // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { @@ -540,6 +565,7 @@ namespace OpenSim.Framework.Communications.Cache //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; }*/ + if (!this.Textures.ContainsKey(imageID)) { if (!this.RequestedTextures.ContainsKey(imageID)) @@ -556,7 +582,7 @@ namespace OpenSim.Framework.Communications.Cache return; } - //Console.WriteLine("texture already in cache"); + // System.Console.WriteLine("texture already in cache"); TextureImage imag = this.Textures[imageID]; AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; @@ -583,46 +609,9 @@ namespace OpenSim.Framework.Communications.Cache 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; @@ -779,4 +768,29 @@ namespace OpenSim.Framework.Communications.Cache } } } + + public class AssetRequestsList + { + public LLUUID AssetID; + public List Requests = new List(); + + public AssetRequestsList(LLUUID assetID) + { + AssetID = assetID; + } + } + + public class NewAssetRequest + { + public LLUUID AssetID; + public AssetRequestCallback Callback; + + public NewAssetRequest(LLUUID assetID, AssetRequestCallback callback) + { + AssetID = assetID; + Callback = callback; + } + + + } } -- cgit v1.1 From 27b5fad56dbf94888d93656373a0350752396295 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 29 Oct 2007 12:59:04 +0000 Subject: * Removed AssetNotFound as it crashes client * Fixed introduced bugs in ScenePresence --- .../Framework/Communications/Cache/AssetCache.cs | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4c18744..1f5b336 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -358,19 +358,19 @@ namespace OpenSim.Framework.Communications.Cache public void AssetNotFound(LLUUID assetID) { - if (this.RequestedTextures.ContainsKey(assetID)) - { - MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID); - AssetRequest req = this.RequestedTextures[assetID]; - ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); - notFound.ImageID.ID = assetID; - req.RequestUser.OutPacket(notFound); - this.RequestedTextures.Remove(assetID); - } - else - { - MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID); - } + //if (this.RequestedTextures.ContainsKey(assetID)) + //{ + // MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID); + // AssetRequest req = this.RequestedTextures[assetID]; + // ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); + // notFound.ImageID.ID = assetID; + // req.RequestUser.OutPacket(notFound); + // this.RequestedTextures.Remove(assetID); + //} + //else + //{ + // MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID); + //} } #region Assets -- cgit v1.1 From 0837f6b78dbb93686ed3a3aca62a21566dfa8ccc Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 29 Oct 2007 14:37:08 +0000 Subject: fixed one bug (where the assets we read and created from the OpenSimAssetSet.xml file, weren't actually getting added to the database). This should make textures/assets work again with db4o, but still seems a problem with sqlite --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 53efa16..74f0167 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -163,6 +163,8 @@ namespace OpenSim.Framework.Communications.Cache public void ForEachXmlAsset(Action action) { + List assets = new List(); + // System.Console.WriteLine("trying loading asset into database"); string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); if (File.Exists(filePath)) { @@ -170,6 +172,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < source.Configs.Count; i++) { + // System.Console.WriteLine("loading asset into database"); string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); string name = source.Configs[i].GetString("name", ""); sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); @@ -180,9 +183,10 @@ namespace OpenSim.Framework.Communications.Cache newAsset.Type = type; newAsset.InvType = invType; - + assets.Add(newAsset); } } + assets.ForEach(action); } } } -- cgit v1.1 From f6e8cbbd068a84df8df9b668c574ad5c737c5c6f Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 29 Oct 2007 15:58:52 +0000 Subject: Fixed a bug in SQLAssetServer that only seemed to be a problem when running under the MS .net Runtime, but was fine with mono. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 2 +- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 74f0167..dc9c1ad 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -37,7 +37,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting Db4o asset storage system"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system"); this._assetRequests = new BlockingQueue(); this._localAssetServerThread = new Thread( RunRequests ); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 580e5c4..296c612 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -42,13 +42,14 @@ namespace OpenSim.Framework.Communications.Cache { public SQLAssetServer(string pluginName) { - _assetRequests = new BlockingQueue(); + // _assetRequests = new BlockingQueue(); AddPlugin(pluginName); } public SQLAssetServer(IAssetProvider assetProvider) { m_assetProviderPlugin = assetProvider; + } public void AddPlugin(string FileName) @@ -92,7 +93,7 @@ namespace OpenSim.Framework.Communications.Cache { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); + //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) -- cgit v1.1 From 3d8219f6c7faa256d6a13ab7925f75d83af95b78 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 29 Oct 2007 21:46:25 +0000 Subject: as per the "Filesystem cleanup for OpenSim repository" mailing list thread. Have flattened the OpenSim.Framework project/namespace. The problem is that the namespace is still wrong as its "OpenSim.Framework" while the directory is "OpenSim\Framework\General" , so we need to decide if we change the directory or correct the namespace. Note this has lead to a big flat project, but I think a lot of the files we most likely don't even use any longer. And others belong in other projects/namespaces anyway. --- .../Framework/Communications/Cache/AssetCache.cs | 3 +- .../Framework/Communications/Cache/AssetServer.cs | 3 +- .../Communications/Cache/AssetServerBase.cs | 32 +++++++++++----------- .../Cache/AssetTransactionManager.cs | 3 +- .../Communications/Cache/AssetTransactions.cs | 3 +- .../Communications/Cache/CachedUserInfo.cs | 2 +- .../Communications/Cache/GridAssetClient.cs | 3 +- .../Communications/Cache/InventoryFolder.cs | 3 +- .../Communications/Cache/LibraryRootFolder.cs | 3 +- .../Communications/Cache/SQLAssetServer.cs | 5 +--- .../Communications/Cache/UserProfileCache.cs | 4 +-- .../Framework/Communications/Capabilities/Caps.cs | 3 +- .../Communications/CommunicationsManager.cs | 3 +- OpenSim/Framework/Communications/IGridServices.cs | 2 +- .../Communications/IInterRegionCommunications.cs | 2 +- .../Framework/Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 8 ++---- .../Framework/Communications/UserManagerBase.cs | 5 ++-- 19 files changed, 37 insertions(+), 54 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1f5b336..39e2887 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -34,8 +34,7 @@ using System.Threading; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index aebda00..c927571 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -36,8 +36,7 @@ using Nini.Config; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index dc9c1ad..0771a20 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -6,8 +6,7 @@ using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -18,18 +17,18 @@ namespace OpenSim.Framework.Communications.Cache protected Thread _localAssetServerThread; protected IAssetProvider m_assetProviderPlugin; protected object syncLock = new object(); - + protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); protected abstract void RunRequests(); - + public void LoadDefaultAssets() { MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); - ForEachDefaultAsset(StoreAsset ); - ForEachXmlAsset(StoreAsset ); + ForEachDefaultAsset(StoreAsset); + ForEachXmlAsset(StoreAsset); CommitAssets(); } @@ -37,10 +36,11 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { + OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system"); this._assetRequests = new BlockingQueue(); - this._localAssetServerThread = new Thread( RunRequests ); + this._localAssetServerThread = new Thread(RunRequests); this._localAssetServerThread.IsBackground = true; this._localAssetServerThread.Start(); } @@ -96,13 +96,13 @@ namespace OpenSim.Framework.Communications.Cache } public virtual void Close() - { - _localAssetServerThread.Abort( ); - } + { + _localAssetServerThread.Abort(); + } public void SetServerInfo(string ServerUrl, string ServerKey) { - + } public virtual List GetDefaultAssets() @@ -149,13 +149,13 @@ namespace OpenSim.Framework.Communications.Cache if (!String.IsNullOrEmpty(filename)) { - MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); + MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename); LoadAsset(asset, isImage, filename); } else { - MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); + MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name); } return asset; @@ -164,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache public void ForEachXmlAsset(Action action) { List assets = new List(); - // System.Console.WriteLine("trying loading asset into database"); + // System.Console.WriteLine("trying loading asset into database"); string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); if (File.Exists(filePath)) { @@ -172,7 +172,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < source.Configs.Count; i++) { - // System.Console.WriteLine("loading asset into database"); + // System.Console.WriteLine("loading asset into database"); string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); string name = source.Configs[i].GetString("name", ""); sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); @@ -183,7 +183,7 @@ namespace OpenSim.Framework.Communications.Cache newAsset.Type = type; newAsset.InvType = invType; - assets.Add(newAsset); + assets.Add(newAsset); } } assets.ForEach(action); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 2c1e5c8..d622e02 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -32,8 +32,7 @@ using System.Text; using System.IO; using libsecondlife; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; using OpenSim.Framework.Data; namespace OpenSim.Framework.Communications.Cache diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index f23441d..e78f4f7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -34,8 +34,7 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 92b21a8..2d639d6 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -26,7 +26,7 @@ * */ using libsecondlife; -using OpenSim.Framework.Types; +using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 7483582..4904293 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -36,8 +36,7 @@ using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; using OpenSim.Framework.Communications; namespace OpenSim.Framework.Communications.Cache diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index af3346f..0905af8 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -32,8 +32,7 @@ using System.Text; using System.IO; using libsecondlife; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 86e26f0..60f9b6b 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -31,8 +31,7 @@ using System.IO; using System.Collections.Generic; using System.Text; using libsecondlife; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; using Nini.Config; namespace OpenSim.Framework.Communications.Cache diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 296c612..0953e19 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -33,8 +33,7 @@ using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -42,14 +41,12 @@ namespace OpenSim.Framework.Communications.Cache { public SQLAssetServer(string pluginName) { - // _assetRequests = new BlockingQueue(); AddPlugin(pluginName); } public SQLAssetServer(IAssetProvider assetProvider) { m_assetProviderPlugin = assetProvider; - } public void AddPlugin(string FileName) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index bd7aeef..8105556 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -33,8 +33,8 @@ using System.IO; using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; + namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 095a5b1..a114b64 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -33,8 +33,7 @@ using System.IO; using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; +using OpenSim.Framework; namespace OpenSim.Region.Capabilities { diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 7a157be..d8d198b 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -30,9 +30,8 @@ using libsecondlife; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework.Types; +using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Utilities; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 4167b65..ccbb729 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Net; using libsecondlife; -using OpenSim.Framework.Types; +using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index a1afe8d..244747d 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -26,7 +26,7 @@ * */ using libsecondlife; -using OpenSim.Framework.Types; +using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 5643d78..e7758c4 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -31,7 +31,7 @@ using System.Collections.Generic; using System.Text; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Types; +using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 6549966..05183be 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -33,7 +33,7 @@ using libsecondlife; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Types; +using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 77b9283..66b91e1 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -34,13 +34,9 @@ using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Configuration; -using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; +using OpenSim.Framework; +using InventoryFolder = OpenSim.Framework.InventoryFolder; namespace OpenSim.Framework.UserManagement { diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 56ed959..006c8ee 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -33,12 +33,11 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework.Configuration; +using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; + namespace OpenSim.Framework.UserManagement { -- cgit v1.1 From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 30 Oct 2007 09:05:31 +0000 Subject: * Optimized usings * Shortened type references * Removed redundant 'this' qualifier --- OpenSim/Framework/Communications/CAPSService.cs | 6 +- .../Framework/Communications/Cache/AssetCache.cs | 207 ++++--- .../Framework/Communications/Cache/AssetServer.cs | 24 +- .../Communications/Cache/AssetServerBase.cs | 26 +- .../Cache/AssetTransactionManager.cs | 37 +- .../Communications/Cache/AssetTransactions.cs | 199 +++---- .../Communications/Cache/CachedUserInfo.cs | 37 +- .../Communications/Cache/GridAssetClient.cs | 21 +- .../Communications/Cache/InventoryFolder.cs | 41 +- .../Communications/Cache/LibraryRootFolder.cs | 82 ++- .../Communications/Cache/SQLAssetServer.cs | 21 +- .../Communications/Cache/UserProfileCache.cs | 72 ++- .../Framework/Communications/Capabilities/Caps.cs | 136 +++-- .../Communications/Capabilities/LLSDArray.cs | 3 +- .../Capabilities/LLSDAssetUploadComplete.cs | 3 +- .../Capabilities/LLSDAssetUploadRequest.cs | 5 +- .../Capabilities/LLSDAssetUploadResponse.cs | 7 +- .../Communications/Capabilities/LLSDCapEvent.cs | 3 +- .../Communications/Capabilities/LLSDCapsDetails.cs | 12 +- .../Communications/Capabilities/LLSDEmpty.cs | 3 +- .../Communications/Capabilities/LLSDHelpers.cs | 32 +- .../Communications/Capabilities/LLSDItemUpdate.cs | 5 +- .../Communications/Capabilities/LLSDMapLayer.cs | 3 +- .../Capabilities/LLSDMapLayerResponse.cs | 3 +- .../Communications/Capabilities/LLSDMapRequest.cs | 3 +- .../Communications/Capabilities/LLSDMethod.cs | 6 +- .../Capabilities/LLSDStreamHandler.cs | 19 +- .../Communications/Capabilities/LLSDTest.cs | 3 +- .../Communications/Capabilities/LLSDType.cs | 10 +- .../Communications/CommunicationsManager.cs | 20 +- OpenSim/Framework/Communications/IGridServices.cs | 6 +- .../Communications/IInterRegionCommunications.cs | 3 +- .../Framework/Communications/IInventoryServices.cs | 6 +- .../Communications/InventoryServiceBase.cs | 19 +- OpenSim/Framework/Communications/LoginResponse.cs | 594 ++++++++------------- OpenSim/Framework/Communications/LoginService.cs | 53 +- .../Communications/Properties/AssemblyInfo.cs | 31 +- .../RestClient/GenericAsyncResult.cs | 37 +- .../Communications/RestClient/RestClient.cs | 64 ++- .../Framework/Communications/UserManagerBase.cs | 49 +- 40 files changed, 832 insertions(+), 1079 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index b60ef02..40f4006 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -37,17 +37,17 @@ namespace OpenSim.Framework.Communications public CAPSService(BaseHttpServer httpServer) { m_server = httpServer; - this.AddCapsSeedHandler("/CapsSeed/", CapsRequest); + AddCapsSeedHandler("/CapsSeed/", CapsRequest); } private void AddCapsSeedHandler(string path, RestMethod restMethod) { - m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); + m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); } public string CapsRequest(string request, string path, string param) { - System.Console.WriteLine("new caps request " + request +" from path "+ path); + System.Console.WriteLine("new caps request " + request + " from path " + path); return ""; } } diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 39e2887..ca2fc35 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -29,12 +29,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Threading; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache @@ -51,18 +48,22 @@ namespace OpenSim.Framework.Communications.Cache public Dictionary Assets; public Dictionary Textures; - public List AssetRequests = new List(); //assets ready to be sent to viewers + 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 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 BlockingQueue QueueTextures = new BlockingQueue(); private Dictionary> AvatarRecievedTextures = new Dictionary>(); - private Dictionary> TimesTextureSent = new Dictionary>(); + private Dictionary> TimesTextureSent = + new Dictionary>(); public Dictionary RequestLists = new Dictionary(); @@ -76,19 +77,18 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); + MainLog.Instance.Verbose("ASSETSTORAGE", "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(); - - this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders)); - this.TextureSenderThread.IsBackground = true; - this.TextureSenderThread.Start(); + _assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + _assetCacheThread.IsBackground = true; + _assetCacheThread.Start(); + TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); + TextureSenderThread.IsBackground = true; + TextureSenderThread.Start(); } /// @@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications.Cache { try { - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); + ProcessAssetQueue(); + ProcessTextureQueue(); Thread.Sleep(500); } catch (Exception e) @@ -115,13 +115,13 @@ namespace OpenSim.Framework.Communications.Cache public AssetBase GetAsset(LLUUID assetID) { AssetBase asset = null; - if (this.Textures.ContainsKey(assetID)) + if (Textures.ContainsKey(assetID)) { - asset = this.Textures[assetID]; + asset = Textures[assetID]; } - else if (this.Assets.ContainsKey(assetID)) + else if (Assets.ContainsKey(assetID)) { - asset = this.Assets[assetID]; + asset = Assets[assetID]; } return asset; } @@ -129,13 +129,13 @@ namespace OpenSim.Framework.Communications.Cache public void GetAsset(LLUUID assetID, AssetRequestCallback callback) { AssetBase asset = null; - if (this.Textures.ContainsKey(assetID)) + if (Textures.ContainsKey(assetID)) { - asset = this.Textures[assetID]; + asset = Textures[assetID]; } - else if (this.Assets.ContainsKey(assetID)) + else if (Assets.ContainsKey(assetID)) { - asset = this.Assets[assetID]; + asset = Assets[assetID]; } if (asset != null) @@ -145,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache else { NewAssetRequest req = new NewAssetRequest(assetID, callback); - if (this.RequestLists.ContainsKey(assetID)) + if (RequestLists.ContainsKey(assetID)) { lock (RequestLists) { @@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Add(assetID, reqList); } } - this._assetServer.FetchAsset(assetID, false); + _assetServer.FetchAsset(assetID, false); } } @@ -171,22 +171,23 @@ namespace OpenSim.Framework.Communications.Cache AssetBase asset = GetAsset(assetID); if (asset == null) { - this._assetServer.FetchAsset(assetID, isTexture); + _assetServer.FetchAsset(assetID, isTexture); } return asset; } public void AddAsset(AssetBase asset) { - //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); if (asset.Type == 0) { //Console.WriteLine("which is a texture"); if (!Textures.ContainsKey(asset.FullID)) - { //texture + { + //texture TextureImage textur = new TextureImage(asset); Textures.Add(textur.FullID, textur); - if(!asset.Temporary) + if (!asset.Temporary) _assetServer.StoreAndCommitAsset(asset); } else @@ -219,49 +220,47 @@ namespace OpenSim.Framework.Communications.Cache /// private void ProcessTextureQueue() { - if (this.TextureRequests.Count == 0) + if (TextureRequests.Count == 0) { //no requests waiting return; } int num; - num = this.TextureRequests.Count; + num = TextureRequests.Count; AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)this.TextureRequests[i]; - if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) + req = (AssetRequest) TextureRequests[i]; + if (!SendingTextures.ContainsKey(req.ImageInfo.FullID)) { //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - this.QueueTextures.Enqueue(sender); + SendingTextures.Add(req.ImageInfo.FullID, sender); + QueueTextures.Enqueue(sender); } - } - this.TextureRequests.Clear(); + TextureRequests.Clear(); } public void ProcessTextureSenders() { while (true) { - TextureSender sender = this.QueueTextures.Dequeue(); - + TextureSender sender = QueueTextures.Dequeue(); + bool finished = sender.SendTexture(); if (finished) { - this.TextureSent(sender); + TextureSent(sender); } else { // Console.WriteLine("readding texture"); - this.QueueTextures.Enqueue(sender); + QueueTextures.Enqueue(sender); } - } } @@ -271,16 +270,16 @@ namespace OpenSim.Framework.Communications.Cache /// public void TextureSent(TextureSender sender) { - if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) + if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + SendingTextures.Remove(sender.request.ImageInfo.FullID); // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(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 + 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 @@ -292,48 +291,48 @@ namespace OpenSim.Framework.Communications.Cache //Console.WriteLine("asset recieved from asset server"); TextureImage image = new TextureImage(asset); - if (!this.Textures.ContainsKey(image.FullID)) + if (!Textures.ContainsKey(image.FullID)) { - this.Textures.Add(image.FullID, image); - if (this.RequestedTextures.ContainsKey(image.FullID)) + Textures.Add(image.FullID, image); + if (RequestedTextures.ContainsKey(image.FullID)) { - AssetRequest req = this.RequestedTextures[image.FullID]; + AssetRequest req = 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) / 1000; + req.NumPackets = 1 + (int) (image.Data.Length - 600)/1000; } else { req.NumPackets = 1; } - this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(req); + RequestedTextures.Remove(image.FullID); + TextureRequests.Add(req); } } } else { AssetInfo assetInf = new AssetInfo(asset); - if (!this.Assets.ContainsKey(assetInf.FullID)) + if (!Assets.ContainsKey(assetInf.FullID)) { - this.Assets.Add(assetInf.FullID, assetInf); - if (this.RequestedAssets.ContainsKey(assetInf.FullID)) + Assets.Add(assetInf.FullID, assetInf); + if (RequestedAssets.ContainsKey(assetInf.FullID)) { - AssetRequest req = this.RequestedAssets[assetInf.FullID]; + AssetRequest req = 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; + req.NumPackets = 1 + (int) (assetInf.Data.Length - 600 + 999)/1000; } else { req.NumPackets = 1; } - this.RequestedAssets.Remove(assetInf.FullID); - this.AssetRequests.Add(req); + RequestedAssets.Remove(assetInf.FullID); + AssetRequests.Add(req); } } } @@ -345,7 +344,7 @@ namespace OpenSim.Framework.Communications.Cache { req.Callback(asset.FullID, asset); } - + lock (RequestLists) { RequestLists.Remove(asset.FullID); @@ -373,6 +372,7 @@ namespace OpenSim.Framework.Communications.Cache } #region Assets + /// /// /// @@ -396,11 +396,11 @@ namespace OpenSim.Framework.Communications.Cache } //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); - if (!this.Assets.ContainsKey(requestID)) + if (!Assets.ContainsKey(requestID)) { //not found asset // so request from asset server - if (!this.RequestedAssets.ContainsKey(requestID)) + if (!RequestedAssets.ContainsKey(requestID)) { AssetRequest request = new AssetRequest(); request.RequestUser = userInfo; @@ -408,13 +408,13 @@ namespace OpenSim.Framework.Communications.Cache request.TransferRequestID = transferRequest.TransferInfo.TransferID; request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; - this.RequestedAssets.Add(requestID, request); - this._assetServer.FetchAsset(requestID, false); + RequestedAssets.Add(requestID, request); + _assetServer.FetchAsset(requestID, false); } return; } //it is in our cache - AssetInfo asset = this.Assets[requestID]; + AssetInfo asset = Assets[requestID]; //work out how many packets it should be sent in // and add to the AssetRequests list @@ -429,14 +429,14 @@ namespace OpenSim.Framework.Communications.Cache if (asset.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; + req.NumPackets = 1 + (int) (asset.Data.Length - 600 + 999)/1000; } else { req.NumPackets = 1; } - this.AssetRequests.Add(req); + AssetRequests.Add(req); } /// @@ -444,17 +444,17 @@ namespace OpenSim.Framework.Communications.Cache /// private void ProcessAssetQueue() { - if (this.AssetRequests.Count == 0) + if (AssetRequests.Count == 0) { //no requests waiting return; } int num; - if (this.AssetRequests.Count < 5) + if (AssetRequests.Count < 5) { //lower than 5 so do all of them - num = this.AssetRequests.Count; + num = AssetRequests.Count; } else { @@ -463,7 +463,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)this.AssetRequests[i]; + req = (AssetRequest) AssetRequests[i]; //Console.WriteLine("sending asset " + req.RequestAssetID); TransferInfoPacket Transfer = new TransferInfoPacket(); Transfer.TransferInfo.ChannelType = 2; @@ -473,7 +473,7 @@ namespace OpenSim.Framework.Communications.Cache { Transfer.TransferInfo.Params = new byte[20]; Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; + int assType = (int) req.AssetInf.Type; Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); } else if (req.AssetRequestSource == 3) @@ -483,7 +483,7 @@ namespace OpenSim.Framework.Communications.Cache //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; req.RequestUser.OutPacket(Transfer); @@ -533,19 +533,19 @@ namespace OpenSim.Framework.Communications.Cache req.RequestUser.OutPacket(TransferPacket); } } - } //remove requests that have been completed for (int i = 0; i < num; i++) { - this.AssetRequests.RemoveAt(0); + AssetRequests.RemoveAt(0); } - } + #endregion #region Textures + /// /// /// @@ -553,21 +553,21 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) { - // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); + // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server - if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { - this.AvatarRecievedTextures.Add(userInfo.AgentId, new List()); + AvatarRecievedTextures.Add(userInfo.AgentId, new List()); } /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) { //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; }*/ - - if (!this.Textures.ContainsKey(imageID)) + + if (!Textures.ContainsKey(imageID)) { - if (!this.RequestedTextures.ContainsKey(imageID)) + if (!RequestedTextures.ContainsKey(imageID)) { //not is cache so request from asset server AssetRequest request = new AssetRequest(); @@ -575,14 +575,14 @@ namespace OpenSim.Framework.Communications.Cache request.RequestAssetID = imageID; request.IsTextureRequest = true; request.DiscardLevel = discard; - this.RequestedTextures.Add(imageID, request); - this._assetServer.FetchAsset(imageID, true); + RequestedTextures.Add(imageID, request); + _assetServer.FetchAsset(imageID, true); } return; } - // System.Console.WriteLine("texture already in cache"); - TextureImage imag = this.Textures[imageID]; + // System.Console.WriteLine("texture already in cache"); + TextureImage imag = Textures[imageID]; AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; req.RequestAssetID = imageID; @@ -594,7 +594,7 @@ namespace OpenSim.Framework.Communications.Cache { //Console.WriteLine("{0}", imag.Data.LongLength); //over 600 bytes so split up file - req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000; + req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000; //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); } else @@ -603,12 +603,11 @@ namespace OpenSim.Framework.Communications.Cache } if (packetNumber != 0) { - req.PacketCounter = (int)packetNumber; + req.PacketCounter = (int) packetNumber; } - this.TextureRequests.Add(req); + TextureRequests.Add(req); } - #endregion public class AssetRequest @@ -630,7 +629,6 @@ namespace OpenSim.Framework.Communications.Cache public AssetRequest() { - } } @@ -638,7 +636,6 @@ namespace OpenSim.Framework.Communications.Cache { public AssetInfo() { - } public AssetInfo(AssetBase aBase) @@ -656,7 +653,6 @@ namespace OpenSim.Framework.Communications.Cache { public TextureImage() { - } public TextureImage(AssetBase aBase) @@ -678,7 +674,6 @@ namespace OpenSim.Framework.Communications.Cache public TextureSender(AssetRequest req) { request = req; - } public bool SendTexture() @@ -686,7 +681,8 @@ namespace OpenSim.Framework.Communications.Cache SendPacket(); counter++; - if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | (request.DiscardLevel == -1)) + if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | + (request.DiscardLevel == -1)) { return true; } @@ -707,7 +703,7 @@ namespace OpenSim.Framework.Communications.Cache im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageID.Size = (uint) req.ImageInfo.Data.Length; im.ImageData.Data = req.ImageInfo.Data; im.ImageID.Codec = 2; req.RequestUser.OutPacket(im); @@ -721,9 +717,9 @@ namespace OpenSim.Framework.Communications.Cache //more than one packet so split file up ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; - im.ImageID.Packets = (ushort)(req.NumPackets); + im.ImageID.Packets = (ushort) (req.NumPackets); im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + 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; @@ -742,19 +738,18 @@ namespace OpenSim.Framework.Communications.Cache //more than one packet so split file up ImagePacketPacket im = new ImagePacketPacket(); im.Header.Reliable = false; - im.ImageID.Packet = (ushort)(req.PacketCounter); + im.ImageID.Packet = (ushort) (req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); + int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1)); if (size > 1000) size = 1000; //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, 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.ImageInfo.FullID); } - } private void SaveAssetToFile(string filename, byte[] data) @@ -789,7 +784,5 @@ namespace OpenSim.Framework.Communications.Cache AssetID = assetID; Callback = callback; } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index c927571..fa421c7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -25,18 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; using System.IO; -using System.Threading; using Db4objects.Db4o; using Db4objects.Db4o.Query; using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -50,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); + MainLog.Instance.Verbose("ASSETS", "Db4 Asset database creation"); if (!yapfile) { @@ -68,29 +61,29 @@ namespace OpenSim.Framework.Communications.Cache db.Commit(); } - override public void Close() + public override void Close() { base.Close(); if (db != null) { - MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); + MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database"); db.Close(); } } - override protected void RunRequests() + protected override void RunRequests() { while (true) { byte[] idata = null; bool found = false; AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); + ARequest req = _assetRequests.Dequeue(); IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); if (result.Count > 0) { - foundAsset = (AssetStorage)result.Next(); + foundAsset = (AssetStorage) result.Next(); found = true; } @@ -110,12 +103,10 @@ namespace OpenSim.Framework.Communications.Cache //asset.FullID = ; _receiver.AssetNotFound(req.AssetID); } - } - } - override protected void StoreAsset(AssetBase asset) + protected override void StoreAsset(AssetBase asset) { AssetStorage store = new AssetStorage(); store.Data = asset.Data; @@ -148,6 +139,7 @@ namespace OpenSim.Framework.Communications.Cache { _findID = find; } + public bool Match(AssetStorage asset) { return (asset.UUID == _findID); diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 0771a20..7109910 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -5,8 +5,6 @@ using System.Threading; using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -36,13 +34,12 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { + MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); + _assetRequests = new BlockingQueue(); - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system"); - this._assetRequests = new BlockingQueue(); - - this._localAssetServerThread = new Thread(RunRequests); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); + _localAssetServerThread = new Thread(RunRequests); + _localAssetServerThread.IsBackground = true; + _localAssetServerThread.Start(); } public void LoadAsset(AssetBase info, bool image, string filename) @@ -57,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); byte[] idata = new byte[numBytes]; BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); + idata = br.ReadBytes((int) numBytes); br.Close(); fStream.Close(); info.Data = idata; @@ -66,7 +63,7 @@ namespace OpenSim.Framework.Communications.Cache public void SetReceiver(IAssetReceiver receiver) { - this._receiver = receiver; + _receiver = receiver; } public void FetchAsset(LLUUID assetID, bool isTexture) @@ -74,7 +71,7 @@ namespace OpenSim.Framework.Communications.Cache ARequest req = new ARequest(); req.AssetID = assetID; req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); + _assetRequests.Enqueue(req); } public void UpdateAsset(AssetBase asset) @@ -102,7 +99,6 @@ namespace OpenSim.Framework.Communications.Cache public void SetServerInfo(string ServerUrl, string ServerKey) { - } public virtual List GetDefaultAssets() @@ -175,8 +171,8 @@ namespace OpenSim.Framework.Communications.Cache // System.Console.WriteLine("loading asset into database"); string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); string fileName = source.Configs[i].GetString("fileName", ""); AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); @@ -189,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache assets.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index d622e02..55b255a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -25,15 +25,8 @@ * 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.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Data; namespace OpenSim.Framework.Communications.Cache { @@ -41,7 +34,10 @@ namespace OpenSim.Framework.Communications.Cache { // Fields public CommunicationsManager CommsManager; - public Dictionary AgentTransactions = new Dictionary(); + + public Dictionary AgentTransactions = + new Dictionary(); + private bool m_dumpAssetsToFile; public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile) @@ -53,10 +49,10 @@ namespace OpenSim.Framework.Communications.Cache // Methods public AgentAssetTransactions AddUser(LLUUID userID) { - if (!this.AgentTransactions.ContainsKey(userID)) + if (!AgentTransactions.ContainsKey(userID)) { AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); - this.AgentTransactions.Add(userID, transactions); + AgentTransactions.Add(userID, transactions); return transactions; } return null; @@ -64,27 +60,30 @@ namespace OpenSim.Framework.Communications.Cache public AgentAssetTransactions GetUserTransActions(LLUUID userID) { - if (this.AgentTransactions.ContainsKey(userID)) + if (AgentTransactions.ContainsKey(userID)) { - return this.AgentTransactions[userID]; + return AgentTransactions[userID]; } return null; } - public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { - transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, + name, invType, type, wearableType, nextOwnerMask); } - } - public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) + public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, + byte[] data, bool storeLocal) { // Console.WriteLine("asset upload of " + assetID); - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); @@ -97,7 +96,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { transactions.HandleXfer(xferID, packetID, data); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index e78f4f7..6b08fc9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -26,17 +26,12 @@ * */ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; +using OpenSim.Region.Capabilities; namespace OpenSim.Framework.Communications.Cache { @@ -53,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache // Methods public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) { - this.UserID = agentID; + UserID = agentID; Manager = manager; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -61,24 +56,24 @@ namespace OpenSim.Framework.Communications.Cache public AssetCapsUploader RequestCapsUploader() { AssetCapsUploader uploader = new AssetCapsUploader(); - this.CapsUploaders.Add(uploader); + CapsUploaders.Add(uploader); return uploader; } public NoteCardCapsUpdate RequestNoteCardUpdater() { NoteCardCapsUpdate update = new NoteCardCapsUpdate(); - this.NotecardUpdaters.Add(update); + NotecardUpdaters.Add(update); return update; } public AssetXferUploader RequestXferUploader(LLUUID transactionID) { - if (!this.XferUploaders.ContainsKey(transactionID)) + if (!XferUploaders.ContainsKey(transactionID)) { AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); - this.XferUploaders.Add(transactionID, uploader); + XferUploaders.Add(transactionID, uploader); return uploader; } return null; @@ -86,7 +81,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleXfer(ulong xferID, uint packetID, byte[] data) { - foreach (AssetXferUploader uploader in this.XferUploaders.Values) + foreach (AssetXferUploader uploader in XferUploaders.Values) { if (uploader.XferID == xferID) { @@ -96,17 +91,21 @@ namespace OpenSim.Framework.Communications.Cache } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - if (this.XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { - this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, + callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } } public AssetBase GetTransactionAsset(LLUUID transactionID) { - if (this.XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { return XferUploaders[transactionID].GetAssetData(); } @@ -130,15 +129,16 @@ namespace OpenSim.Framework.Communications.Cache public event UpLoadedAsset OnUpLoad; // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, + LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) { - this.m_assetName = assetName; - this.m_assetDescription = assetDescription; - this.m_folderID = folderID; - this.newAssetID = assetID; - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; + m_assetName = assetName; + m_assetDescription = assetDescription; + m_folderID = folderID; + newAssetID = assetID; + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; m_dumpImageToFile = dumpImageToFile; } @@ -156,18 +156,18 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToStringHyphenated(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.m_dumpImageToFile) + httpListener.RemoveStreamHandler("POST", uploaderPath); + if (m_dumpImageToFile) { - this.SaveImageToFile(this.m_assetName + ".jp2", data); + SaveImageToFile(m_assetName + ".jp2", data); } - if (this.OnUpLoad != null) + if (OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , ""); + OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); } return text; } @@ -196,90 +196,91 @@ namespace OpenSim.Framework.Communications.Cache public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) { - this.m_userTransactions = transactions; + m_userTransactions = transactions; m_dumpAssetToFile = dumpAssetToFile; } // Methods public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) { - if (this.XferID == xferID) + if (XferID == xferID) { - if (this.Asset.Data.Length > 1) + if (Asset.Data.Length > 1) { - byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; - Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); - Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); - this.Asset.Data = destinationArray; + byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; + Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); + Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); + Asset.Data = destinationArray; } else { byte[] buffer2 = new byte[data.Length - 4]; Array.Copy(data, 4, buffer2, 0, data.Length - 4); - this.Asset.Data = buffer2; + Asset.Data = buffer2; } ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); newPack.XferID.ID = xferID; newPack.XferID.Packet = packetID; - this.ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack); if ((packetID & 0x80000000) != 0) { - this.SendCompleteMessage(); + SendCompleteMessage(); } } } - public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) + public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, + bool storeLocal) { - this.ourClient = remoteClient; - this.Asset = new AssetBase(); - this.Asset.FullID = assetID; - this.Asset.InvType = type; - this.Asset.Type = type; - this.Asset.Data = data; - this.Asset.Name = "blank"; - this.Asset.Description = "empty"; - this.TransactionID = transaction; - this.m_storeLocal = storeLocal; - if (this.Asset.Data.Length > 2) + ourClient = remoteClient; + Asset = new AssetBase(); + Asset.FullID = assetID; + Asset.InvType = type; + Asset.Type = type; + Asset.Data = data; + Asset.Name = "blank"; + Asset.Description = "empty"; + TransactionID = transaction; + m_storeLocal = storeLocal; + if (Asset.Data.Length > 2) { - this.SendCompleteMessage(); + SendCompleteMessage(); } else { - this.ReqestStartXfer(); + ReqestStartXfer(); } } protected void ReqestStartXfer() { - this.UploadComplete = false; - this.XferID = Util.GetNextXferID(); + UploadComplete = false; + XferID = Util.GetNextXferID(); RequestXferPacket newPack = new RequestXferPacket(); - newPack.XferID.ID = this.XferID; - newPack.XferID.VFileType = this.Asset.Type; - newPack.XferID.VFileID = this.Asset.FullID; + newPack.XferID.ID = XferID; + newPack.XferID.VFileType = Asset.Type; + newPack.XferID.VFileID = Asset.FullID; newPack.XferID.FilePath = 0; newPack.XferID.Filename = new byte[0]; - this.ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack); } protected void SendCompleteMessage() { - this.UploadComplete = true; + UploadComplete = true; AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); - newPack.AssetBlock.Type = this.Asset.Type; + newPack.AssetBlock.Type = Asset.Type; newPack.AssetBlock.Success = true; - newPack.AssetBlock.UUID = this.Asset.FullID; - this.ourClient.OutPacket(newPack); - this.m_finished = true; + newPack.AssetBlock.UUID = Asset.FullID; + ourClient.OutPacket(newPack); + m_finished = true; if (m_createItem) { DoCreateItem(); } else if (m_storeLocal) { - this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); + m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); } // Console.WriteLine("upload complete "+ this.TransactionID); @@ -287,8 +288,10 @@ namespace OpenSim.Framework.Communications.Cache if (m_dumpAssetToFile) { DateTime now = DateTime.Now; - string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type ); - SaveAssetToFile(filename, this.Asset.Data); + string filename = + String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, + now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); + SaveAssetToFile(filename, Asset.Data); } } @@ -301,20 +304,22 @@ namespace OpenSim.Framework.Communications.Cache fs.Close(); } - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - if (this.TransactionID == transactionID) + if (TransactionID == transactionID) { - this.InventFolder = folderID; - this.m_name = name; - this.m_description = description; + InventFolder = folderID; + m_name = name; + m_description = description; this.type = type; this.invType = invType; - this.nextPerm = nextOwnerMask; - this.Asset.Name = name; - this.Asset.Description = description; - this.Asset.Type = type; - this.Asset.InvType = invType; + nextPerm = nextOwnerMask; + Asset.Name = name; + Asset.Description = description; + Asset.Type = type; + Asset.InvType = invType; m_createItem = true; if (m_finished) { @@ -326,22 +331,23 @@ namespace OpenSim.Framework.Communications.Cache private void DoCreateItem() { //really need to fix this call, if lbsa71 saw this he would die. - this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); - CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); + m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); + CachedUserInfo userInfo = + m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); - item.avatarID = this.ourClient.AgentId; + item.avatarID = ourClient.AgentId; item.creatorsID = ourClient.AgentId; item.inventoryID = LLUUID.Random(); item.assetID = Asset.FullID; - item.inventoryDescription = this.m_description; + item.inventoryDescription = m_description; item.inventoryName = m_name; item.assetType = type; - item.invType = this.invType; - item.parentFolderID = this.InventFolder; + item.invType = invType; + item.parentFolderID = InventFolder; item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = this.nextPerm; + item.inventoryNextPermissions = nextPerm; userInfo.AddItem(ourClient.AgentId, item); ourClient.SendInventoryItemUpdate(item); @@ -350,14 +356,13 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateInventoryItem(LLUUID itemID) { - } public AssetBase GetAssetData() { if (m_finished) { - return this.Asset; + return Asset; } return null; } @@ -379,10 +384,10 @@ namespace OpenSim.Framework.Communications.Cache // Methods public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) { - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; - this.newAssetID = LLUUID.Random(); + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; + newAssetID = LLUUID.Random(); } private void SaveImageToFile(string filename, byte[] data) @@ -399,18 +404,18 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToStringHyphenated(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) + httpListener.RemoveStreamHandler("POST", uploaderPath); + if (SaveImages) { - this.SaveImageToFile(this.m_assetName + "notecard.txt", data); + SaveImageToFile(m_assetName + "notecard.txt", data); } - if (this.OnUpLoad != null) + if (OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" ); + OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); } return text; } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 2d639d6..8fbc3fd 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -45,22 +44,22 @@ namespace OpenSim.Framework.Communications.Cache // Methods public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { - if (userID == this.UserProfile.UUID) + if (userID == UserProfile.UUID) { - if (this.RootFolder == null) + if (RootFolder == null) { if (folderInfo.parentID == LLUUID.Zero) { - this.RootFolder = folderInfo; + RootFolder = folderInfo; } } - else if (this.RootFolder.folderID == folderInfo.parentID) + else if (RootFolder.folderID == folderInfo.parentID) { - this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); } else { - InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { folder.SubFolders.Add(folderInfo.folderID, folderInfo); @@ -71,18 +70,18 @@ namespace OpenSim.Framework.Communications.Cache public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - if (itemInfo.parentFolderID == this.RootFolder.folderID) + if (itemInfo.parentFolderID == RootFolder.folderID) { - this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); } else { - InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + folder.Items.Add(itemInfo.inventoryID, itemInfo); } } } @@ -90,30 +89,30 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - this.ItemReceive(userID, itemInfo); - this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + ItemReceive(userID, itemInfo); + m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { result = RootFolder.DeleteItem(item.inventoryID); if (result) { - this.m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); + m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); } } return result; diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 4904293..74a1ef4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -25,19 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; +using System.Collections.Generic; using System.IO; -using System.Threading; -using System.Reflection; using System.Xml.Serialization; - using libsecondlife; - -using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Communications; namespace OpenSim.Framework.Communications.Cache { @@ -63,7 +57,6 @@ namespace OpenSim.Framework.Communications.Cache Stream s = null; try { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); RestClient rc = new RestClient(_assetServerUrl); @@ -77,8 +70,8 @@ namespace OpenSim.Framework.Communications.Cache if (s.Length > 0) { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase asset = (AssetBase)xs.Deserialize(s); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + AssetBase asset = (AssetBase) xs.Deserialize(s); _receiver.AssetReceived(asset, isTexture); } @@ -106,7 +99,7 @@ namespace OpenSim.Framework.Communications.Cache { MemoryStream s = new MemoryStream(); - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); xs.Serialize(s, asset); RestClient rc = new RestClient(_assetServerUrl); rc.AddResourcePath("assets"); @@ -129,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - public System.Collections.Generic.List GetDefaultAssets() + public List GetDefaultAssets() { throw new Exception("The method or operation is not implemented."); } @@ -156,4 +149,4 @@ namespace OpenSim.Framework.Communications.Cache #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 0905af8..3495e55 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -25,14 +25,8 @@ * 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.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -44,17 +38,16 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl(InventoryFolderBase folderbase) { - this.agentID = folderbase.agentID; - this.folderID = folderbase.folderID; - this.name = folderbase.name; - this.parentID = folderbase.parentID; - this.type = folderbase.type; - this.version = folderbase.version; + agentID = folderbase.agentID; + folderID = folderbase.folderID; + name = folderbase.name; + parentID = folderbase.parentID; + type = folderbase.type; + version = folderbase.version; } public InventoryFolderImpl() { - } // Methods @@ -65,19 +58,19 @@ namespace OpenSim.Framework.Communications.Cache subFold.folderID = folderID; subFold.type = (short) type; subFold.parentID = this.folderID; - subFold.agentID = this.agentID; - this.SubFolders.Add(subFold.folderID, subFold); + subFold.agentID = agentID; + SubFolders.Add(subFold.folderID, subFold); return subFold; } public InventoryItemBase HasItem(LLUUID itemID) { InventoryItemBase base2 = null; - if (this.Items.ContainsKey(itemID)) + if (Items.ContainsKey(itemID)) { - return this.Items[itemID]; + return Items[itemID]; } - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { base2 = folder.HasItem(itemID); if (base2 != null) @@ -91,12 +84,12 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID itemID) { bool found = false; - if (this.Items.ContainsKey(itemID)) + if (Items.ContainsKey(itemID)) { Items.Remove(itemID); return true; } - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { found = folder.DeleteItem(itemID); if (found == true) @@ -111,13 +104,13 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl HasSubFolder(LLUUID folderID) { InventoryFolderImpl returnFolder = null; - if (this.SubFolders.ContainsKey(folderID)) + if (SubFolders.ContainsKey(folderID)) { - returnFolder = this.SubFolders[folderID]; + returnFolder = SubFolders[folderID]; } else { - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { returnFolder = folder.HasSubFolder(folderID); if (returnFolder != null) @@ -132,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache public List RequestListOfItems() { List itemList = new List(); - foreach (InventoryItemBase item in this.Items.Values) + foreach (InventoryItemBase item in Items.Values) { itemList.Add(item); } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 60f9b6b..765c42e 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -26,12 +26,8 @@ * */ -using System; using System.IO; -using System.Collections.Generic; -using System.Text; using libsecondlife; -using OpenSim.Framework; using Nini.Config; namespace OpenSim.Framework.Communications.Cache @@ -40,43 +36,42 @@ namespace OpenSim.Framework.Communications.Cache /// Basically a hack to give us a Inventory library while we don't have a inventory server /// once the server is fully implemented then should read the data from that /// - public class LibraryRootFolder : Cache.InventoryFolderImpl + public class LibraryRootFolder : InventoryFolderImpl { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - private Cache.InventoryFolderImpl m_textureFolder; + private InventoryFolderImpl m_textureFolder; public LibraryRootFolder() { - this.agentID = libOwner; - this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); - this.name = "OpenSim Library"; - this.parentID = LLUUID.Zero; - this.type = (short)-1; - this.version = (ushort)1; - - Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl(); + agentID = libOwner; + folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); + name = "OpenSim Library"; + parentID = LLUUID.Zero; + type = (short) -1; + version = (ushort) 1; + + InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); folderInfo.name = "Texture Library"; - folderInfo.parentID = this.folderID; + folderInfo.parentID = folderID; folderInfo.type = -1; folderInfo.version = 1; - this.SubFolders.Add(folderInfo.folderID, folderInfo); - this.m_textureFolder = folderInfo; + SubFolders.Add(folderInfo.folderID, folderInfo); + m_textureFolder = folderInfo; - this.CreateLibraryItems(); + CreateLibraryItems(); string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); if (File.Exists(filePath)) { XmlConfigSource source = new XmlConfigSource(filePath); - this.ReadItemsFromFile(source); + ReadItemsFromFile(source); } } private void CreateLibraryItems() { - InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -90,7 +85,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -105,7 +100,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -120,7 +115,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -135,7 +130,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -150,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -161,10 +156,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Shape"; item.assetType = 13; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -175,10 +170,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Skin"; item.assetType = 13; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -189,10 +184,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Shirt"; item.assetType = 5; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -203,11 +198,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Pants"; item.assetType = 5; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); - + Items.Add(item.inventoryID, item); } private void ReadItemsFromFile(IConfigSource source) @@ -217,28 +211,28 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; - item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); + item.inventoryID = + new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); item.inventoryDescription = source.Configs[i].GetString("description", ""); item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); if (item.assetType == 0) { - item.parentFolderID = this.m_textureFolder.folderID; - this.m_textureFolder.Items.Add(item.inventoryID, item); + item.parentFolderID = m_textureFolder.folderID; + m_textureFolder.Items.Add(item.inventoryID, item); } else { - item.parentFolderID = this.folderID; - this.Items.Add(item.inventoryID, item); + item.parentFolderID = folderID; + Items.Add(item.inventoryID, item); } } } - } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 0953e19..b4f29db 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -26,14 +26,8 @@ * */ using System; -using System.IO; -using System.Threading; using System.Reflection; -using libsecondlife; -using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -62,11 +56,14 @@ namespace OpenSim.Framework.Communications.Cache if (typeInterface != null) { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetProvider plug = + (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + MainLog.Instance.Verbose("AssetStorage", + "Added " + m_assetProviderPlugin.Name + " " + + m_assetProviderPlugin.Version); } typeInterface = null; @@ -84,13 +81,13 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } - override protected void RunRequests() + protected override void RunRequests() { while (true) { - ARequest req = this._assetRequests.Dequeue(); + ARequest req = _assetRequests.Dequeue(); - //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); + //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) @@ -105,9 +102,7 @@ namespace OpenSim.Framework.Communications.Cache { _receiver.AssetNotFound(req.AssetID); } - } - } protected override void StoreAsset(AssetBase asset) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 8105556..fe943b0 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -25,16 +25,8 @@ * 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.Communications.Cache; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; - namespace OpenSim.Framework.Communications.Cache { @@ -49,7 +41,7 @@ namespace OpenSim.Framework.Communications.Cache // Methods public UserProfileCache(CommunicationsManager parent) { - this.m_parent = parent; + m_parent = parent; } /// @@ -62,14 +54,14 @@ namespace OpenSim.Framework.Communications.Cache // Potential fix - Multithreading issue. lock (UserProfiles) { - if (!this.UserProfiles.ContainsKey(userID)) + if (!UserProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); - userInfo.UserProfile = this.RequestUserProfileForUser(userID); + CachedUserInfo userInfo = new CachedUserInfo(m_parent); + userInfo.UserProfile = RequestUserProfileForUser(userID); if (userInfo.UserProfile != null) { - this.RequestInventoryForUser(userID, userInfo); - this.UserProfiles.Add(userID, userInfo); + RequestInventoryForUser(userID, userInfo); + UserProfiles.Add(userID, userInfo); } else { @@ -91,26 +83,28 @@ namespace OpenSim.Framework.Communications.Cache public CachedUserInfo GetUserDetails(LLUUID userID) { - if (this.UserProfiles.ContainsKey(userID)) + if (UserProfiles.ContainsKey(userID)) { - return this.UserProfiles[userID]; + return UserProfiles[userID]; } return null; } - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) + public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, + string folderName, LLUUID parentID) { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + CachedUserInfo info = UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + InventoryFolderImpl createdFolder = + info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); if (createdFolder != null) { - this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); } } else @@ -125,27 +119,30 @@ namespace OpenSim.Framework.Communications.Cache } } - public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) + public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, + bool fetchFolders, bool fetchItems, int sortOrder) { - InventoryFolderImpl fold = null; - if (folderID == libraryRoot.folderID ) + InventoryFolderImpl fold = null; + if (folderID == libraryRoot.folderID) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, + libraryRoot.RequestListOfItems()); } - else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) + else if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); } - else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + else if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + CachedUserInfo info = UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == folderID) { if (fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, + info.RootFolder.RequestListOfItems()); } } else @@ -153,7 +150,8 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); if ((folder != null) && fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, + folder.RequestListOfItems()); } } } @@ -166,11 +164,11 @@ namespace OpenSim.Framework.Communications.Cache { //Console.WriteLine("request info for library item"); } - else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + else if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + InventoryItemBase item = UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); if (item != null) { remoteClient.SendInventoryItemDetails(ownerID, item); @@ -185,7 +183,7 @@ namespace OpenSim.Framework.Communications.Cache /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -194,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache /// private UserProfileData RequestUserProfileForUser(LLUUID userID) { - return this.m_parent.UserService.GetUserProfile(userID); + return m_parent.UserService.GetUserProfile(userID); } /// diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a114b64..23dfcc6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -28,18 +28,23 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; -using OpenSim.Framework; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); + public delegate void UpLoadedAsset( + string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, + string inventoryType, string assetType); + public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); + public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); + public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); public class Caps @@ -62,7 +67,8 @@ namespace OpenSim.Region.Capabilities public ItemUpdatedCallback ItemUpdatedCall = null; private bool m_dumpAssetsToFile; - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, + LLUUID agent, bool dumpAssetsToFile) { assetCache = assetCach; m_capsObjectPath = capsPath; @@ -78,12 +84,17 @@ namespace OpenSim.Region.Capabilities /// public void RegisterHandlers() { - OpenSim.Framework.Console.MainLog.Instance.Verbose("CAPS","Registering CAPS handlers"); + MainLog.Instance.Verbose("CAPS", "Registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; try { - httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer)); - httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, + GetMapLayer)); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", + capsBase + m_newInventory, + NewAgentInventoryRequest)); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); @@ -103,7 +114,7 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } - + /// /// /// @@ -113,8 +124,8 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { - // Console.WriteLine("caps request " + request); - string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); + // Console.WriteLine("caps request " + request); + string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); return result; } @@ -125,9 +136,10 @@ namespace OpenSim.Region.Capabilities protected LLSDCapsDetails GetCapabilities() { LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; + string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; + // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; @@ -142,7 +154,7 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) { LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); + mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); return mapResponse; } @@ -174,6 +186,7 @@ namespace OpenSim.Region.Capabilities } #region EventQueue (Currently not enabled) + /// /// /// @@ -184,10 +197,10 @@ namespace OpenSim.Region.Capabilities public string ProcessEventQueue(string request, string path, string param) { string res = ""; - - if (this.CapsEventQueue.Count > 0) + + if (CapsEventQueue.Count > 0) { - lock (this.CapsEventQueue) + lock (CapsEventQueue) { string item = CapsEventQueue.Dequeue(); res = item; @@ -195,7 +208,7 @@ namespace OpenSim.Region.Capabilities } else { - res = this.CreateEmptyEventResponse(); + res = CreateEmptyEventResponse(); } return res; } @@ -214,8 +227,8 @@ namespace OpenSim.Region.Capabilities eventItem.events.Array.Add(new LLSDEmpty()); string res = LLSDHelpers.SerialiseLLSDReply(eventItem); eventQueueCount++; - - this.CapsEventQueue.Enqueue(res); + + CapsEventQueue.Enqueue(res); return res; } @@ -232,6 +245,7 @@ namespace OpenSim.Region.Capabilities eventQueueCount++; return res; } + #endregion /// @@ -243,24 +257,27 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); - + string capsBase = "/CAPS/" + m_capsObjectPath; LLUUID newInvItem = llsdRequest.item_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile ); - uploader.OnUpLoad += this.ItemUpdated; + ItemUpdater uploader = + new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); + uploader.OnUpLoad += ItemUpdated; - httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + 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"; - + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -272,7 +289,7 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); - + string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; @@ -281,14 +298,18 @@ namespace OpenSim.Region.Capabilities LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile); - httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + AssetUploader uploader = + new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); + 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; + uploader.OnUpLoad += UploadCompleteHandler; return uploadResponse; } @@ -298,7 +319,9 @@ namespace OpenSim.Region.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType) + public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, + LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, + string assetType) { sbyte assType = 0; sbyte inType = 0; @@ -319,14 +342,14 @@ namespace OpenSim.Region.Capabilities asset.FullID = assetID; asset.Type = assType; asset.InvType = inType; - asset.Name = assetName; + asset.Name = assetName; asset.Data = data; - this.assetCache.AddAsset(asset); + assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); item.avatarID = agentID; item.creatorsID = agentID; - item.inventoryID = inventoryItem; + item.inventoryID = inventoryItem; item.assetID = asset.FullID; item.inventoryDescription = assetDescription; item.inventoryName = assetName; @@ -340,14 +363,13 @@ namespace OpenSim.Region.Capabilities { AddNewInventoryItem(agentID, item); } - } public LLUUID ItemUpdated(LLUUID itemID, byte[] data) { if (ItemUpdatedCall != null) { - return ItemUpdatedCall(this.agentID, itemID, data); + return ItemUpdatedCall(agentID, itemID, data); } return LLUUID.Zero; } @@ -359,7 +381,7 @@ namespace OpenSim.Region.Capabilities private string uploaderPath = ""; private LLUUID newAssetID; private LLUUID inventoryItemID; - private LLUUID parentFolder; + private LLUUID parentFolder; private BaseHttpServer httpListener; private bool m_dumpAssetsToFile; private string m_assetName = ""; @@ -368,7 +390,9 @@ namespace OpenSim.Region.Capabilities private string m_invType = ""; private string m_assetType = ""; - public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile) + public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, + LLUUID parentFolderID, string invType, string assetType, string path, + BaseHttpServer httpServer, bool dumpAssetsToFile) { m_assetName = assetName; m_assetDes = description; @@ -391,7 +415,7 @@ namespace OpenSim.Region.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = this.inventoryItemID; + LLUUID inv = inventoryItemID; string res = ""; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToStringHyphenated(); @@ -399,29 +423,29 @@ namespace OpenSim.Region.Capabilities uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - + httpListener.RemoveStreamHandler("POST", uploaderPath); - if (this.m_dumpAssetsToFile) + if (m_dumpAssetsToFile) { - this.SaveAssetToFile(m_assetName + ".jp2", data); + SaveAssetToFile(m_assetName + ".jp2", data); } if (OnUpLoad != null) { OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } - + return res; } private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); + FileStream fs = File.Create(filename); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close(); } } @@ -434,7 +458,7 @@ namespace OpenSim.Region.Capabilities private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) + public ItemUpdater(LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; @@ -452,7 +476,7 @@ namespace OpenSim.Region.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = this.inventoryItemID; + LLUUID inv = inventoryItemID; string res = ""; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); LLUUID assetID = LLUUID.Zero; @@ -461,7 +485,7 @@ namespace OpenSim.Region.Capabilities { assetID = OnUpLoad(inv, data); } - + uploadComplete.new_asset = assetID.ToStringHyphenated(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; @@ -470,9 +494,9 @@ namespace OpenSim.Region.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); - if (this.m_dumpAssetToFile) + if (m_dumpAssetToFile) { - this.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); + SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } return res; @@ -488,6 +512,4 @@ namespace OpenSim.Region.Capabilities } } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 2af5a4a..2ed7750 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -36,7 +36,6 @@ namespace OpenSim.Region.Capabilities public LLSDArray() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index e65e741..d054386 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -39,7 +39,6 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadComplete() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 3a2fe20..7fed27a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -26,9 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; namespace OpenSim.Region.Capabilities @@ -46,4 +43,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index c7a9ee6..3ad618d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Capabilities { [LLSDMap] @@ -40,7 +36,6 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index d1894d4..06afac4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDCapEvent() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index 3184792..35caa15 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -34,18 +34,14 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - // public string RequestTextureDownload = ""; - // public string ChatSessionRequest = ""; + // public string RequestTextureDownload = ""; + // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; - // public string ParcelVoiceInfoRequest = ""; + // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() { - } } -} - - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 0169d3c..69c525c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -32,7 +32,6 @@ namespace OpenSim.Region.Capabilities { public LLSDEmpty() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 8a2215f..8252a63 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.Capabilities public static void SerializeLLSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); if (llsdattributes.Length > 0) { switch (llsdattributes[0].ObjectType) @@ -62,7 +62,8 @@ namespace OpenSim.Region.Capabilities for (int i = 0; i < fields.Length; i++) { object fieldValue = fields[i].GetValue(obj); - LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] fieldAttributes = + (LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false); if (fieldAttributes.Length > 0) { writer.WriteStartElement(String.Empty, "key", String.Empty); @@ -83,7 +84,7 @@ namespace OpenSim.Region.Capabilities case "ARRAY": // LLSDArray arrayObject = obj as LLSDArray; // ArrayList a = arrayObject.Array; - ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj); + ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); if (a != null) { writer.WriteStartElement(String.Empty, "array", String.Empty); @@ -105,7 +106,7 @@ namespace OpenSim.Region.Capabilities public static object DeserialiseLLSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); if (llsdattributes.Length > 0) { switch (llsdattributes[0].ObjectType) @@ -114,7 +115,7 @@ namespace OpenSim.Region.Capabilities IDictionaryEnumerator enumerator = llsd.GetEnumerator(); while (enumerator.MoveNext()) { - FieldInfo field = myType.GetField((string)enumerator.Key); + FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { if (enumerator.Value is Hashtable) @@ -142,23 +143,4 @@ namespace OpenSim.Region.Capabilities return obj; } } - - - - - - - - - - - - - - - - - - - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 57fc9e8..3842058 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -26,9 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; namespace OpenSim.Region.Capabilities @@ -42,4 +39,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 6d17bff..683e479 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -40,7 +40,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayer() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 7900290..1945a6c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayerResponse() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 5fa08c9..935f81d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapRequest() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index 67253ee..6bd47e1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -26,11 +26,7 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Capabilities { public delegate TResponse LLSDMethod(TRequest request); -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 894b276..08e9563 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -26,13 +26,11 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Servers; -using System.IO; using System.Collections; +using System.IO; +using System.Text; using libsecondlife; +using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities { @@ -42,11 +40,11 @@ namespace OpenSim.Region.Capabilities private LLSDMethod m_method; public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) - : base(httpMethod, path ) + : base(httpMethod, path) { m_method = method; } - + public override byte[] Handle(string path, Stream request) { //Encoding encoding = Encoding.UTF8; @@ -55,16 +53,15 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); + 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) ); + return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index f70fa11..c2a6054 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDTest() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 6af7f39..a90ae03 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -37,23 +37,19 @@ namespace OpenSim.Region.Capabilities public LLSDType(string type) { myType = type; - } public string ObjectType { - get - { - return myType; - } + get { return myType; } } } [AttributeUsage(AttributeTargets.Class)] public class LLSDMap : LLSDType { - public LLSDMap() : base( "MAP" ) + public LLSDMap() : base("MAP") { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d8d198b..77c7261 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,69 +28,77 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications { public class CommunicationsManager { protected IUserService m_userService; + public IUserService UserService { get { return m_userService; } } protected IGridServices m_gridService; + public IGridServices GridService { get { return m_gridService; } } protected IInventoryServices m_inventoryService; + public IInventoryServices InventoryService { get { return m_inventoryService; } } protected IInterRegionCommunications m_interRegion; + public IInterRegionCommunications InterRegion { get { return m_interRegion; } } protected UserProfileCache m_userProfileCache; + public UserProfileCache UserProfileCache { get { return m_userProfileCache; } } protected AssetTransactionManager m_transactionsManager; + public AssetTransactionManager TransactionsManager { get { return m_transactionsManager; } } protected AssetCache m_assetCache; + public AssetCache AssetCache { get { return m_assetCache; } } protected NetworkServersInfo m_networkServersInfo; + public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } } - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool dumpAssetsToFile) + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, + bool dumpAssetsToFile) { m_networkServersInfo = serversInfo; m_assetCache = assetCache; m_userProfileCache = new UserProfileCache(this); - m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile ); + m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } public void doCreate(string[] cmmdParams) @@ -106,7 +114,6 @@ namespace OpenSim.Framework.Communications if (cmmdParams.Length < 2) { - firstName = MainLog.Instance.CmdPrompt("First name", "Default"); lastName = MainLog.Instance.CmdPrompt("Last name", "User"); password = MainLog.Instance.PasswdPrompt("Password"); @@ -120,7 +127,6 @@ namespace OpenSim.Framework.Communications password = cmmdParams[3]; regX = Convert.ToUInt32(cmmdParams[4]); regY = Convert.ToUInt32(cmmdParams[5]); - } AddUser(firstName, lastName, password, regX, regY); @@ -140,7 +146,7 @@ namespace OpenSim.Framework.Communications } else { - this.m_inventoryService.CreateNewUserInventory(userProf.UUID); + m_inventoryService.CreateNewUserInventory(userProf.UUID); System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); return userProf.UUID; } diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index ccbb729..ce6205f 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -27,10 +27,6 @@ */ using System.Collections.Generic; -using System.Net; -using libsecondlife; - -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -41,4 +37,4 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 244747d..d4fb54b 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -36,4 +35,4 @@ namespace OpenSim.Framework.Communications bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index e7758c4..fc301c2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -26,16 +26,14 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); + public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); public interface IInventoryServices @@ -53,4 +51,4 @@ namespace OpenSim.Framework.Communications /// List RequestFirstLevelFolders(LLUUID userID); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 05183be..effe132 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -30,10 +30,8 @@ using System; using System.Collections.Generic; using System.Reflection; using libsecondlife; -using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -67,10 +65,10 @@ namespace OpenSim.Framework.Communications if (typeInterface != null) { IInventoryData plug = - (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface"); + m_plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("INVENTORY", "Added IInventoryData Interface"); } } } @@ -168,7 +166,7 @@ namespace OpenSim.Framework.Communications { foreach (InventoryFolderBase folder in inventory.Folders.Values) { - this.AddFolder(folder); + AddFolder(folder); } } @@ -176,7 +174,7 @@ namespace OpenSim.Framework.Communications { UsersInventory inven = new UsersInventory(); inven.CreateNewInventorySet(user); - this.AddNewInventorySet(inven); + AddNewInventorySet(inven); } public class UsersInventory @@ -186,7 +184,6 @@ namespace OpenSim.Framework.Communications public UsersInventory() { - } public virtual void CreateNewInventorySet(LLUUID user) @@ -231,9 +228,11 @@ namespace OpenSim.Framework.Communications } } - public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 38bc016..4d1c35a 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -34,12 +34,10 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement { - /// /// A temp class to handle login response. /// Should make use of UserProfileManager where possible. /// - public class LoginResponse { private Hashtable loginFlagsHash; @@ -103,211 +101,222 @@ namespace OpenSim.Framework.UserManagement public LoginResponse() { - this.loginFlags = new ArrayList(); - this.globalTextures = new ArrayList(); - this.eventCategories = new ArrayList(); - this.uiConfig = new ArrayList(); - this.classifiedCategories = new ArrayList(); + loginFlags = new ArrayList(); + globalTextures = new ArrayList(); + eventCategories = new ArrayList(); + uiConfig = new ArrayList(); + classifiedCategories = new ArrayList(); - this.loginError = new Hashtable(); - this.uiConfigHash = new Hashtable(); + loginError = new Hashtable(); + uiConfigHash = new Hashtable(); - this.defaultXmlRpcResponse = new XmlRpcResponse(); - this.userProfile = new UserInfo(); - this.inventoryRoot = new ArrayList(); - this.initialOutfit = new ArrayList(); - this.agentInventory = new ArrayList(); - this.inventoryLibrary = new ArrayList(); - this.inventoryLibraryOwner = new ArrayList(); + defaultXmlRpcResponse = new XmlRpcResponse(); + userProfile = new UserInfo(); + inventoryRoot = new ArrayList(); + initialOutfit = new ArrayList(); + agentInventory = new ArrayList(); + inventoryLibrary = new ArrayList(); + inventoryLibraryOwner = new ArrayList(); - this.xmlRpcResponse = new XmlRpcResponse(); - this.defaultXmlRpcResponse = new XmlRpcResponse(); + xmlRpcResponse = new XmlRpcResponse(); + defaultXmlRpcResponse = new XmlRpcResponse(); - this.SetDefaultValues(); + SetDefaultValues(); } // LoginServer public void SetDefaultValues() { - this.DST = "N"; - this.StipendSinceLogin = "N"; - this.Gendered = "Y"; - this.EverLoggedIn = "Y"; - this.login = "false"; - this.firstname = "Test"; - this.lastname = "User"; - this.agentAccess = "M"; - this.startLocation = "last"; - this.allowFirstLife = "Y"; - - this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - - this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; - this.ErrorReason = "key"; - this.welcomeMessage = "Welcome to OpenSim!"; - this.seedCapability = ""; - this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}"; - this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; - this.RegionX = (uint)255232; - this.RegionY = (uint)254976; - - // Classifieds; - this.AddClassifiedCategory((Int32)1, "Shopping"); - this.AddClassifiedCategory((Int32)2, "Land Rental"); - this.AddClassifiedCategory((Int32)3, "Property Rental"); - this.AddClassifiedCategory((Int32)4, "Special Attraction"); - this.AddClassifiedCategory((Int32)5, "New Products"); - this.AddClassifiedCategory((Int32)6, "Employment"); - this.AddClassifiedCategory((Int32)7, "Wanted"); - this.AddClassifiedCategory((Int32)8, "Service"); - this.AddClassifiedCategory((Int32)9, "Personal"); - - - this.SessionID = LLUUID.Random(); - this.SecureSessionID = LLUUID.Random(); - this.AgentID = LLUUID.Random(); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - this.initialOutfit.Add(InitialOutfitHash); - - + DST = "N"; + StipendSinceLogin = "N"; + Gendered = "Y"; + EverLoggedIn = "Y"; + login = "false"; + firstname = "Test"; + lastname = "User"; + agentAccess = "M"; + startLocation = "last"; + allowFirstLife = "Y"; + + SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + + ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + ErrorReason = "key"; + welcomeMessage = "Welcome to OpenSim!"; + seedCapability = ""; + home = "{'region_handle':[r" + (1000*256).ToString() + ",r" + (1000*256).ToString() + "], 'position':[r" + + userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + + userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + + userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; + lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + RegionX = (uint) 255232; + RegionY = (uint) 254976; + + // Classifieds; + AddClassifiedCategory((Int32) 1, "Shopping"); + AddClassifiedCategory((Int32) 2, "Land Rental"); + AddClassifiedCategory((Int32) 3, "Property Rental"); + AddClassifiedCategory((Int32) 4, "Special Attraction"); + AddClassifiedCategory((Int32) 5, "New Products"); + AddClassifiedCategory((Int32) 6, "Employment"); + AddClassifiedCategory((Int32) 7, "Wanted"); + AddClassifiedCategory((Int32) 8, "Service"); + AddClassifiedCategory((Int32) 9, "Personal"); + + + SessionID = LLUUID.Random(); + SecureSessionID = LLUUID.Random(); + AgentID = LLUUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + initialOutfit.Add(InitialOutfitHash); } // SetDefaultValues #region Login Failure Methods + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) { // Overwrite any default values; - this.xmlRpcResponse = new XmlRpcResponse(); + xmlRpcResponse = new XmlRpcResponse(); // Ensure Login Failed message/reason; - this.ErrorMessage = message; - this.ErrorReason = reason; - - this.loginError["reason"] = this.ErrorReason; - this.loginError["message"] = this.ErrorMessage; - this.loginError["login"] = login; - this.xmlRpcResponse.Value = this.loginError; - return (this.xmlRpcResponse); + ErrorMessage = message; + ErrorReason = reason; + + loginError["reason"] = ErrorReason; + loginError["message"] = ErrorMessage; + loginError["login"] = login; + xmlRpcResponse.Value = loginError; + return (xmlRpcResponse); } // GenerateResponse public XmlRpcResponse CreateFailedResponse() { - return (this.CreateLoginFailedResponse()); + return (CreateLoginFailedResponse()); } // CreateErrorConnectingToGridResponse() public XmlRpcResponse CreateLoginFailedResponse() { - return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false")); + return + (GenerateFailureResponse("key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false")); } // LoginFailedResponse public XmlRpcResponse CreateAlreadyLoggedInResponse() { - return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false")); + return + (GenerateFailureResponse("presence", + "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", + "false")); } // CreateAlreadyLoggedInResponse() public XmlRpcResponse CreateDeadRegionResponse() { - return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false")); + return + (GenerateFailureResponse("key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false")); } - public XmlRpcResponse CreateGridErrorResponse() + public XmlRpcResponse CreateGridErrorResponse() { - return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false")); + return + (GenerateFailureResponse("key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false")); } - + #endregion public XmlRpcResponse ToXmlRpcResponse() { try { - Hashtable responseData = new Hashtable(); - this.loginFlagsHash = new Hashtable(); - this.loginFlagsHash["daylight_savings"] = this.DST; - this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin; - this.loginFlagsHash["gendered"] = this.Gendered; - this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn; - this.loginFlags.Add(this.loginFlagsHash); - - responseData["first_name"] = this.Firstname; - responseData["last_name"] = this.Lastname; - responseData["agent_access"] = this.agentAccess; - - this.globalTexturesHash = new Hashtable(); - this.globalTexturesHash["sun_texture_id"] = this.SunTexture; - this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture; - this.globalTexturesHash["moon_texture_id"] = this.MoonTexture; - this.globalTextures.Add(this.globalTexturesHash); - // this.eventCategories.Add(this.eventCategoriesHash); - - this.AddToUIConfig("allow_first_life", this.allowFirstLife); - this.uiConfig.Add(this.uiConfigHash); - - responseData["sim_port"] =(Int32) this.SimPort; - responseData["sim_ip"] = this.SimAddress; - - responseData["agent_id"] = this.AgentID.ToStringHyphenated(); - responseData["session_id"] = this.SessionID.ToStringHyphenated(); - responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated(); - responseData["circuit_code"] = this.CircuitCode; - responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = this.loginFlags; - responseData["global-textures"] = this.globalTextures; - responseData["seed_capability"] = this.seedCapability; - - responseData["event_categories"] = this.eventCategories; + loginFlagsHash = new Hashtable(); + loginFlagsHash["daylight_savings"] = DST; + loginFlagsHash["stipend_since_login"] = StipendSinceLogin; + loginFlagsHash["gendered"] = Gendered; + loginFlagsHash["ever_logged_in"] = EverLoggedIn; + loginFlags.Add(loginFlagsHash); + + responseData["first_name"] = Firstname; + responseData["last_name"] = Lastname; + responseData["agent_access"] = agentAccess; + + globalTexturesHash = new Hashtable(); + globalTexturesHash["sun_texture_id"] = SunTexture; + globalTexturesHash["cloud_texture_id"] = CloudTexture; + globalTexturesHash["moon_texture_id"] = MoonTexture; + globalTextures.Add(globalTexturesHash); + // this.eventCategories.Add(this.eventCategoriesHash); + + AddToUIConfig("allow_first_life", allowFirstLife); + uiConfig.Add(uiConfigHash); + + responseData["sim_port"] = (Int32) SimPort; + responseData["sim_ip"] = SimAddress; + + responseData["agent_id"] = AgentID.ToStringHyphenated(); + responseData["session_id"] = SessionID.ToStringHyphenated(); + responseData["secure_session_id"] = SecureSessionID.ToStringHyphenated(); + responseData["circuit_code"] = CircuitCode; + responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = loginFlags; + responseData["global-textures"] = globalTextures; + responseData["seed_capability"] = seedCapability; + + responseData["event_categories"] = eventCategories; responseData["event_notifications"] = new ArrayList(); // todo - responseData["classified_categories"] = this.classifiedCategories; - responseData["ui-config"] = this.uiConfig; + responseData["classified_categories"] = classifiedCategories; + responseData["ui-config"] = uiConfig; - responseData["inventory-skeleton"] = this.agentInventory; - responseData["inventory-skel-lib"] = this.inventoryLibrary; - responseData["inventory-root"] = this.inventoryRoot; + responseData["inventory-skeleton"] = agentInventory; + responseData["inventory-skel-lib"] = inventoryLibrary; + responseData["inventory-root"] = inventoryRoot; responseData["gestures"] = new ArrayList(); // todo - responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; - responseData["initial-outfit"] = this.initialOutfit; - responseData["start_location"] = this.startLocation; - responseData["seed_capability"] = this.seedCapability; - responseData["home"] = this.home; - responseData["look_at"] = this.lookAt; - responseData["message"] = this.welcomeMessage; - responseData["region_x"] = (Int32)this.RegionX * 256; - responseData["region_y"] = (Int32)this.RegionY * 256; + responseData["inventory-lib-owner"] = inventoryLibraryOwner; + responseData["initial-outfit"] = initialOutfit; + responseData["start_location"] = startLocation; + responseData["seed_capability"] = seedCapability; + responseData["home"] = home; + responseData["look_at"] = lookAt; + responseData["message"] = welcomeMessage; + responseData["region_x"] = (Int32) RegionX*256; + responseData["region_y"] = (Int32) RegionY*256; //responseData["inventory-lib-root"] = new ArrayList(); // todo //responseData["buddy-list"] = new ArrayList(); // todo responseData["login"] = "true"; - this.xmlRpcResponse.Value = responseData; + xmlRpcResponse.Value = responseData; - return (this.xmlRpcResponse); + return (xmlRpcResponse); } catch (Exception e) { MainLog.Instance.Warn( "CLIENT", "LoginResponse: Error creating XML-RPC Response: " + e.Message - ); - return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); - + ); + return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); } - } // ToXmlRpcResponse public void SetEventCategories(string category, string value) { - // this.eventCategoriesHash[category] = value; + // this.eventCategoriesHash[category] = value; //TODO } // SetEventCategories public void AddToUIConfig(string itemName, string item) { - this.uiConfigHash[itemName] = item; + uiConfigHash[itemName] = item; } // SetUIConfig public void AddClassifiedCategory(Int32 ID, string categoryName) @@ -315,372 +324,193 @@ namespace OpenSim.Framework.UserManagement Hashtable hash = new Hashtable(); hash["category_name"] = categoryName; hash["category_id"] = ID; - this.classifiedCategories.Add(hash); + classifiedCategories.Add(hash); // this.classifiedCategoriesHash.Clear(); } // SetClassifiedCategory #region Properties + public string Login { - get - { - return this.login; - } - set - { - this.login = value; - } + get { return login; } + set { login = value; } } // Login public string DST { - get - { - return this.dst; - } - set - { - this.dst = value; - } + get { return dst; } + set { dst = value; } } // DST public string StipendSinceLogin { - get - { - return this.stipendSinceLogin; - } - set - { - this.stipendSinceLogin = value; - } + get { return stipendSinceLogin; } + set { stipendSinceLogin = value; } } // StipendSinceLogin public string Gendered { - get - { - return this.gendered; - } - set - { - this.gendered = value; - } + get { return gendered; } + set { gendered = value; } } // Gendered public string EverLoggedIn { - get - { - return this.everLoggedIn; - } - set - { - this.everLoggedIn = value; - } + get { return everLoggedIn; } + set { everLoggedIn = value; } } // EverLoggedIn public int SimPort { - get - { - return this.simPort; - } - set - { - this.simPort = value; - } + get { return simPort; } + set { simPort = value; } } // SimPort public string SimAddress { - get - { - return this.simAddress; - } - set - { - this.simAddress = value; - } + get { return simAddress; } + set { simAddress = value; } } // SimAddress public LLUUID AgentID { - get - { - return this.agentID; - } - set - { - this.agentID = value; - } + get { return agentID; } + set { agentID = value; } } // AgentID public LLUUID SessionID { - get - { - return this.sessionID; - } - set - { - this.sessionID = value; - } + get { return sessionID; } + set { sessionID = value; } } // SessionID public LLUUID SecureSessionID { - get - { - return this.secureSessionID; - } - set - { - this.secureSessionID = value; - } + get { return secureSessionID; } + set { secureSessionID = value; } } // SecureSessionID public Int32 CircuitCode { - get - { - return this.circuitCode; - } - set - { - this.circuitCode = value; - } + get { return circuitCode; } + set { circuitCode = value; } } // CircuitCode public uint RegionX { - get - { - return this.regionX; - } - set - { - this.regionX = value; - } + get { return regionX; } + set { regionX = value; } } // RegionX public uint RegionY { - get - { - return this.regionY; - } - set - { - this.regionY = value; - } + get { return regionY; } + set { regionY = value; } } // RegionY public string SunTexture { - get - { - return this.sunTexture; - } - set - { - this.sunTexture = value; - } + get { return sunTexture; } + set { sunTexture = value; } } // SunTexture public string CloudTexture { - get - { - return this.cloudTexture; - } - set - { - this.cloudTexture = value; - } + get { return cloudTexture; } + set { cloudTexture = value; } } // CloudTexture public string MoonTexture { - get - { - return this.moonTexture; - } - set - { - this.moonTexture = value; - } + get { return moonTexture; } + set { moonTexture = value; } } // MoonTexture public string Firstname { - get - { - return this.firstname; - } - set - { - this.firstname = value; - } + get { return firstname; } + set { firstname = value; } } // Firstname public string Lastname { - get - { - return this.lastname; - } - set - { - this.lastname = value; - } + get { return lastname; } + set { lastname = value; } } // Lastname public string AgentAccess { - get - { - return this.agentAccess; - } - set - { - this.agentAccess = value; - } + get { return agentAccess; } + set { agentAccess = value; } } public string StartLocation { - get - { - return this.startLocation; - } - set - { - this.startLocation = value; - } + get { return startLocation; } + set { startLocation = value; } } // StartLocation public string LookAt { - get - { - return this.lookAt; - } - set - { - this.lookAt = value; - } + get { return lookAt; } + set { lookAt = value; } } public string SeedCapability { - get - { - return this.seedCapability; - } - set - { - this.seedCapability = value; - } + get { return seedCapability; } + set { seedCapability = value; } } // SeedCapability public string ErrorReason { - get - { - return this.errorReason; - } - set - { - this.errorReason = value; - } + get { return errorReason; } + set { errorReason = value; } } // ErrorReason public string ErrorMessage { - get - { - return this.errorMessage; - } - set - { - this.errorMessage = value; - } + get { return errorMessage; } + set { errorMessage = value; } } // ErrorMessage public ArrayList InventoryRoot { - get - { - return this.inventoryRoot; - } - set - { - this.inventoryRoot = value; - } + get { return inventoryRoot; } + set { inventoryRoot = value; } } public ArrayList InventorySkeleton { - get - { - return this.agentInventory; - } - set - { - this.agentInventory = value; - } + get { return agentInventory; } + set { agentInventory = value; } } public ArrayList InventoryLibrary { - get - { - return this.inventoryLibrary; - } - set - { - this.inventoryLibrary = value; - } + get { return inventoryLibrary; } + set { inventoryLibrary = value; } } public ArrayList InventoryLibraryOwner { - get - { - return this.inventoryLibraryOwner; - } - set - { - this.inventoryLibraryOwner = value; - } + get { return inventoryLibraryOwner; } + set { inventoryLibraryOwner = value; } } public string Home { - get - { - return this.home; - } - set - { - this.home = value; - } + get { return home; } + set { home = value; } } public string Message { - get - { - return this.welcomeMessage; - } - set - { - this.welcomeMessage = value; - } + get { return welcomeMessage; } + set { welcomeMessage = value; } } - #endregion + #endregion public class UserInfo { @@ -691,6 +521,4 @@ namespace OpenSim.Framework.UserManagement public LLVector3 homelookat; } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 66b91e1..497cc5d 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -28,16 +28,10 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using OpenSim.Framework; -using InventoryFolder = OpenSim.Framework.InventoryFolder; - namespace OpenSim.Framework.UserManagement { public class LoginService @@ -61,12 +55,12 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - - MainLog.Instance.Verbose("LOGIN","Attempting login now..."); + MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && + requestData.Contains("passwd")); bool GoodLogin = false; UserProfileData userProfile; @@ -74,9 +68,9 @@ namespace OpenSim.Framework.UserManagement if (GoodXML) { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; + string firstname = (string) requestData["first"]; + string lastname = (string) requestData["last"]; + string passwd = (string) requestData["passwd"]; userProfile = GetTheUser(firstname, lastname); if (userProfile == null) @@ -110,7 +104,7 @@ namespace OpenSim.Framework.UserManagement LLUUID agentID = userProfile.UUID; // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); + InventoryData inventData = CreateInventoryData(agentID); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -120,7 +114,7 @@ namespace OpenSim.Framework.UserManagement userProfile.rootInventoryFolderID = inventData.RootFolderID; // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); + uint circode = (uint) (Util.RandomClass.Next()); logResponse.Lastname = userProfile.surname; logResponse.Firstname = userProfile.username; @@ -129,20 +123,20 @@ namespace OpenSim.Framework.UserManagement logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; + logResponse.InventoryLibrary = GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.CircuitCode = (Int32) circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; //logResponse.SimAddress = "127.0.0.1"; //overwritten //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); + logResponse.Message = GetMessage(); try { - this.CustomiseResponse(logResponse, userProfile); + CustomiseResponse(logResponse, userProfile); } catch (Exception e) { @@ -152,7 +146,6 @@ namespace OpenSim.Framework.UserManagement } CommitAgent(ref userProfile); return logResponse.ToXmlRpcResponse(); - } catch (Exception E) @@ -162,7 +155,6 @@ namespace OpenSim.Framework.UserManagement //} } return response; - } /// @@ -174,7 +166,7 @@ namespace OpenSim.Framework.UserManagement { } - /// + /// /// Saves a target agent to the database /// /// The users profile @@ -194,8 +186,7 @@ namespace OpenSim.Framework.UserManagement /// Authenticated? public virtual bool AuthenticateUser(UserProfileData profile, string password) { - - MainLog.Instance.Verbose("LOGIN","Authenticating " + profile.username + " " + profile.surname); + MainLog.Instance.Verbose("LOGIN", "Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ @@ -211,7 +202,7 @@ namespace OpenSim.Framework.UserManagement /// public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - this.m_userManager.CreateAgent(profile, request); + m_userManager.CreateAgent(profile, request); } /// @@ -222,7 +213,7 @@ namespace OpenSim.Framework.UserManagement /// public virtual UserProfileData GetTheUser(string firstname, string lastname) { - return this.m_userManager.GetUserProfile(firstname, lastname); + return m_userManager.GetUserProfile(firstname, lastname); } /// @@ -286,8 +277,8 @@ namespace OpenSim.Framework.UserManagement TempHash = new Hashtable(); TempHash["name"] = InvFolder.FolderName; TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["version"] = (Int32) InvFolder.Version; + TempHash["type_default"] = (Int32) InvFolder.DefaultType; TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); AgentInventoryArray.Add(TempHash); } @@ -307,4 +298,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 43fce84..a812ac9 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,25 +27,29 @@ */ 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("OpenGrid.Framework.Communications")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenGrid.Framework.Communications")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenGrid.Framework.Communications")] +[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)] + +[assembly : ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] + +[assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] // Version information for an assembly consists of the following four values: // @@ -56,5 +60,6 @@ using System.Runtime.InteropServices; // // 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")] + +[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index c821fa4..72d8f65 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading; namespace OpenSim.Framework.Communications { internal class SimpleAsyncResult : IAsyncResult { - private readonly AsyncCallback m_callback; /// @@ -36,7 +33,6 @@ namespace OpenSim.Framework.Communications m_completedSynchronously = 1; } - #region IAsyncResult Members public object AsyncState @@ -45,7 +41,6 @@ namespace OpenSim.Framework.Communications } - public WaitHandle AsyncWaitHandle { get @@ -82,19 +77,18 @@ namespace OpenSim.Framework.Communications get { return Thread.VolatileRead(ref m_completed) == 1; } } - #endregion - #region class Methods + internal void SetAsCompleted(bool completedSynchronously) { m_completed = 1; - if(completedSynchronously) + if (completedSynchronously) m_completedSynchronously = 1; else m_completedSynchronously = 0; - + SignalCompletion(); } @@ -112,9 +106,9 @@ namespace OpenSim.Framework.Communications private void SignalCompletion() { - if(m_waitHandle != null) m_waitHandle.Set(); + if (m_waitHandle != null) m_waitHandle.Set(); - if(m_callback != null) m_callback(this); + if (m_callback != null) m_callback(this); } public void EndInvoke() @@ -125,14 +119,14 @@ namespace OpenSim.Framework.Communications // If the operation isn't done, wait for it AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); - m_waitHandle = null; // Allow early GC + m_waitHandle = null; // Allow early GC } // Operation is done: if an exception occured, throw it if (m_exception != null) throw m_exception; - } + } - #endregion + #endregion } internal class AsyncResult : SimpleAsyncResult @@ -140,10 +134,12 @@ namespace OpenSim.Framework.Communications private T m_result = default(T); public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) { } + base(asyncCallback, state) + { + } - public void SetAsCompleted(T result, bool completedSynchronously) + public void SetAsCompleted(T result, bool completedSynchronously) { // Save the asynchronous operation's result m_result = result; @@ -153,11 +149,10 @@ namespace OpenSim.Framework.Communications base.SetAsCompleted(completedSynchronously); } - new public T EndInvoke() + public new T EndInvoke() { - base.EndInvoke(); - return m_result; + base.EndInvoke(); + return m_result; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 392669f..ac3a287 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -1,12 +1,10 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; -using System.Web; using System.Text; -using System.Collections.Generic; using System.Threading; - -using OpenSim.Framework.Console; +using System.Web; namespace OpenSim.Framework.Communications { @@ -29,9 +27,10 @@ namespace OpenSim.Framework.Communications /// public class RestClient { + private string realuri; - string realuri; #region member variables + /// /// The base Uri of the web-service e.g. http://www.google.com /// @@ -60,7 +59,7 @@ namespace OpenSim.Framework.Communications /// /// MemoryStream representing the resultiong resource /// - Stream _resource; + private Stream _resource; /// /// WebRequest object, held as a member variable @@ -80,12 +79,12 @@ namespace OpenSim.Framework.Communications /// /// Default time out period /// - const int DefaultTimeout = 10 * 1000; // 10 seconds timeout + private const int DefaultTimeout = 10*1000; // 10 seconds timeout /// /// Default Buffer size of a block requested from the web-server /// - const int BufferSize = 4096; // Read blocks of 4 KB. + private const int BufferSize = 4096; // Read blocks of 4 KB. /// @@ -97,6 +96,7 @@ namespace OpenSim.Framework.Communications #endregion member variables #region constructors + /// /// Instantiate a new RestClient /// @@ -111,7 +111,8 @@ namespace OpenSim.Framework.Communications _lock = new object(); } - object _lock; + private object _lock; + #endregion constructors /// @@ -120,8 +121,8 @@ namespace OpenSim.Framework.Communications /// path entry public void AddResourcePath(string element) { - if(isSlashed(element)) - _pathElements.Add(element.Substring(0, element.Length-1)); + if (isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length - 1)); else _pathElements.Add(element); } @@ -178,7 +179,7 @@ namespace OpenSim.Framework.Communications /// Build a Uri based on the intial Url, path elements and parameters /// /// fully constructed Uri - Uri buildUri() + private Uri buildUri() { StringBuilder sb = new StringBuilder(); sb.Append(_url); @@ -196,7 +197,8 @@ namespace OpenSim.Framework.Communications { sb.Append("?"); firstElement = false; - } else + } + else sb.Append("&"); sb.Append(kv.Key); @@ -209,7 +211,9 @@ namespace OpenSim.Framework.Communications realuri = sb.ToString(); return new Uri(sb.ToString()); } + #region Async communications with server + /// /// Async method, invoked when a block of data has been received from the service /// @@ -218,13 +222,14 @@ namespace OpenSim.Framework.Communications { try { - Stream s = (Stream)ar.AsyncState; + Stream s = (Stream) ar.AsyncState; int read = s.EndRead(ar); if (read > 0) { _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); // TODO! Implement timeout, without killing the server //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); @@ -251,12 +256,13 @@ namespace OpenSim.Framework.Communications try { // grab response - WebRequest wr = (WebRequest)ar.AsyncState; - _response = (HttpWebResponse)wr.EndGetResponse(ar); + WebRequest wr = (WebRequest) ar.AsyncState; + _response = (HttpWebResponse) wr.EndGetResponse(ar); // get response stream, and setup async reading Stream s = _response.GetResponseStream(); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); // TODO! Implement timeout, without killing the server // wait until completed, or we timed out @@ -281,6 +287,7 @@ namespace OpenSim.Framework.Communications } } } + #endregion Async communications with server /// @@ -290,17 +297,17 @@ namespace OpenSim.Framework.Communications { lock (_lock) { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; _request.Timeout = 200000; _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse)_request.GetResponse(); + _response = (HttpWebResponse) _request.GetResponse(); Stream src = _response.GetResponseStream(); int length = src.Read(_readbuf, 0, BufferSize); - while(length > 0) + while (length > 0) { _resource.Write(_readbuf, 0, length); length = src.Read(_readbuf, 0, BufferSize); @@ -329,7 +336,7 @@ namespace OpenSim.Framework.Communications public Stream Request(Stream src) { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; _request.Timeout = 900000; @@ -340,13 +347,13 @@ namespace OpenSim.Framework.Communications src.Seek(0, SeekOrigin.Begin); Stream dst = _request.GetRequestStream(); byte[] buf = new byte[1024]; - int length = src.Read(buf,0, 1024); + int length = src.Read(buf, 0, 1024); while (length > 0) { dst.Write(buf, 0, length); length = src.Read(buf, 0, 1024); } - _response = (HttpWebResponse)_request.GetResponse(); + _response = (HttpWebResponse) _request.GetResponse(); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -357,8 +364,8 @@ namespace OpenSim.Framework.Communications return null; } - #region Async Invocation + public IAsyncResult BeginRequest(AsyncCallback callback, object state) { /// @@ -371,7 +378,7 @@ namespace OpenSim.Framework.Communications public Stream EndRequest(IAsyncResult asyncResult) { - AsyncResult ar = (AsyncResult)asyncResult; + AsyncResult ar = (AsyncResult) asyncResult; // Wait for operation to complete, then return result or // throw exception @@ -381,7 +388,7 @@ namespace OpenSim.Framework.Communications private void RequestHelper(Object asyncResult) { // We know that it's really an AsyncResult object - AsyncResult ar = (AsyncResult)asyncResult; + AsyncResult ar = (AsyncResult) asyncResult; try { // Perform the operation; if sucessful set the result @@ -394,6 +401,7 @@ namespace OpenSim.Framework.Communications ar.HandleException(e, false); } } + #endregion Async Invocation } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 006c8ee..cdc3baf 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -33,18 +33,15 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; - namespace OpenSim.Framework.UserManagement { public abstract class UserManagerBase : IUserService { public UserConfig _config; - Dictionary _plugins = new Dictionary(); + private Dictionary _plugins = new Dictionary(); /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. @@ -78,11 +75,12 @@ namespace OpenSim.Framework.UserManagement public void AddPlugin(IUserData plug) { plug.Initialise(); - this._plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); + _plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("Userstorage: Added IUserData Interface"); } #region Get UserProfile + /// /// Loads a user profile from a database by UUID /// @@ -100,7 +98,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -126,7 +124,7 @@ namespace OpenSim.Framework.UserManagement catch (Exception e) { System.Console.WriteLine("EEK!"); - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -145,7 +143,7 @@ namespace OpenSim.Framework.UserManagement { try { - UserProfileData profile = plugin.Value.GetUserByName(fname,lname); + UserProfileData profile = plugin.Value.GetUserByName(fname, lname); profile.currentAgent = getUserAgent(profile.UUID); @@ -153,7 +151,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -170,20 +168,24 @@ namespace OpenSim.Framework.UserManagement { foreach (KeyValuePair plugin in _plugins) { - try { + try + { plugin.Value.UpdateUserProfile(data); return true; - } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + } + catch (Exception e) + { + MainLog.Instance.Verbose("Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } - + return false; } #endregion #region Get UserAgent + /// /// Loads a user agent by uuid (not called directly) /// @@ -199,7 +201,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -221,7 +223,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -249,11 +251,11 @@ namespace OpenSim.Framework.UserManagement { try { - return plugin.Value.GetAgentByName(fname,lname); + return plugin.Value.GetAgentByName(fname, lname); } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -263,6 +265,7 @@ namespace OpenSim.Framework.UserManagement #endregion #region CreateAgent + /// /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB /// @@ -270,7 +273,7 @@ namespace OpenSim.Framework.UserManagement /// The users loginrequest public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; UserAgentData agent = new UserAgentData(); @@ -297,7 +300,7 @@ namespace OpenSim.Framework.UserManagement // If user specified additional start, use that if (requestData.ContainsKey("start")) { - string startLoc = ((string)requestData["start"]).Trim(); + string startLoc = ((string) requestData["start"]).Trim(); if (!(startLoc == "last" || startLoc == "home")) { // Format: uri:Ahern&162&213&34 @@ -312,7 +315,6 @@ namespace OpenSim.Framework.UserManagement } catch (Exception) { - } } } @@ -323,7 +325,7 @@ namespace OpenSim.Framework.UserManagement // Current location agent.regionID = new LLUUID(); // Fill in later - agent.currentRegion = new LLUUID(); // Fill in later + agent.currentRegion = new LLUUID(); // Fill in later profile.currentAgent = agent; } @@ -364,7 +366,6 @@ namespace OpenSim.Framework.UserManagement try { plugin.Value.AddNewUserProfile(user); - } catch (Exception e) { @@ -376,4 +377,4 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); } -} +} \ No newline at end of file -- cgit v1.1 From 7f0d836d35e579632413e1b06d5f5e6e6981ca05 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 31 Oct 2007 05:29:51 +0000 Subject: made illogical bitwise operations logical --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index ca2fc35..5457d14 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -681,7 +681,7 @@ namespace OpenSim.Framework.Communications.Cache SendPacket(); counter++; - if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | + if ((request.PacketCounter >= request.NumPackets) || counter > 100 || (request.NumPackets == 1) || (request.DiscardLevel == -1)) { return true; -- cgit v1.1 From f42afe81afc225b26abb1468b70a4f6b17c63472 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 31 Oct 2007 08:07:20 +0000 Subject: added .dat extension to dumped asset files --- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 6b08fc9..9e9ec05 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -289,7 +289,7 @@ namespace OpenSim.Framework.Communications.Cache { DateTime now = DateTime.Now; string filename = - String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, + String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); SaveAssetToFile(filename, Asset.Data); } -- cgit v1.1 From 5fb956f75a5c298a19454986f37418e28591547e Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Wed, 31 Oct 2007 18:49:40 +0000 Subject: Improved logging, to identify which asset fetch caused an execption during retrieval of assets from the asset server --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 74a1ef4..66fa245 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -84,6 +84,7 @@ namespace OpenSim.Framework.Communications.Cache catch (Exception e) { MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", assetID.ToString()); MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } } -- cgit v1.1 From b3aa6e616bbea8ee579070608888f2b43e818626 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 31 Oct 2007 20:39:52 +0000 Subject: * Took a stab at #500 by making sure there is only one place stuff gets added, and that that place is thread-aware. * Refactored it to TryGetValue instead of Contains --- .../Communications/Cache/UserProfileCache.cs | 114 +++++++-------------- 1 file changed, 37 insertions(+), 77 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index fe943b0..ccf5024 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -33,8 +33,8 @@ namespace OpenSim.Framework.Communications.Cache public class UserProfileCache { // Fields - private CommunicationsManager m_parent; - public Dictionary UserProfiles = new Dictionary(); + private readonly CommunicationsManager m_parent; + private readonly Dictionary m_userProfiles = new Dictionary(); public LibraryRootFolder libraryRoot = new LibraryRootFolder(); @@ -52,16 +52,17 @@ namespace OpenSim.Framework.Communications.Cache public void AddNewUser(LLUUID userID) { // Potential fix - Multithreading issue. - lock (UserProfiles) + lock (m_userProfiles) { - if (!UserProfiles.ContainsKey(userID)) + if (!m_userProfiles.ContainsKey(userID)) { CachedUserInfo userInfo = new CachedUserInfo(m_parent); - userInfo.UserProfile = RequestUserProfileForUser(userID); + userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); + if (userInfo.UserProfile != null) { RequestInventoryForUser(userID, userInfo); - UserProfiles.Add(userID, userInfo); + m_userProfiles.Add(userID, userInfo); } else { @@ -71,37 +72,25 @@ namespace OpenSim.Framework.Communications.Cache } } - /// - /// A new user has moved into a region in this instance - /// so get info from servers - /// - /// - /// - public void AddNewUser(string firstName, string lastName) - { - } - public CachedUserInfo GetUserDetails(LLUUID userID) { - if (UserProfiles.ContainsKey(userID)) - { - return UserProfiles[userID]; - } - return null; + return m_userProfiles[userID]; } public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) { - if (UserProfiles.ContainsKey(remoteClient.AgentId)) + CachedUserInfo userProfile; + + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (UserProfiles[remoteClient.AgentId].RootFolder != null) + if (userProfile.RootFolder != null) { - CachedUserInfo info = UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == parentID) + if (userProfile.RootFolder.folderID == parentID) { InventoryFolderImpl createdFolder = - info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + if (createdFolder != null) { m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); @@ -109,7 +98,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = info.RootFolder.HasSubFolder(parentID); + InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID); if (folder != null) { folder.CreateNewSubFolder(folderID, folderName, folderType); @@ -127,27 +116,33 @@ namespace OpenSim.Framework.Communications.Cache { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); + + return; } - else if ((fold = libraryRoot.HasSubFolder(folderID)) != null) + + if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); + + return; } - else if (UserProfiles.ContainsKey(remoteClient.AgentId)) - { - if (UserProfiles[remoteClient.AgentId].RootFolder != null) + + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) { - CachedUserInfo info = UserProfiles[remoteClient.AgentId]; - if (info.RootFolder.folderID == folderID) + if (userProfile.RootFolder.folderID == folderID) { if (fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - info.RootFolder.RequestListOfItems()); + userProfile.RootFolder.RequestListOfItems()); } } else { - InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); + InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(folderID); if ((folder != null) && fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, @@ -163,12 +158,16 @@ namespace OpenSim.Framework.Communications.Cache if (ownerID == libraryRoot.agentID) { //Console.WriteLine("request info for library item"); + + return; } - else if (UserProfiles.ContainsKey(remoteClient.AgentId)) + + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (UserProfiles[remoteClient.AgentId].RootFolder != null) + if (userProfile.RootFolder != null) { - InventoryItemBase item = UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); if (item != null) { remoteClient.SendInventoryItemDetails(ownerID, item); @@ -177,48 +176,9 @@ namespace OpenSim.Framework.Communications.Cache } } - /// - /// Request Iventory Info from Inventory server - /// - /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } - - /// - /// Request the user profile from User server - /// - /// - private UserProfileData RequestUserProfileForUser(LLUUID userID) - { - return m_parent.UserService.GetUserProfile(userID); - } - - /// - /// Update Inventory data to Inventory server - /// - /// - private void UpdateInventoryToServer(LLUUID userID) - { - } - - /// - /// Make sure UserProfile is updated on user server - /// - /// - private void UpdateUserProfileToServer(LLUUID userID) - { - } - - /// - /// A user has left this instance - /// so make sure servers have been updated - /// Then remove cached info - /// - /// - public void UserLogOut(LLUUID userID) - { - } } } \ No newline at end of file -- cgit v1.1 From 88f04731ca42444ae6a3a04d600799b882514d6a Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 1 Nov 2007 15:54:59 +0000 Subject: Test on the grid asset problem, don't update to this version unless you just want to test to see if this fixes anything (but it could just as well break grid assets even more). --- .../Communications/Cache/AssetServerBase.cs | 2 +- .../Communications/Cache/GridAssetClient.cs | 103 +++++++++------------ 2 files changed, 43 insertions(+), 62 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7109910..7c9df88 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications.Cache _assetRequests.Enqueue(req); } - public void UpdateAsset(AssetBase asset) + public virtual void UpdateAsset(AssetBase asset) { lock (syncLock) { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 66fa245..ec163fb 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -35,10 +35,9 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { - public class GridAssetClient : IAssetServer + public class GridAssetClient : AssetServerBase { private string _assetServerUrl; - private IAssetReceiver _receiver; public GridAssetClient(string serverUrl) { @@ -47,54 +46,60 @@ namespace OpenSim.Framework.Communications.Cache #region IAssetServer Members - public void SetReceiver(IAssetReceiver receiver) + protected override void RunRequests() { - _receiver = receiver; - } - - public void FetchAsset(LLUUID assetID, bool isTexture) - { - Stream s = null; - try + while (true) { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); + ARequest req = _assetRequests.Dequeue(); - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(assetID.ToString()); - if (isTexture) - rc.AddQueryParameter("texture"); + //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); - rc.RequestMethod = "GET"; - s = rc.Request(); - if (s.Length > 0) + Stream s = null; + try { - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); - AssetBase asset = (AssetBase) xs.Deserialize(s); - - _receiver.AssetReceived(asset, isTexture); + MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + s = rc.Request(); + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + AssetBase newAsset = (AssetBase)xs.Deserialize(s); + + _receiver.AssetReceived(newAsset, req.IsTexture); + } + else + { + MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString()); + _receiver.AssetNotFound(req.AssetID); + } } - else + catch (Exception e) { - MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString()); - _receiver.AssetNotFound(assetID); + MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); + MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } - } - catch (Exception e) - { - MainLog.Instance.Error("ASSETCACHE", e.Message); - MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", assetID.ToString()); - MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + } } - public void UpdateAsset(AssetBase asset) + + + public override void UpdateAsset(AssetBase asset) { throw new Exception("The method or operation is not implemented."); } - public void StoreAndCommitAsset(AssetBase asset) + protected override void StoreAsset(AssetBase asset) { try { @@ -113,40 +118,16 @@ namespace OpenSim.Framework.Communications.Cache } } - public void Close() - { - throw new Exception("The method or operation is not implemented."); - } - - public void LoadAsset(AssetBase info, bool image, string filename) + protected override void CommitAssets() { - throw new Exception("The method or operation is not implemented."); } - public List GetDefaultAssets() + public override void Close() { throw new Exception("The method or operation is not implemented."); } - public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachDefaultAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } - - public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) - { - throw new Exception("The method or operation is not implemented."); - } - - public void ForEachXmlAsset(Action action) - { - throw new Exception("The method or operation is not implemented."); - } + #endregion } -- cgit v1.1 From 7a66eff8af0d9d56ffb3b2c1f4f5088f98c99d64 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 1 Nov 2007 17:28:38 +0000 Subject: renamed FetchAsset to RequestAsset on IAssetServer, as think its a more fitting name. As the call shouldn't actually return the data, but just add a request for the data to be sent back via the callback. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 8 ++++---- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 5457d14..6222649 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Add(assetID, reqList); } } - _assetServer.FetchAsset(assetID, false); + _assetServer.RequestAsset(assetID, false); } } @@ -171,7 +171,7 @@ namespace OpenSim.Framework.Communications.Cache AssetBase asset = GetAsset(assetID); if (asset == null) { - _assetServer.FetchAsset(assetID, isTexture); + _assetServer.RequestAsset(assetID, isTexture); } return asset; } @@ -409,7 +409,7 @@ namespace OpenSim.Framework.Communications.Cache request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; RequestedAssets.Add(requestID, request); - _assetServer.FetchAsset(requestID, false); + _assetServer.RequestAsset(requestID, false); } return; } @@ -576,7 +576,7 @@ namespace OpenSim.Framework.Communications.Cache request.IsTextureRequest = true; request.DiscardLevel = discard; RequestedTextures.Add(imageID, request); - _assetServer.FetchAsset(imageID, true); + _assetServer.RequestAsset(imageID, true); } return; } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7c9df88..128e2e6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Cache _receiver = receiver; } - public void FetchAsset(LLUUID assetID, bool isTexture) + public void RequestAsset(LLUUID assetID, bool isTexture) { ARequest req = new ARequest(); req.AssetID = assetID; -- cgit v1.1 From 4fad66f855544b9298ae2216c58c0f44009358a5 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 1 Nov 2007 19:19:05 +0000 Subject: * Diuerse beavtificatems --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/UserProfileCache.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 6222649..6be0852 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -52,10 +52,10 @@ namespace OpenSim.Framework.Communications.Cache public List TextureRequests = new List(); //textures ready to be sent public Dictionary RequestedAssets = new Dictionary(); - //Assets requested from the asset server + //Assets requested from the asset server public Dictionary RequestedTextures = new Dictionary(); - //Textures requested from the asset server + //Textures requested from the asset server public Dictionary SendingTextures = new Dictionary(); private BlockingQueue QueueTextures = new BlockingQueue(); diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index ccf5024..74b2440 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl createdFolder = userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - + if (createdFolder != null) { m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); @@ -119,7 +119,7 @@ namespace OpenSim.Framework.Communications.Cache return; } - + if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); @@ -129,7 +129,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { + { if (userProfile.RootFolder != null) { if (userProfile.RootFolder.folderID == folderID) -- cgit v1.1 From 21e47f8ef04bd345eb3c8e0823392a2dbc269e4e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 Nov 2007 22:01:26 +0000 Subject: debug tracing for asset server hangs --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 +++- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 4 +++- OpenSim/Framework/Communications/RestClient/RestClient.cs | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 128e2e6..4ff1024 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -71,7 +71,9 @@ namespace OpenSim.Framework.Communications.Cache ARequest req = new ARequest(); req.AssetID = assetID; req.IsTexture = isTexture; + MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID); _assetRequests.Enqueue(req); + MainLog.Instance.Verbose("ASSET","Added {0} to request queue", assetID); } public virtual void UpdateAsset(AssetBase asset) @@ -185,4 +187,4 @@ namespace OpenSim.Framework.Communications.Cache assets.ForEach(action); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index ec163fb..64e561b 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -108,9 +108,11 @@ namespace OpenSim.Framework.Communications.Cache XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); xs.Serialize(s, asset); RestClient rc = new RestClient(_assetServerUrl); + MainLog.Instance.Verbose("ASSET", "Storing {0}", rc); rc.AddResourcePath("assets"); rc.RequestMethod = "POST"; rc.Request(s); + MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); } catch (Exception e) { @@ -131,4 +133,4 @@ namespace OpenSim.Framework.Communications.Cache #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index ac3a287..acb3fd4 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -5,6 +5,7 @@ using System.Net; using System.Text; using System.Threading; using System.Web; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications { @@ -209,6 +210,7 @@ namespace OpenSim.Framework.Communications } } realuri = sb.ToString(); + MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); return new Uri(sb.ToString()); } @@ -335,7 +337,7 @@ namespace OpenSim.Framework.Communications } public Stream Request(Stream src) - { + { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; @@ -344,10 +346,16 @@ namespace OpenSim.Framework.Communications _asyncException = null; _request.ContentLength = src.Length; + MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); + MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); + MainLog.Instance.Verbose("REST", "Seek is ok"); Stream dst = _request.GetRequestStream(); + MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); + byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); + MainLog.Instance.Verbose("REST", "First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); @@ -404,4 +412,4 @@ namespace OpenSim.Framework.Communications #endregion Async Invocation } -} \ No newline at end of file +} -- cgit v1.1 From 91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 3 Nov 2007 14:04:59 +0000 Subject: testing different rest post method/class for Grid asset client. (possible that I haven't set the post url correctly) --- .../Communications/Cache/GridAssetClient.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 64e561b..632f96c 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -32,6 +32,7 @@ using System.IO; using System.Xml.Serialization; using libsecondlife; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications.Cache { @@ -103,16 +104,17 @@ namespace OpenSim.Framework.Communications.Cache { try { - MemoryStream s = new MemoryStream(); - - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); - xs.Serialize(s, asset); - RestClient rc = new RestClient(_assetServerUrl); - MainLog.Instance.Verbose("ASSET", "Storing {0}", rc); - rc.AddResourcePath("assets"); - rc.RequestMethod = "POST"; - rc.Request(s); - MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); + // MemoryStream s = new MemoryStream(); + + // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + // xs.Serialize(s, asset); + // RestClient rc = new RestClient(_assetServerUrl); + MainLog.Instance.Verbose("ASSET", "Storing asset"); + //rc.AddResourcePath("assets"); + // rc.RequestMethod = "POST"; + // rc.Request(s); + //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); + RestObjectPoster.BeginPostObject(_assetRequests + "/assets/", asset); } catch (Exception e) { -- cgit v1.1 From b51a900bebe914650c1c7db7b77f74c5ac107f6d Mon Sep 17 00:00:00 2001 From: mingchen Date: Sat, 3 Nov 2007 17:49:45 +0000 Subject: *Master Avatar can be specified by a previous UUID in either grid mode or standalone mode by specifying a master_avatar_uuid attribute in the place of master_avatar_xxxx_name and master_avatar_password.You will not be asked for the name and password if a valid UUID is specified. --- OpenSim/Framework/Communications/UserManagerBase.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index cdc3baf..408f37c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -376,5 +376,6 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); + public abstract UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid); } } \ No newline at end of file -- cgit v1.1 From 19fe9a02081f3c43ff17b39e5843b13055a7c4c6 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 4 Nov 2007 10:40:28 +0000 Subject: Do I really have to write a log entry, can't I just hide this commit somewhere so its added but doesn't show up anywhere. As I can't believe I would make such a stupid mistake and not notice. --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 632f96c..580e528 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -114,7 +114,8 @@ namespace OpenSim.Framework.Communications.Cache // rc.RequestMethod = "POST"; // rc.Request(s); //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); - RestObjectPoster.BeginPostObject(_assetRequests + "/assets/", asset); + MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); + RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); } catch (Exception e) { -- cgit v1.1 From d56ed8fe9c6428a4ac3288190be303b5813b0b91 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 4 Nov 2007 22:22:53 +0000 Subject: Some more refactoring --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index d4fb54b..e5ed136 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -34,5 +34,6 @@ namespace OpenSim.Framework.Communications bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); + void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); } } \ No newline at end of file -- cgit v1.1 From ee1fcc729c9fe4df367a12ffe4a0d90c7378c160 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 6 Nov 2007 11:10:45 +0000 Subject: * Added better logging to AssetCache * AssetCache now ignores duplicate uploads * some m_ refactoring * ignored some bins --- .../Framework/Communications/Cache/AssetCache.cs | 108 +++++++++++++-------- .../Communications/Cache/AssetServerBase.cs | 20 +--- .../Framework/Communications/Capabilities/Caps.cs | 67 ++++++------- 3 files changed, 101 insertions(+), 94 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 6be0852..8adf76c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -58,37 +58,40 @@ namespace OpenSim.Framework.Communications.Cache //Textures requested from the asset server public Dictionary SendingTextures = new Dictionary(); - private BlockingQueue QueueTextures = new BlockingQueue(); - private Dictionary> AvatarRecievedTextures = new Dictionary>(); + public Dictionary RequestLists = new Dictionary(); + + private BlockingQueue m_queueTextures = new BlockingQueue(); + private Dictionary> m_avatarReceivedTextures = new Dictionary>(); - private Dictionary> TimesTextureSent = + private Dictionary> m_timesTextureSent = new Dictionary>(); - public Dictionary RequestLists = new Dictionary(); - private IAssetServer _assetServer; - private Thread _assetCacheThread; + private IAssetServer m_assetServer; - private Thread TextureSenderThread; + private Thread m_assetCacheThread; + private Thread m_textureSenderThread; + private LogBase m_log; /// /// /// - public AssetCache(IAssetServer assetServer) + public AssetCache(IAssetServer assetServer, LogBase log) { - MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); - _assetServer = assetServer; - _assetServer.SetReceiver(this); + log.Verbose("ASSETSTORAGE", "Creating Asset cache"); + m_assetServer = assetServer; + m_assetServer.SetReceiver(this); Assets = new Dictionary(); Textures = new Dictionary(); - _assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - _assetCacheThread.IsBackground = true; - _assetCacheThread.Start(); - - TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); - TextureSenderThread.IsBackground = true; - TextureSenderThread.Start(); + m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + m_assetCacheThread.IsBackground = true; + m_assetCacheThread.Start(); + + m_textureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); + m_textureSenderThread.IsBackground = true; + m_textureSenderThread.Start(); + m_log = log; } /// @@ -161,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Add(assetID, reqList); } } - _assetServer.RequestAsset(assetID, false); + m_assetServer.RequestAsset(assetID, false); } } @@ -171,46 +174,67 @@ namespace OpenSim.Framework.Communications.Cache AssetBase asset = GetAsset(assetID); if (asset == null) { - _assetServer.RequestAsset(assetID, isTexture); + m_assetServer.RequestAsset(assetID, isTexture); } return asset; } public void AddAsset(AssetBase asset) { - //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + string temporary = asset.Temporary ? "temporary" : ""; + string type = asset.Type == 0 ? "texture" : "asset"; + + string result = "Ignored"; + if (asset.Type == 0) { - //Console.WriteLine("which is a texture"); - if (!Textures.ContainsKey(asset.FullID)) + if(Textures.ContainsKey(asset.FullID)) { - //texture - TextureImage textur = new TextureImage(asset); - Textures.Add(textur.FullID, textur); - if (!asset.Temporary) - _assetServer.StoreAndCommitAsset(asset); + result = "Duplicate ignored."; } else { TextureImage textur = new TextureImage(asset); - Textures[asset.FullID] = textur; + Textures.Add(textur.FullID, textur); + if (asset.Temporary) + { + result = "Added to cache"; + } + else + { + m_assetServer.StoreAndCommitAsset(asset); + result = "Added to server"; + } } } else { - if (!Assets.ContainsKey(asset.FullID)) + if (Assets.ContainsKey(asset.FullID)) + { + result = "Duplicate ignored."; + } + else { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); - if (!asset.Temporary) - _assetServer.StoreAndCommitAsset(asset); + if (asset.Temporary) + { + result = "Added to cache"; + } + else + { + m_assetServer.StoreAndCommitAsset(asset); + result = "Added to server"; + } } } + + m_log.Verbose("ASSETCACHE", "Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); } public void DeleteAsset(LLUUID assetID) { - // this._assetServer.DeleteAsset(assetID); + // this.m_assetServer.DeleteAsset(assetID); //Todo should delete it from memory too } @@ -238,7 +262,7 @@ namespace OpenSim.Framework.Communications.Cache TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; SendingTextures.Add(req.ImageInfo.FullID, sender); - QueueTextures.Enqueue(sender); + m_queueTextures.Enqueue(sender); } } @@ -249,7 +273,7 @@ namespace OpenSim.Framework.Communications.Cache { while (true) { - TextureSender sender = QueueTextures.Dequeue(); + TextureSender sender = m_queueTextures.Dequeue(); bool finished = sender.SendTexture(); if (finished) @@ -259,7 +283,7 @@ namespace OpenSim.Framework.Communications.Cache else { // Console.WriteLine("readding texture"); - QueueTextures.Enqueue(sender); + m_queueTextures.Enqueue(sender); } } } @@ -273,7 +297,7 @@ namespace OpenSim.Framework.Communications.Cache if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); + // this.m_avatarReceivedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } @@ -409,7 +433,7 @@ namespace OpenSim.Framework.Communications.Cache request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; RequestedAssets.Add(requestID, request); - _assetServer.RequestAsset(requestID, false); + m_assetServer.RequestAsset(requestID, false); } return; } @@ -555,11 +579,11 @@ namespace OpenSim.Framework.Communications.Cache { // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server - if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + if (!m_avatarReceivedTextures.ContainsKey(userInfo.AgentId)) { - AvatarRecievedTextures.Add(userInfo.AgentId, new List()); + m_avatarReceivedTextures.Add(userInfo.AgentId, new List()); } - /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) + /* if(this.m_avatarReceivedTextures[userInfo.AgentId].Contains(imageID)) { //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; @@ -576,7 +600,7 @@ namespace OpenSim.Framework.Communications.Cache request.IsTextureRequest = true; request.DiscardLevel = discard; RequestedTextures.Add(imageID, request); - _assetServer.RequestAsset(imageID, true); + m_assetServer.RequestAsset(imageID, true); } return; } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 4ff1024..7692057 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -23,7 +23,7 @@ namespace OpenSim.Framework.Communications.Cache public void LoadDefaultAssets() { - MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); + MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); ForEachDefaultAsset(StoreAsset); ForEachXmlAsset(StoreAsset); @@ -106,24 +106,6 @@ namespace OpenSim.Framework.Communications.Cache public virtual List GetDefaultAssets() { List assets = new List(); - // These assets have been moved into the OpenSimAssetSet.XML file - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2")); - - //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); - //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); - //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); - //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); - return assets; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 23dfcc6..51a4598 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -58,24 +58,25 @@ namespace OpenSim.Region.Capabilities //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 NewInventoryItem AddNewInventoryItem = null; - public ItemUpdatedCallback ItemUpdatedCall = null; + private BaseHttpServer m_httpListener; + private LLUUID m_agentID; + private AssetCache m_assetCache; + private int m_eventQueueCount = 1; + private Queue m_capsEventQueue = new Queue(); private bool m_dumpAssetsToFile; - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, + public NewInventoryItem AddNewInventoryItem = null; + public ItemUpdatedCallback ItemUpdatedCall = null; + + public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { - assetCache = assetCach; + m_assetCache = assetCache; m_capsObjectPath = capsPath; - httpListener = httpServer; + m_httpListener = httpServer; m_httpListenerHostName = httpListen; m_httpListenPort = httpPort; - agentID = agent; + m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -88,17 +89,17 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; try { - httpListener.AddStreamHandler( + m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); - httpListener.AddStreamHandler( + m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, NewAgentInventoryRequest)); - AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); - //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); - AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); + AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); + //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); + AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); } catch { @@ -198,11 +199,11 @@ namespace OpenSim.Region.Capabilities { string res = ""; - if (CapsEventQueue.Count > 0) + if (m_capsEventQueue.Count > 0) { - lock (CapsEventQueue) + lock (m_capsEventQueue) { - string item = CapsEventQueue.Dequeue(); + string item = m_capsEventQueue.Dequeue(); res = item; } } @@ -222,13 +223,13 @@ namespace OpenSim.Region.Capabilities public string CreateEstablishAgentComms(string caps, string ipAddressPort) { LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = eventQueueCount; + eventItem.id = m_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++; + m_eventQueueCount++; - CapsEventQueue.Enqueue(res); + m_capsEventQueue.Enqueue(res); return res; } @@ -239,10 +240,10 @@ namespace OpenSim.Region.Capabilities public string CreateEmptyEventResponse() { LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = eventQueueCount; + eventItem.id = m_eventQueueCount; eventItem.events.Array.Add(new LLSDEmpty()); string res = LLSDHelpers.SerialiseLLSDReply(eventItem); - eventQueueCount++; + m_eventQueueCount++; return res; } @@ -266,10 +267,10 @@ namespace OpenSim.Region.Capabilities string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); ItemUpdater uploader = - new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); + new ItemUpdater(newInvItem, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); uploader.OnUpLoad += ItemUpdated; - httpListener.AddStreamHandler( + m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -300,8 +301,8 @@ namespace OpenSim.Region.Capabilities AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); - httpListener.AddStreamHandler( + llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); + m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -344,11 +345,11 @@ namespace OpenSim.Region.Capabilities asset.InvType = inType; asset.Name = assetName; asset.Data = data; - assetCache.AddAsset(asset); + m_assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); - item.avatarID = agentID; - item.creatorsID = agentID; + item.avatarID = m_agentID; + item.creatorsID = m_agentID; item.inventoryID = inventoryItem; item.assetID = asset.FullID; item.inventoryDescription = assetDescription; @@ -361,7 +362,7 @@ namespace OpenSim.Region.Capabilities if (AddNewInventoryItem != null) { - AddNewInventoryItem(agentID, item); + AddNewInventoryItem(m_agentID, item); } } @@ -369,7 +370,7 @@ namespace OpenSim.Region.Capabilities { if (ItemUpdatedCall != null) { - return ItemUpdatedCall(agentID, itemID, data); + return ItemUpdatedCall(m_agentID, itemID, data); } return LLUUID.Zero; } -- cgit v1.1 From c93f7188c758571283c017aa3d33a6ba55cf2cd5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 9 Nov 2007 01:59:18 +0000 Subject: * Added a mutex to the LoginService allowing only a single login simultaneously. (queues) * This is a temporary fix to prevent an issue with adjohn reported when attempting to login large numbers of users in a short period of time. * A rewritten login service is on the cards. --- OpenSim/Framework/Communications/LoginService.cs | 175 ++++++++++++----------- 1 file changed, 93 insertions(+), 82 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 497cc5d..e24d858 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -28,6 +28,7 @@ using System; using System.Collections; +using System.Threading; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; @@ -38,6 +39,7 @@ namespace OpenSim.Framework.UserManagement { protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; + protected Mutex m_loginMutex = new Mutex(false); public LoginService(UserManagerBase userManager, string welcomeMess) { @@ -55,104 +57,113 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable) request.Params[0]; - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && - requestData.Contains("passwd")); - bool GoodLogin = false; + // Temporary fix + m_loginMutex.WaitOne(); + try + { + MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && + requestData.Contains("passwd")); + bool GoodLogin = false; - if (GoodXML) - { - string firstname = (string) requestData["first"]; - string lastname = (string) requestData["last"]; - string passwd = (string) requestData["passwd"]; + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - return logResponse.CreateLoginFailedResponse(); + if (GoodXML) + { + string firstname = (string)requestData["first"]; + string lastname = (string)requestData["last"]; + string passwd = (string)requestData["passwd"]; - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else - { - return logResponse.CreateGridErrorResponse(); - } + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + return logResponse.CreateLoginFailedResponse(); - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponse(); - } - else - { - // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else { - // Reject the login - return logResponse.CreateAlreadyLoggedInResponse(); + return logResponse.CreateGridErrorResponse(); } - // Otherwise... - // Create a new agent session - CreateAgent(userProfile, request); - try + if (!GoodLogin) { - LLUUID agentID = userProfile.UUID; - - // Inventory Library Section - InventoryData inventData = CreateInventoryData(agentID); - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; - - // Circuit Code - uint circode = (uint) (Util.RandomClass.Next()); - - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.CircuitCode = (Int32) circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten - logResponse.Message = GetMessage(); + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); try { - CustomiseResponse(logResponse, userProfile); + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = GetMessage(); + + try + { + CustomiseResponse(logResponse, userProfile); + } + catch (Exception e) + { + MainLog.Instance.Verbose(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); + } + CommitAgent(ref userProfile); + return logResponse.ToXmlRpcResponse(); } - catch (Exception e) + + catch (Exception E) { - MainLog.Instance.Verbose(e.ToString()); - return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); + MainLog.Instance.Verbose(E.ToString()); } - CommitAgent(ref userProfile); - return logResponse.ToXmlRpcResponse(); + //} } - - catch (Exception E) - { - MainLog.Instance.Verbose(E.ToString()); - } - //} + } + finally + { + m_loginMutex.ReleaseMutex(); } return response; } -- cgit v1.1 From 3a5ae43d5ed7e3379452099e0ddeefe002358e19 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 9 Nov 2007 02:13:07 +0000 Subject: * Fixed compile issue. --- OpenSim/Framework/Communications/LoginService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e24d858..450bada 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -160,12 +160,13 @@ namespace OpenSim.Framework.UserManagement } //} } + return response; } finally { m_loginMutex.ReleaseMutex(); } - return response; + return null; } /// -- cgit v1.1 From 46fbcad2aac3720b826d56b6cc5b483b98a07cf3 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sun, 11 Nov 2007 00:11:34 +0000 Subject: Fixed bug in assetcache where certain textures were not being packetized correctly --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 8adf76c..0ea33ff 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -325,7 +325,7 @@ namespace OpenSim.Framework.Communications.Cache if (image.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int) (image.Data.Length - 600)/1000; + req.NumPackets = 2 + (int) (image.Data.Length - 601)/1000; } else { -- cgit v1.1 From 7f8a69f181aba493416c8b5c6e8aa4be8fde7a34 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 13 Nov 2007 10:47:39 +0000 Subject: Some work on being able to set/send a users Buddylist info. (added handling code to LoginResponse). And as a test each user signing in will get the test account ("Mr OpenSim") as a friend (online/offline status will not currently show up) --- OpenSim/Framework/Communications/LoginResponse.cs | 64 ++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 4d1c35a..a8c3f23 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -28,6 +28,7 @@ using System; using System.Collections; +using System.Collections.Generic; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; @@ -99,6 +100,8 @@ namespace OpenSim.Framework.UserManagement private string seedCapability; private string lookAt; + private BuddyList m_buddyList = null; + public LoginResponse() { loginFlags = new ArrayList(); @@ -291,7 +294,11 @@ namespace OpenSim.Framework.UserManagement responseData["region_y"] = (Int32) RegionY*256; //responseData["inventory-lib-root"] = new ArrayList(); // todo - //responseData["buddy-list"] = new ArrayList(); // todo + + if (m_buddyList != null) + { + responseData["buddy-list"] = m_buddyList.ToArray(); + } responseData["login"] = "true"; xmlRpcResponse.Value = responseData; @@ -510,6 +517,12 @@ namespace OpenSim.Framework.UserManagement set { welcomeMessage = value; } } + public BuddyList BuddList + { + get{return m_buddyList;} + set { m_buddyList = value; } + } + #endregion public class UserInfo @@ -520,5 +533,54 @@ namespace OpenSim.Framework.UserManagement public LLVector3 homepos; public LLVector3 homelookat; } + + public class BuddyList + { + public List Buddies = new List(); + + public void AddNewBuddy(BuddyInfo buddy) + { + if (!Buddies.Contains(buddy)) + { + Buddies.Add(buddy); + } + } + + public ArrayList ToArray() + { + ArrayList buddyArray = new ArrayList(); + foreach (BuddyInfo buddy in Buddies) + { + buddyArray.Add(buddy.ToHashTable()); + } + return buddyArray; + } + + public class BuddyInfo + { + public int BuddyRightsHave = 1; + public int BuddyRightsGiven = 1; + public LLUUID BuddyID; + + public BuddyInfo(string buddyID) + { + BuddyID = new LLUUID(buddyID); + } + + public BuddyInfo(LLUUID buddyID) + { + BuddyID = buddyID; + } + + public Hashtable ToHashTable() + { + Hashtable hTable = new Hashtable(); + hTable["buddy_rights_has"] = BuddyRightsHave; + hTable["buddy_rights_given"] = BuddyRightsGiven; + hTable["buddy_id"] = BuddyID.ToStringHyphenated(); + return hTable; + } + } + } } } \ No newline at end of file -- cgit v1.1 From 9f6b3e2357e76b9b85b447da189b4bf4163edd3c Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 13 Nov 2007 22:48:19 +0000 Subject: * Added AvatarPicker in Standalone mode. Works for finding avatar to ban, manually trying to add a friend (with the add button) or useful to those who are curious which usernames have visited your standalone sim. Important for future development :D. * Grid mode always returns 0 results until the Grid Communications portion is done. --- .../Framework/Communications/CommunicationsManager.cs | 10 ++++++++++ OpenSim/Framework/Communications/IGridServices.cs | 1 + OpenSim/Framework/Communications/UserManagerBase.cs | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 77c7261..7b1a97e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,6 +28,7 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; +using System.Collections.Generic; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; @@ -173,6 +174,15 @@ namespace OpenSim.Framework.Communications } } } + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + { + + + List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); + + + return pickerlist; + } #endregion } diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index ce6205f..3d0af09 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -36,5 +36,6 @@ namespace OpenSim.Framework.Communications List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 408f37c..3a32ba9 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -105,6 +105,25 @@ namespace OpenSim.Framework.UserManagement return null; } + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + { + List pickerlist = new List(); + foreach (KeyValuePair plugin in _plugins) + { + try + { + pickerlist = plugin.Value.GeneratePickerResults(queryID, query); + + } + catch (Exception e) + { + MainLog.Instance.Verbose("Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + return new List(); + } + } + return pickerlist; + } + /// /// Loads a user profile by name -- cgit v1.1 From 666bd6f06e5eaff3acfb969d2851b7d98b18c495 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Wed, 14 Nov 2007 06:00:03 +0000 Subject: Another try: Fix moon bleeding over into linden grid. Need to clear your cache to fix it. --- OpenSim/Framework/Communications/LoginResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index a8c3f23..98a6cfc 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -141,8 +141,8 @@ namespace OpenSim.Framework.UserManagement allowFirstLife = "Y"; SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; + MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; ErrorReason = "key"; -- cgit v1.1 From 483377adaedefb12f19b3f843dbabfd7b545bf90 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 16 Nov 2007 13:39:11 +0000 Subject: More cleaning up when deleting regions from a instance. NOTE: IGridServices.DeregisterRegion() method needs implementing for grid mode. --- OpenSim/Framework/Communications/IGridServices.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 3d0af09..c1fb9c4 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -33,6 +33,7 @@ namespace OpenSim.Framework.Communications public interface IGridServices { RegionCommsListener RegisterRegion(RegionInfo regionInfos); + bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); -- cgit v1.1 From 946db5461c8262d3b957e42ed7a90feb447c618b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 17 Nov 2007 05:53:12 +0000 Subject: catch exceptions when loading malformed xml files --- .../Communications/Cache/AssetServerBase.cs | 38 +++++++++++++--------- .../Communications/Cache/LibraryRootFolder.cs | 13 ++++++-- 2 files changed, 34 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7692057..1a20cee 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Threading; +using System.Xml; using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; @@ -148,22 +149,29 @@ namespace OpenSim.Framework.Communications.Cache string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); if (File.Exists(filePath)) { - XmlConfigSource source = new XmlConfigSource(filePath); - - for (int i = 0; i < source.Configs.Count; i++) + try + { + XmlConfigSource source = new XmlConfigSource(filePath); + + for (int i = 0; i < source.Configs.Count; i++) + { + // System.Console.WriteLine("loading asset into database"); + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string name = source.Configs[i].GetString("name", ""); + sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + + AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); + + newAsset.Type = type; + newAsset.InvType = invType; + assets.Add(newAsset); + } + } + catch (XmlException e) { - // System.Console.WriteLine("loading asset into database"); - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); - string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - - AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); - - newAsset.Type = type; - newAsset.InvType = invType; - assets.Add(newAsset); + MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString()); } } assets.ForEach(action); diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 765c42e..05caa84 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -27,8 +27,10 @@ */ using System.IO; +using System.Xml; using libsecondlife; using Nini.Config; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { @@ -65,8 +67,15 @@ namespace OpenSim.Framework.Communications.Cache string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); if (File.Exists(filePath)) { - XmlConfigSource source = new XmlConfigSource(filePath); - ReadItemsFromFile(source); + try + { + XmlConfigSource source = new XmlConfigSource(filePath); + ReadItemsFromFile(source); + } + catch (XmlException e) + { + MainLog.Instance.Error("INVENTORY", "Error loading " + filePath + ": " + e.ToString()); + } } } -- cgit v1.1 From d10c79d4216436fd2a5056dbf853f317967202af Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 18 Nov 2007 13:50:46 +0000 Subject: first stab at implementation of CopyInventoryItem --- .../Framework/Communications/Cache/AssetCache.cs | 11 ++++++++ .../Communications/Cache/LibraryRootFolder.cs | 31 +++++++++++++--------- .../Communications/Cache/UserProfileCache.cs | 5 +++- 3 files changed, 33 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0ea33ff..99041c1 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -239,6 +239,17 @@ namespace OpenSim.Framework.Communications.Cache //Todo should delete it from memory too } + public AssetBase CopyAsset(LLUUID assetID) + { + AssetBase asset = GetAsset(assetID); + if (asset == null) + return null; + + asset.FullID = LLUUID.Random(); // TODO: check for conflicts + AddAsset(asset); + return asset; + } + /// /// /// diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 05caa84..62251bc 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -88,7 +88,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); item.inventoryDescription = "Plywood texture"; item.inventoryName = "Plywood"; - item.assetType = 0; + item.assetType = (int) AssetType.Texture; + item.invType = (int) InventoryType.Texture; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -103,7 +104,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003"); item.inventoryDescription = "Rocks texture"; item.inventoryName = "Rocks"; - item.assetType = 0; + item.assetType = (int) AssetType.Texture; + item.invType = (int) InventoryType.Texture; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -118,7 +120,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001"); item.inventoryDescription = "Bricks texture"; item.inventoryName = "Bricks"; - item.assetType = 0; + item.assetType = (int) AssetType.Texture; + item.invType = (int) InventoryType.Texture; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -133,7 +136,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004"); item.inventoryDescription = "Granite texture"; item.inventoryName = "Granite"; - item.assetType = 0; + item.assetType = (int) AssetType.Texture; + item.invType = (int) InventoryType.Texture; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -148,7 +152,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005"); item.inventoryDescription = "Hardwood texture"; item.inventoryName = "Hardwood"; - item.assetType = 0; + item.assetType = (int) AssetType.Texture; + item.invType = (int) InventoryType.Texture; item.parentFolderID = m_textureFolder.folderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; @@ -163,8 +168,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); item.inventoryDescription = "Default Shape"; item.inventoryName = "Default Shape"; - item.assetType = 13; - item.invType = 18; + item.assetType = (int) AssetType.Bodypart; + item.invType = (int) InventoryType.Wearable; item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; @@ -177,8 +182,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); item.inventoryDescription = "Default Skin"; item.inventoryName = "Default Skin"; - item.assetType = 13; - item.invType = 18; + item.assetType = (int) AssetType.Bodypart; + item.invType = (int) InventoryType.Wearable; item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; @@ -191,8 +196,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110"); item.inventoryDescription = "Default Shirt"; item.inventoryName = "Default Shirt"; - item.assetType = 5; - item.invType = 18; + item.assetType = (int) AssetType.Clothing; + item.invType = (int) InventoryType.Wearable; item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; @@ -205,8 +210,8 @@ namespace OpenSim.Framework.Communications.Cache item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120"); item.inventoryDescription = "Default Pants"; item.inventoryName = "Default Pants"; - item.assetType = 5; - item.invType = 18; + item.assetType = (int) AssetType.Clothing; + item.invType = (int) InventoryType.Wearable; item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 74b2440..117ed36 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -74,7 +74,10 @@ namespace OpenSim.Framework.Communications.Cache public CachedUserInfo GetUserDetails(LLUUID userID) { - return m_userProfiles[userID]; + if (m_userProfiles.ContainsKey(userID)) + return m_userProfiles[userID]; + else + return null; } public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, -- cgit v1.1 From 924026d01c1dd25218e9a4296eb27640091405f3 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 18 Nov 2007 15:14:37 +0000 Subject: cleaned up some mono compiler warnings --- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 3a32ba9..cf82103 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -115,7 +115,7 @@ namespace OpenSim.Framework.UserManagement pickerlist = plugin.Value.GeneratePickerResults(queryID, query); } - catch (Exception e) + catch (Exception) { MainLog.Instance.Verbose("Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); return new List(); @@ -326,7 +326,7 @@ namespace OpenSim.Framework.UserManagement try { string[] parts = startLoc.Remove(0, 4).Split('&'); - string region = parts[0]; + //string region = parts[0]; //////////////////////////////////////////////////// //SimProfile SimInfo = new SimProfile(); -- cgit v1.1 From 615b40b68b2311433b855f8c1e961a8b71eb9b65 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 18 Nov 2007 15:54:05 +0000 Subject: * Refactored IClientAPI.OutPacket to require a second mandatory parameter. This parameter has an enum:int ThrottleOutPacketType and contains types; Resend, Land, Wind, Cloud, Task, Texture, and Asset. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 16 ++++++++-------- .../Framework/Communications/Cache/AssetTransactions.cs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 99041c1..edca142 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -520,7 +520,7 @@ namespace OpenSim.Framework.Communications.Cache } Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; - req.RequestUser.OutPacket(Transfer); + req.RequestUser.OutPacket(Transfer,ThrottleOutPacketType.Asset); if (req.NumPackets == 1) { @@ -530,7 +530,7 @@ namespace OpenSim.Framework.Communications.Cache TransferPacket.TransferData.TransferID = req.TransferRequestID; TransferPacket.TransferData.Data = req.AssetInf.Data; TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); } else { @@ -546,7 +546,7 @@ namespace OpenSim.Framework.Communications.Cache Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length); TransferPacket.TransferData.Data = chunk; TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); } else { @@ -555,7 +555,7 @@ namespace OpenSim.Framework.Communications.Cache TransferPacket.TransferData.Data = chunk; TransferPacket.TransferData.Status = 0; - req.RequestUser.OutPacket(TransferPacket); + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); TransferPacket = new TransferPacketPacket(); TransferPacket.TransferData.Packet = 1; @@ -565,7 +565,7 @@ namespace OpenSim.Framework.Communications.Cache Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); TransferPacket.TransferData.Data = chunk1; TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); } } } @@ -741,7 +741,7 @@ namespace OpenSim.Framework.Communications.Cache im.ImageID.Size = (uint) req.ImageInfo.Data.Length; im.ImageData.Data = req.ImageInfo.Data; im.ImageID.Codec = 2; - req.RequestUser.OutPacket(im); + req.RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); req.PacketCounter++; //req.ImageInfo.l= time; //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); @@ -758,7 +758,7 @@ namespace OpenSim.Framework.Communications.Cache 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.RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); req.PacketCounter++; //req.ImageInfo.last_used = time; @@ -780,7 +780,7 @@ namespace OpenSim.Framework.Communications.Cache //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); 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.RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 9e9ec05..acd57b6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -221,7 +221,7 @@ namespace OpenSim.Framework.Communications.Cache ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); newPack.XferID.ID = xferID; newPack.XferID.Packet = packetID; - ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); if ((packetID & 0x80000000) != 0) { SendCompleteMessage(); @@ -262,7 +262,7 @@ namespace OpenSim.Framework.Communications.Cache newPack.XferID.VFileID = Asset.FullID; newPack.XferID.FilePath = 0; newPack.XferID.Filename = new byte[0]; - ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); } protected void SendCompleteMessage() @@ -272,7 +272,7 @@ namespace OpenSim.Framework.Communications.Cache newPack.AssetBlock.Type = Asset.Type; newPack.AssetBlock.Success = true; newPack.AssetBlock.UUID = Asset.FullID; - ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); m_finished = true; if (m_createItem) { -- cgit v1.1 From ce3a87daa57460ac2e2636b70d55971ece6ee10e Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 19 Nov 2007 11:20:36 +0000 Subject: * Changed namespace --- OpenSim/Framework/Communications/CommunicationsManager.cs | 1 - OpenSim/Framework/Communications/UserManagerBase.cs | 1 - 2 files changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 7b1a97e..a7280aa 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -30,7 +30,6 @@ using libsecondlife; using OpenSim.Framework.Communications.Cache; using System.Collections.Generic; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index cf82103..cab54fe 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -34,7 +34,6 @@ using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; namespace OpenSim.Framework.UserManagement { -- cgit v1.1 From 7cb38712d5ad6781e672e4f1c8500ecd88d85f3e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 21 Nov 2007 02:17:24 +0000 Subject: * Did some initial work for prim crossing. Just glue so far. * Added the child_get_tasks OpenSim.ini flag for testing the UDP packet sending code and packet throttler. This flag gets purposely disabled in grid mode. This flag also has the consequence that you can see the prim in neighboring regions without going into them. Be warned, this causes tons of dropped packets. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index e5ed136..94e4cf7 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -32,8 +32,15 @@ namespace OpenSim.Framework.Communications public interface IInterRegionCommunications { bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); + bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); + bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); + bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); + bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); + bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID); + void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); + } } \ No newline at end of file -- cgit v1.1 From fb2588b409069a1c24b55bb547d1a06eec2f0440 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 23 Nov 2007 13:21:39 +0000 Subject: * Refactored NumPackets calculation --- .../Framework/Communications/Cache/AssetCache.cs | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index edca142..cb8b9f6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -333,15 +333,9 @@ namespace OpenSim.Framework.Communications.Cache { AssetRequest req = RequestedTextures[image.FullID]; req.ImageInfo = image; - if (image.Data.LongLength > 600) - { - //over 600 bytes so split up file - req.NumPackets = 2 + (int) (image.Data.Length - 601)/1000; - } - else - { - req.NumPackets = 1; - } + + req.NumPackets = CalculateNumPackets(image.Data.Length); + RequestedTextures.Remove(image.FullID); TextureRequests.Add(req); } @@ -625,24 +619,31 @@ namespace OpenSim.Framework.Communications.Cache req.ImageInfo = imag; req.DiscardLevel = discard; - if (imag.Data.LongLength > 600) - { - //Console.WriteLine("{0}", imag.Data.LongLength); - //over 600 bytes so split up file - req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000; - //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); - } - else - { - req.NumPackets = 1; - } + req.NumPackets = CalculateNumPackets(imag.Data.Length); + if (packetNumber != 0) { req.PacketCounter = (int) packetNumber; } + TextureRequests.Add(req); } + private int CalculateNumPackets(int length) + { + int numPackets = 1; + + if (length > 600) + { + //over 600 bytes so split up file + int restData = (length - 600); + int restPackets = ((restData+999)/1000); + numPackets = 1 + restPackets; + } + + return numPackets; + } + #endregion public class AssetRequest -- cgit v1.1 From 0951f895ef07a784b094d5f8eb3825b65d5ad171 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 24 Nov 2007 10:36:54 +0000 Subject: * Removed references to "new LLUUID()", replaced with LLUUID.Zero. --- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index cab54fe..6916519 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -342,8 +342,8 @@ namespace OpenSim.Framework.UserManagement agent.logoutTime = 0; // Current location - agent.regionID = new LLUUID(); // Fill in later - agent.currentRegion = new LLUUID(); // Fill in later + agent.regionID = LLUUID.Zero; // Fill in later + agent.currentRegion = LLUUID.Zero; // Fill in later profile.currentAgent = agent; } -- cgit v1.1 From 175b6115f19f9bad7c81fde625250b3a7f8a33f2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 26 Nov 2007 05:02:18 +0000 Subject: * Restarting regions with the estate tools works in sandbox mode. I'm still working on grid mode, however. It doesn't break anything, but that feature doesn't work in grid mode yet either. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 94e4cf7..c64abb5 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -33,6 +33,7 @@ namespace OpenSim.Framework.Communications { bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); + bool RegionUp(RegionInfo region); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); -- cgit v1.1 From 082f2baebe300e1313a34444c42dcc0a20c44baf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 27 Nov 2007 13:46:52 +0000 Subject: Fixed an event in the events chain in inter-region communications. As a consequence, restarting sims in the same process instance now shows them when they come back up in grid mode and standalone mode. --- OpenSim/Framework/Communications/IGridServices.cs | 1 + OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 ++ 2 files changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index c1fb9c4..b67db89 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -32,6 +32,7 @@ namespace OpenSim.Framework.Communications { public interface IGridServices { + string gdebugRegionName { get; set; } RegionCommsListener RegisterRegion(RegionInfo regionInfos); bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index c64abb5..55616a4 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -31,6 +31,8 @@ namespace OpenSim.Framework.Communications { public interface IInterRegionCommunications { + + string rdebugRegionName{ get; set; } bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); bool RegionUp(RegionInfo region); -- cgit v1.1 From b7d596a6af51bea7dba642cdc768ac5ff77af5f3 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 28 Nov 2007 06:18:07 +0000 Subject: * Restaring the sim works fine in grid mode now. Sims announce themselves to their neighbors when they start up. Neighbors get this message and tell their agents that there's a new sim up. * Certain unrecoverable physics based crashes in ODE are now hooked up to the 'restart the sim' routine. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 55616a4..a492c51 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -35,7 +35,7 @@ namespace OpenSim.Framework.Communications string rdebugRegionName{ get; set; } bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); - bool RegionUp(RegionInfo region); + bool RegionUp(SearializableRegionInfo region); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); -- cgit v1.1 From 81ba94fde8871df86e304a3dad7846059fd32045 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 29 Nov 2007 02:07:19 +0000 Subject: * Fixed about 7 issues with restarting sims and resolved interRegion comms issues. This includes the issue that MW described this morning. There's a lot of little nit picky changes that make a world of difference. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index a492c51..e025223 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -35,7 +35,7 @@ namespace OpenSim.Framework.Communications string rdebugRegionName{ get; set; } bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); - bool RegionUp(SearializableRegionInfo region); + bool RegionUp(SearializableRegionInfo region, ulong regionhandle); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); -- cgit v1.1 From 6d7ce67db1c62f5436cf8aa6819c545097a66f96 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 29 Nov 2007 07:22:11 +0000 Subject: fixed duplicate login in standalone mode (mostly untested in grid mode) --- OpenSim/Framework/Communications/LoginService.cs | 3 +-- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 450bada..118668c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -185,8 +185,7 @@ namespace OpenSim.Framework.UserManagement /// Successful? public bool CommitAgent(ref UserProfileData profile) { - // Saves the agent to database - return true; + return m_userManager.CommitAgent(ref profile); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 6916519..74dba4c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -355,8 +355,8 @@ namespace OpenSim.Framework.UserManagement /// Successful? public bool CommitAgent(ref UserProfileData profile) { - // Saves the agent to database - return true; + // TODO: how is this function different from setUserProfile? + return setUserProfile(profile); } #endregion -- cgit v1.1 From af9eb87ad1cad8c5d9b0ca3ba04dc14a12e95021 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 29 Nov 2007 17:14:06 +0000 Subject: return an appropriate inv_lib_root, which the libsl folks have identified as the reason libsl can't currently connect to OpenSim. Patch from Justin Casey (IBM) --- OpenSim/Framework/Communications/LoginResponse.cs | 10 +++++++++- OpenSim/Framework/Communications/LoginService.cs | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 98a6cfc..dccba1c 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -55,6 +55,7 @@ namespace OpenSim.Framework.UserManagement private ArrayList initialOutfit; private ArrayList agentInventory; private ArrayList inventoryLibraryOwner; + private ArrayList inventoryLibRoot; private ArrayList inventoryLibrary; private UserInfo userProfile; @@ -282,6 +283,7 @@ namespace OpenSim.Framework.UserManagement responseData["inventory-skeleton"] = agentInventory; responseData["inventory-skel-lib"] = inventoryLibrary; responseData["inventory-root"] = inventoryRoot; + responseData["inventory-lib-root"] = inventoryLibRoot; responseData["gestures"] = new ArrayList(); // todo responseData["inventory-lib-owner"] = inventoryLibraryOwner; responseData["initial-outfit"] = initialOutfit; @@ -505,6 +507,12 @@ namespace OpenSim.Framework.UserManagement set { inventoryLibraryOwner = value; } } + public ArrayList InventoryLibRoot + { + get { return inventoryLibRoot; } + set { inventoryLibRoot = value; } + } + public string Home { get { return home; } @@ -583,4 +591,4 @@ namespace OpenSim.Framework.UserManagement } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 118668c..239bada 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -130,6 +130,13 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); + + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten -- cgit v1.1 From d3ab5ad506477bb7dbcff61893afc91aef931158 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 29 Nov 2007 20:20:11 +0000 Subject: revert r2510, this seems to break normal logins, at least from Linux clients. --- OpenSim/Framework/Communications/LoginResponse.cs | 10 +--------- OpenSim/Framework/Communications/LoginService.cs | 7 ------- 2 files changed, 1 insertion(+), 16 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index dccba1c..98a6cfc 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -55,7 +55,6 @@ namespace OpenSim.Framework.UserManagement private ArrayList initialOutfit; private ArrayList agentInventory; private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibRoot; private ArrayList inventoryLibrary; private UserInfo userProfile; @@ -283,7 +282,6 @@ namespace OpenSim.Framework.UserManagement responseData["inventory-skeleton"] = agentInventory; responseData["inventory-skel-lib"] = inventoryLibrary; responseData["inventory-root"] = inventoryRoot; - responseData["inventory-lib-root"] = inventoryLibRoot; responseData["gestures"] = new ArrayList(); // todo responseData["inventory-lib-owner"] = inventoryLibraryOwner; responseData["initial-outfit"] = initialOutfit; @@ -507,12 +505,6 @@ namespace OpenSim.Framework.UserManagement set { inventoryLibraryOwner = value; } } - public ArrayList InventoryLibRoot - { - get { return inventoryLibRoot; } - set { inventoryLibRoot = value; } - } - public string Home { get { return home; } @@ -591,4 +583,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 239bada..118668c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -130,13 +130,6 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); - - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten -- cgit v1.1 From 5eb091ceee98f334fbb4c37e25f8217d1c40701f Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 30 Nov 2007 01:20:31 +0000 Subject: * Temporary fix for 'User already online' issue in standalone mode. * Revert this once we get a working logoff. --- OpenSim/Framework/Communications/LoginService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 118668c..9177704 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -96,10 +96,15 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { + userProfile.currentAgent.agentOnline = false; + m_userManager.CommitAgent(ref userProfile); + // Reject the login return logResponse.CreateAlreadyLoggedInResponse(); + } // Otherwise... // Create a new agent session -- cgit v1.1 From 57e6b516390a6a07a9c5fb62f11f56ccb6bf04fa Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 30 Nov 2007 02:01:12 +0000 Subject: * Here's the issue, on log-off, the routine sets up a null useragent member and then tries to save it to the database.. where it was going wrong, is the database had a check to do *nothing* when it got a null useragent. I made it delete the userAgent row. This should be a good enough fix to solve the problem. It still needs to be looked at by a DB guy --- OpenSim/Framework/Communications/UserManagerBase.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 74dba4c..f1f2c2b 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -253,6 +253,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData profile = GetUserProfile(agentID); profile.currentAgent = null; + setUserProfile(profile); } -- cgit v1.1 From 3ab3392defb1a8d6f1605ce37579158ed83d1c20 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 30 Nov 2007 02:14:29 +0000 Subject: * This extends my first hack to clear out the useragent table for that specific user. * This helps people who have multiple records in their useragent table. * This update should be looked at.. because really what it should be doing is initiating a grid wide logoff. --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 9177704..1d53669 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -99,7 +99,7 @@ namespace OpenSim.Framework.UserManagement if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { - userProfile.currentAgent.agentOnline = false; + userProfile.currentAgent = null; m_userManager.CommitAgent(ref userProfile); // Reject the login -- cgit v1.1 From d2fe290bb6fe52e40799b4b258564b7bf9f9aed2 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 30 Nov 2007 15:27:56 +0000 Subject: return of the inv-lib-root patch from Justin Casey (IBM) Should fix libsl login ability. No long breaks my login to test environment. --- OpenSim/Framework/Communications/LoginResponse.cs | 10 +++++++++- OpenSim/Framework/Communications/LoginService.cs | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 98a6cfc..dccba1c 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -55,6 +55,7 @@ namespace OpenSim.Framework.UserManagement private ArrayList initialOutfit; private ArrayList agentInventory; private ArrayList inventoryLibraryOwner; + private ArrayList inventoryLibRoot; private ArrayList inventoryLibrary; private UserInfo userProfile; @@ -282,6 +283,7 @@ namespace OpenSim.Framework.UserManagement responseData["inventory-skeleton"] = agentInventory; responseData["inventory-skel-lib"] = inventoryLibrary; responseData["inventory-root"] = inventoryRoot; + responseData["inventory-lib-root"] = inventoryLibRoot; responseData["gestures"] = new ArrayList(); // todo responseData["inventory-lib-owner"] = inventoryLibraryOwner; responseData["initial-outfit"] = initialOutfit; @@ -505,6 +507,12 @@ namespace OpenSim.Framework.UserManagement set { inventoryLibraryOwner = value; } } + public ArrayList InventoryLibRoot + { + get { return inventoryLibRoot; } + set { inventoryLibRoot = value; } + } + public string Home { get { return home; } @@ -583,4 +591,4 @@ namespace OpenSim.Framework.UserManagement } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 1d53669..4c33bd8 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -135,6 +135,13 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); + + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten -- cgit v1.1 From b167507e323a2f0162aa3106ab63d8cf2a5f57ae Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 30 Nov 2007 20:16:40 +0000 Subject: Patch for mantis 0000015: Textures don't display in the object properties window From Justin Casey (IBM) --- .../Communications/Cache/InventoryFolder.cs | 9 ++++++++- .../Communications/Cache/UserProfileCache.cs | 23 +++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 3495e55..6161c5a 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -36,6 +36,13 @@ namespace OpenSim.Framework.Communications.Cache public Dictionary Items = new Dictionary(); public Dictionary SubFolders = new Dictionary(); + // Accessors + public int SubFoldersCount + { + get { return SubFolders.Count; } + } + + // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) { agentID = folderbase.agentID; @@ -132,4 +139,4 @@ namespace OpenSim.Framework.Communications.Cache return itemList; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 117ed36..379ac9d 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -111,6 +111,15 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Tell the client about the various child items and folders contained in the requested folder. + /// + /// + /// + /// + /// + /// + /// public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { @@ -118,14 +127,14 @@ namespace OpenSim.Framework.Communications.Cache if (folderID == libraryRoot.folderID) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, - libraryRoot.RequestListOfItems()); + libraryRoot.RequestListOfItems(), libraryRoot.SubFoldersCount); return; } if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.SubFoldersCount); return; } @@ -140,16 +149,16 @@ namespace OpenSim.Framework.Communications.Cache if (fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - userProfile.RootFolder.RequestListOfItems()); + userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.SubFoldersCount); } } else { InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(folderID); - if ((folder != null) && fetchItems) + + if (fetchItems && folder != null) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - folder.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems(), folder.SubFoldersCount); } } } @@ -184,4 +193,4 @@ namespace OpenSim.Framework.Communications.Cache m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } } -} \ No newline at end of file +} -- cgit v1.1 From fff468dcfe1dcca005a01f6370f1cd967f9c589a Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 1 Dec 2007 16:40:26 +0000 Subject: Attempt to fix mantis issue # 65, seems like it is a race condition between two regions trying to add a user to the AssetTransactionManager at the same time. So have placed a lock around the Dictionary add. --- .../Framework/Communications/Cache/AssetTransactionManager.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 55b255a..cbf63ca 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -49,11 +49,14 @@ namespace OpenSim.Framework.Communications.Cache // Methods public AgentAssetTransactions AddUser(LLUUID userID) { - if (!AgentTransactions.ContainsKey(userID)) + lock (AgentTransactions) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); - AgentTransactions.Add(userID, transactions); - return transactions; + if (!AgentTransactions.ContainsKey(userID)) + { + AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); + AgentTransactions.Add(userID, transactions); + return transactions; + } } return null; } -- cgit v1.1 From 5df851761aa796cba70a3b6d8b36d119502c1de2 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 1 Dec 2007 18:49:17 +0000 Subject: Initial working Grid Inventory server. Only been tested on a very small grid, so likely to have problems on a larger grid with more people? To use , both the user server and Inventory server need to be running this latest revision. (older regions should be able to still be used, just the user won't have inventory on them). Also and HERE IS THE BIG BREAK ISSUE, currently, so that the initial inventory details for a user are added to the inventory db , you need to recreate the accounts using the user server "create user" feature. It should be quite easy to manual populate the inventory database instead but I someone else will need to look into that) Also I've only tested using SQLite as the database provider, there is a Mysql inventory provider but I don't know if it works (SQLite is set as default, so you will need to change it in the inventory server config.xml) --- OpenSim/Framework/Communications/IInventoryServices.cs | 2 +- OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 ++-- OpenSim/Framework/Communications/UserManagerBase.cs | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index fc301c2..96bb7b3 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications public interface IInventoryServices { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); + void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); void CreateNewUserInventory(LLUUID user); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index effe132..091d829 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications } } - public void deleteItem(InventoryItemBase item) + public void DeleteItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) { @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f1f2c2b..119f8a5 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -366,7 +366,7 @@ namespace OpenSim.Framework.UserManagement /// /// /// - public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); user.homeLocation = new LLVector3(128, 128, 100); @@ -391,6 +391,8 @@ namespace OpenSim.Framework.UserManagement MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } + + return user.UUID; } public abstract UserProfileData SetupMasterUser(string firstName, string lastName); -- cgit v1.1 From 4dee53c7fb476b0503b8443b2dba1eb868a56815 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 1 Dec 2007 20:57:14 +0000 Subject: Attempt to fix mantis issue # 73 --- .../Communications/Cache/InventoryFolder.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 6161c5a..fd029cd 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -60,14 +60,18 @@ namespace OpenSim.Framework.Communications.Cache // Methods public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { - InventoryFolderImpl subFold = new InventoryFolderImpl(); - subFold.name = folderName; - subFold.folderID = folderID; - subFold.type = (short) type; - subFold.parentID = this.folderID; - subFold.agentID = agentID; - SubFolders.Add(subFold.folderID, subFold); - return subFold; + if (!SubFolders.ContainsKey(folderID)) + { + InventoryFolderImpl subFold = new InventoryFolderImpl(); + subFold.name = folderName; + subFold.folderID = folderID; + subFold.type = (short)type; + subFold.parentID = this.folderID; + subFold.agentID = agentID; + SubFolders.Add(subFold.folderID, subFold); + return subFold; + } + return null; } public InventoryItemBase HasItem(LLUUID itemID) -- cgit v1.1 From b92df4aaafb353b4737aede206e99f10dd946bf1 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 10:21:17 +0000 Subject: New Inventory folder should now be stored to the inventory server/database. This also seems to fix the problem of Body parts not being persisted properly. --- OpenSim/Framework/Communications/Cache/UserProfileCache.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 379ac9d..3c8ab51 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -96,7 +96,14 @@ namespace OpenSim.Framework.Communications.Cache if (createdFolder != null) { - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.agentID = createdFolder.agentID; + createdBaseFolder.folderID = createdFolder.folderID; + createdBaseFolder.name = createdFolder.name; + createdBaseFolder.parentID = createdFolder.parentID; + createdBaseFolder.type = createdFolder.type; + createdBaseFolder.version = createdFolder.version; + m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } } else -- cgit v1.1 From 80609c2b1572d9b946675db486fc46e327171cfa Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 13:59:15 +0000 Subject: Some refactoring , mainly on Inventory code. --- .../Communications/Cache/InventoryFolder.cs | 146 --------------- .../Communications/Cache/InventoryFolderImpl.cs | 146 +++++++++++++++ .../Communications/Cache/LibraryRootFolder.cs | 152 ++++----------- .../Communications/Cache/UserProfileCache.cs | 203 --------------------- .../Cache/UserProfileCacheService.cs | 203 +++++++++++++++++++++ .../Communications/CommunicationsManager.cs | 6 +- 6 files changed, 387 insertions(+), 469 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/InventoryFolder.cs create mode 100644 OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs delete mode 100644 OpenSim/Framework/Communications/Cache/UserProfileCache.cs create mode 100644 OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs deleted file mode 100644 index fd029cd..0000000 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ /dev/null @@ -1,146 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System.Collections.Generic; -using libsecondlife; - -namespace OpenSim.Framework.Communications.Cache -{ - public class InventoryFolderImpl : InventoryFolderBase - { - // Fields - public Dictionary Items = new Dictionary(); - public Dictionary SubFolders = new Dictionary(); - - // Accessors - public int SubFoldersCount - { - get { return SubFolders.Count; } - } - - // Constructors - public InventoryFolderImpl(InventoryFolderBase folderbase) - { - agentID = folderbase.agentID; - folderID = folderbase.folderID; - name = folderbase.name; - parentID = folderbase.parentID; - type = folderbase.type; - version = folderbase.version; - } - - public InventoryFolderImpl() - { - } - - // Methods - public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) - { - if (!SubFolders.ContainsKey(folderID)) - { - InventoryFolderImpl subFold = new InventoryFolderImpl(); - subFold.name = folderName; - subFold.folderID = folderID; - subFold.type = (short)type; - subFold.parentID = this.folderID; - subFold.agentID = agentID; - SubFolders.Add(subFold.folderID, subFold); - return subFold; - } - return null; - } - - public InventoryItemBase HasItem(LLUUID itemID) - { - InventoryItemBase base2 = null; - if (Items.ContainsKey(itemID)) - { - return Items[itemID]; - } - foreach (InventoryFolderImpl folder in SubFolders.Values) - { - base2 = folder.HasItem(itemID); - if (base2 != null) - { - break; - } - } - return base2; - } - - public bool DeleteItem(LLUUID itemID) - { - bool found = false; - if (Items.ContainsKey(itemID)) - { - Items.Remove(itemID); - return true; - } - foreach (InventoryFolderImpl folder in SubFolders.Values) - { - found = folder.DeleteItem(itemID); - if (found == true) - { - break; - } - } - return found; - } - - - public InventoryFolderImpl HasSubFolder(LLUUID folderID) - { - InventoryFolderImpl returnFolder = null; - if (SubFolders.ContainsKey(folderID)) - { - returnFolder = SubFolders[folderID]; - } - else - { - foreach (InventoryFolderImpl folder in SubFolders.Values) - { - returnFolder = folder.HasSubFolder(folderID); - if (returnFolder != null) - { - break; - } - } - } - return returnFolder; - } - - public List RequestListOfItems() - { - List itemList = new List(); - foreach (InventoryItemBase item in Items.Values) - { - itemList.Add(item); - } - return itemList; - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs new file mode 100644 index 0000000..fd029cd --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -0,0 +1,146 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Communications.Cache +{ + public class InventoryFolderImpl : InventoryFolderBase + { + // Fields + public Dictionary Items = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); + + // Accessors + public int SubFoldersCount + { + get { return SubFolders.Count; } + } + + // Constructors + public InventoryFolderImpl(InventoryFolderBase folderbase) + { + agentID = folderbase.agentID; + folderID = folderbase.folderID; + name = folderbase.name; + parentID = folderbase.parentID; + type = folderbase.type; + version = folderbase.version; + } + + public InventoryFolderImpl() + { + } + + // Methods + public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + { + if (!SubFolders.ContainsKey(folderID)) + { + InventoryFolderImpl subFold = new InventoryFolderImpl(); + subFold.name = folderName; + subFold.folderID = folderID; + subFold.type = (short)type; + subFold.parentID = this.folderID; + subFold.agentID = agentID; + SubFolders.Add(subFold.folderID, subFold); + return subFold; + } + return null; + } + + public InventoryItemBase HasItem(LLUUID itemID) + { + InventoryItemBase base2 = null; + if (Items.ContainsKey(itemID)) + { + return Items[itemID]; + } + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + base2 = folder.HasItem(itemID); + if (base2 != null) + { + break; + } + } + return base2; + } + + public bool DeleteItem(LLUUID itemID) + { + bool found = false; + if (Items.ContainsKey(itemID)) + { + Items.Remove(itemID); + return true; + } + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + found = folder.DeleteItem(itemID); + if (found == true) + { + break; + } + } + return found; + } + + + public InventoryFolderImpl HasSubFolder(LLUUID folderID) + { + InventoryFolderImpl returnFolder = null; + if (SubFolders.ContainsKey(folderID)) + { + returnFolder = SubFolders[folderID]; + } + else + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + returnFolder = folder.HasSubFolder(folderID); + if (returnFolder != null) + { + break; + } + } + } + return returnFolder; + } + + public List RequestListOfItems() + { + List itemList = new List(); + foreach (InventoryItemBase item in Items.Values) + { + itemList.Add(item); + } + return itemList; + } + } +} diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 62251bc..33b4281 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -49,8 +49,8 @@ namespace OpenSim.Framework.Communications.Cache folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); name = "OpenSim Library"; parentID = LLUUID.Zero; - type = (short) -1; - version = (ushort) 1; + type = (short)-1; + version = (ushort)1; InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; @@ -67,7 +67,7 @@ namespace OpenSim.Framework.Communications.Cache string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); if (File.Exists(filePath)) { - try + try { XmlConfigSource source = new XmlConfigSource(filePath); ReadItemsFromFile(source); @@ -81,143 +81,61 @@ namespace OpenSim.Framework.Communications.Cache private void CreateLibraryItems() { - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); - item.inventoryDescription = "Plywood texture"; - item.inventoryName = "Plywood"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + InventoryItemBase item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000002"), "Plywood", "Plywood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); m_textureFolder.Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003"); - item.inventoryDescription = "Rocks texture"; - item.inventoryName = "Rocks"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000003"), "Rocks", "Rocks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); m_textureFolder.Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001"); - item.inventoryDescription = "Bricks texture"; - item.inventoryName = "Bricks"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000001"), "Bricks", "Bricks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); m_textureFolder.Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004"); - item.inventoryDescription = "Granite texture"; - item.inventoryName = "Granite"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000004"), "Granite", "Granite texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); m_textureFolder.Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005"); - item.inventoryDescription = "Hardwood texture"; - item.inventoryName = "Hardwood"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000005"), "Hardwood", "Hardwood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); m_textureFolder.Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"); - item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - item.inventoryDescription = "Default Shape"; - item.inventoryName = "Default Shape"; - item.assetType = (int) AssetType.Bodypart; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; + item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"); - item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - item.inventoryDescription = "Default Skin"; - item.inventoryName = "Default Skin"; - item.assetType = (int) AssetType.Bodypart; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"); - item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - item.inventoryDescription = "Default Shirt"; - item.inventoryName = "Default Shirt"; - item.assetType = (int) AssetType.Clothing; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"); - item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - item.inventoryDescription = "Default Pants"; - item.inventoryName = "Default Pants"; - item.assetType = (int) AssetType.Clothing; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); } + private InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) + { + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = LLUUID.Random(); + item.assetID = assetID; + item.inventoryDescription = description; + item.inventoryName = name; + item.assetType = assetType; + item.invType = invType; + item.parentFolderID = parentFolderID; + item.inventoryBasePermissions = 0x7FFFFFFF; + item.inventoryEveryOnePermissions = 0x7FFFFFFF; + item.inventoryCurrentPermissions = 0x7FFFFFFF; + item.inventoryNextPermissions = 0x7FFFFFFF; + return item; + } + private void ReadItemsFromFile(IConfigSource source) { for (int i = 0; i < source.Configs.Count; i++) @@ -232,10 +150,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); if (item.assetType == 0) { item.parentFolderID = m_textureFolder.folderID; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs deleted file mode 100644 index 3c8ab51..0000000 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ /dev/null @@ -1,203 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System.Collections.Generic; -using libsecondlife; - -namespace OpenSim.Framework.Communications.Cache -{ - public class UserProfileCache - { - // Fields - private readonly CommunicationsManager m_parent; - private readonly Dictionary m_userProfiles = new Dictionary(); - - public LibraryRootFolder libraryRoot = new LibraryRootFolder(); - - // Methods - 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) - { - // Potential fix - Multithreading issue. - lock (m_userProfiles) - { - if (!m_userProfiles.ContainsKey(userID)) - { - CachedUserInfo userInfo = new CachedUserInfo(m_parent); - userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); - - if (userInfo.UserProfile != null) - { - RequestInventoryForUser(userID, userInfo); - m_userProfiles.Add(userID, userInfo); - } - else - { - System.Console.WriteLine("CACHE", "User profile for user not found"); - } - } - } - } - - public CachedUserInfo GetUserDetails(LLUUID userID) - { - if (m_userProfiles.ContainsKey(userID)) - return m_userProfiles[userID]; - else - return null; - } - - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, - string folderName, LLUUID parentID) - { - CachedUserInfo userProfile; - - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (userProfile.RootFolder != null) - { - if (userProfile.RootFolder.folderID == parentID) - { - InventoryFolderImpl createdFolder = - userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.agentID = createdFolder.agentID; - createdBaseFolder.folderID = createdFolder.folderID; - createdBaseFolder.name = createdFolder.name; - createdBaseFolder.parentID = createdFolder.parentID; - createdBaseFolder.type = createdFolder.type; - createdBaseFolder.version = createdFolder.version; - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); - } - } - else - { - InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID); - if (folder != null) - { - folder.CreateNewSubFolder(folderID, folderName, folderType); - } - } - } - } - } - - /// - /// Tell the client about the various child items and folders contained in the requested folder. - /// - /// - /// - /// - /// - /// - /// - public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder) - { - InventoryFolderImpl fold = null; - if (folderID == libraryRoot.folderID) - { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, - libraryRoot.RequestListOfItems(), libraryRoot.SubFoldersCount); - - return; - } - - if ((fold = libraryRoot.HasSubFolder(folderID)) != null) - { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.SubFoldersCount); - - return; - } - - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (userProfile.RootFolder != null) - { - if (userProfile.RootFolder.folderID == folderID) - { - if (fetchItems) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.SubFoldersCount); - } - } - else - { - InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(folderID); - - if (fetchItems && folder != null) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems(), folder.SubFoldersCount); - } - } - } - } - } - - public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) - { - if (ownerID == libraryRoot.agentID) - { - //Console.WriteLine("request info for library item"); - - return; - } - - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (userProfile.RootFolder != null) - { - InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); - if (item != null) - { - remoteClient.SendInventoryItemDetails(ownerID, item); - } - } - } - } - - private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) - { - m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs new file mode 100644 index 0000000..b24d763 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -0,0 +1,203 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Communications.Cache +{ + public class UserProfileCacheService + { + // Fields + private readonly CommunicationsManager m_parent; + private readonly Dictionary m_userProfiles = new Dictionary(); + + public LibraryRootFolder libraryRoot = new LibraryRootFolder(); + + // Methods + public UserProfileCacheService(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) + { + // Potential fix - Multithreading issue. + lock (m_userProfiles) + { + if (!m_userProfiles.ContainsKey(userID)) + { + CachedUserInfo userInfo = new CachedUserInfo(m_parent); + userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); + + if (userInfo.UserProfile != null) + { + RequestInventoryForUser(userID, userInfo); + m_userProfiles.Add(userID, userInfo); + } + else + { + System.Console.WriteLine("CACHE", "User profile for user not found"); + } + } + } + } + + public CachedUserInfo GetUserDetails(LLUUID userID) + { + if (m_userProfiles.ContainsKey(userID)) + return m_userProfiles[userID]; + else + return null; + } + + public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, + string folderName, LLUUID parentID) + { + CachedUserInfo userProfile; + + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + if (userProfile.RootFolder.folderID == parentID) + { + InventoryFolderImpl createdFolder = + userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + + if (createdFolder != null) + { + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.agentID = createdFolder.agentID; + createdBaseFolder.folderID = createdFolder.folderID; + createdBaseFolder.name = createdFolder.name; + createdBaseFolder.parentID = createdFolder.parentID; + createdBaseFolder.type = createdFolder.type; + createdBaseFolder.version = createdFolder.version; + m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + } + } + else + { + InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID); + if (folder != null) + { + folder.CreateNewSubFolder(folderID, folderName, folderType); + } + } + } + } + } + + /// + /// Tell the client about the various child items and folders contained in the requested folder. + /// + /// + /// + /// + /// + /// + /// + public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, + bool fetchFolders, bool fetchItems, int sortOrder) + { + InventoryFolderImpl fold = null; + if (folderID == libraryRoot.folderID) + { + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, + libraryRoot.RequestListOfItems(), libraryRoot.SubFoldersCount); + + return; + } + + if ((fold = libraryRoot.HasSubFolder(folderID)) != null) + { + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.SubFoldersCount); + + return; + } + + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + if (userProfile.RootFolder.folderID == folderID) + { + if (fetchItems) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, + userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.SubFoldersCount); + } + } + else + { + InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(folderID); + + if (fetchItems && folder != null) + { + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems(), folder.SubFoldersCount); + } + } + } + } + } + + public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) + { + if (ownerID == libraryRoot.agentID) + { + //Console.WriteLine("request info for library item"); + + return; + } + + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); + if (item != null) + { + remoteClient.SendInventoryItemDetails(ownerID, item); + } + } + } + } + + private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) + { + m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + } + } +} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index a7280aa..d4ddead 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -64,9 +64,9 @@ namespace OpenSim.Framework.Communications get { return m_interRegion; } } - protected UserProfileCache m_userProfileCache; + protected UserProfileCacheService m_userProfileCache; - public UserProfileCache UserProfileCache + public UserProfileCacheService UserProfileCache { get { return m_userProfileCache; } } @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications { m_networkServersInfo = serversInfo; m_assetCache = assetCache; - m_userProfileCache = new UserProfileCache(this); + m_userProfileCache = new UserProfileCacheService(this); m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } -- cgit v1.1 From 86ae8e97cda6360758b3cf2c7dce94b7da9cf486 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 14:12:56 +0000 Subject: Fixes a bug that my last commit introduced. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 33b4281..2a24821 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -122,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); + item.inventoryID = inventoryID; item.assetID = assetID; item.inventoryDescription = description; item.inventoryName = name; -- cgit v1.1 From cac98171e5143dbcd37acca00a9e4ed87ec4e477 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 14:56:23 +0000 Subject: Very partial Avatar Appearance (ie, clothes/body parts) "storage". In standalone mode it will mean that when you log off and log back on ,as long as the region server hasn't been restarted , your avatar will start with wearing the clothes that it wore on log off. In grid mode its even more limited in that wearing/removing clothes/body parts are only stored in the region server instance you are one. so if you are in a different region to your login region (which are on different region server instances), and then change clothes, those changes won't be remembered. So as said, its very limited but is a small step towards having proper appearance persist. Just need to store this data out to a database. --- .../Framework/Communications/Cache/AssetTransactions.cs | 2 +- .../Framework/Communications/CommunicationsManager.cs | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index acd57b6..f7e80c9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -333,7 +333,7 @@ namespace OpenSim.Framework.Communications.Cache //really need to fix this call, if lbsa71 saw this he would die. m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); CachedUserInfo userInfo = - m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); + m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d4ddead..bfdd118 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -64,11 +64,11 @@ namespace OpenSim.Framework.Communications get { return m_interRegion; } } - protected UserProfileCacheService m_userProfileCache; + protected UserProfileCacheService m_userProfileCacheService; - public UserProfileCacheService UserProfileCache + public UserProfileCacheService UserProfileCacheService { - get { return m_userProfileCache; } + get { return m_userProfileCacheService; } } protected AssetTransactionManager m_transactionsManager; @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications { m_networkServersInfo = serversInfo; m_assetCache = assetCache; - m_userProfileCache = new UserProfileCacheService(this); + m_userProfileCacheService = new UserProfileCacheService(this); m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } @@ -156,7 +156,7 @@ namespace OpenSim.Framework.Communications public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfileCache.libraryRoot.agentID) + if (uuid == m_userProfileCacheService.libraryRoot.agentID) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } @@ -175,11 +175,7 @@ namespace OpenSim.Framework.Communications } public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { - - - List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); - - + List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); return pickerlist; } -- cgit v1.1 From ac77c32453fdeffc03a5abbb6cbb037dfc1e7c0d Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 2 Dec 2007 20:43:21 +0000 Subject: Attempt to fix mantis issue #82, taking prims into inventory and then rezzing them in another region. --- .../Framework/Communications/Cache/CachedUserInfo.cs | 20 ++++++++++++++++---- .../Communications/Cache/UserProfileCacheService.cs | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 8fbc3fd..81ee29b 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -55,14 +55,20 @@ namespace OpenSim.Framework.Communications.Cache } else if (RootFolder.folderID == folderInfo.parentID) { - RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + if (!RootFolder.SubFolders.ContainsKey(folderInfo.folderID)) + { + RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + } } else { InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { - folder.SubFolders.Add(folderInfo.folderID, folderInfo); + if (!folder.SubFolders.ContainsKey(folderInfo.folderID)) + { + folder.SubFolders.Add(folderInfo.folderID, folderInfo); + } } } } @@ -74,14 +80,20 @@ namespace OpenSim.Framework.Communications.Cache { if (itemInfo.parentFolderID == RootFolder.folderID) { - RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + if (!RootFolder.Items.ContainsKey(itemInfo.inventoryID)) + { + RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + } } else { InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + if (!folder.Items.ContainsKey(itemInfo.inventoryID)) + { + folder.Items.Add(itemInfo.inventoryID, itemInfo); + } } } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b24d763..fb4c3a6 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -72,6 +72,15 @@ namespace OpenSim.Framework.Communications.Cache } } + public void UpdateUserInventory(LLUUID userID) + { + CachedUserInfo userInfo = GetUserDetails(userID); + if (userInfo != null) + { + RequestInventoryForUser(userID, userInfo); + } + } + public CachedUserInfo GetUserDetails(LLUUID userID) { if (m_userProfiles.ContainsKey(userID)) -- cgit v1.1 From 4c0ddacc160f3c25343eba73d2c2b026dfbbf67d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 3 Dec 2007 07:26:27 +0000 Subject: minor meaningless changes --- OpenSim/Framework/Communications/RestClient/RestClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index acb3fd4..7a23e78 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -177,7 +177,7 @@ namespace OpenSim.Framework.Communications } /// - /// Build a Uri based on the intial Url, path elements and parameters + /// Build a Uri based on the initial Url, path elements and parameters /// /// fully constructed Uri private Uri buildUri() @@ -250,7 +250,7 @@ namespace OpenSim.Framework.Communications } /// - /// Async method, invoked when the intial response if received from the server + /// Async method, invoked when the initial response if received from the server /// /// private void ResponseIsReadyDelegate(IAsyncResult ar) -- cgit v1.1 From c29105aa3ee52e158b4c7870409165a89be4bcf6 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 3 Dec 2007 17:24:27 +0000 Subject: This is a simple patch which just renames an IClientAPI method to SendInventoryItemCreateUpdate() in order to reflect the actual packet it sends (UpdateCreateInventoryItem). From Justin Casey (IBM) --- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index f7e80c9..9bc24e7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryNextPermissions = nextPerm; userInfo.AddItem(ourClient.AgentId, item); - ourClient.SendInventoryItemUpdate(item); + ourClient.SendInventoryItemCreateUpdate(item); } } -- cgit v1.1 From be7ae3dd3ecddc46390f40c0315ff84703c32e7a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 4 Dec 2007 08:18:09 +0000 Subject: * Removed 12 compiler warnings. --- OpenSim/Framework/Communications/LoginService.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 4c33bd8..e7441b8 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -178,7 +178,6 @@ namespace OpenSim.Framework.UserManagement { m_loginMutex.ReleaseMutex(); } - return null; } /// -- cgit v1.1 From 01db4cd71dd935407c1449e34921719036c2ec56 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 4 Dec 2007 10:22:09 +0000 Subject: * More console message fixes * Tagged Verbose("msg",...) as obsolete. Please use Verbose("AREA","msg",...) instead. --- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- .../Framework/Communications/UserManagerBase.cs | 25 +++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e7441b8..d18cf63 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -158,7 +158,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose(e.ToString()); + MainLog.Instance.Verbose("LOGIN", e.ToString()); return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } @@ -168,7 +168,7 @@ namespace OpenSim.Framework.UserManagement catch (Exception E) { - MainLog.Instance.Verbose(E.ToString()); + MainLog.Instance.Verbose("LOGIN", E.ToString()); } //} } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 119f8a5..88214cd 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -50,10 +50,10 @@ namespace OpenSim.Framework.UserManagement { if (!String.IsNullOrEmpty(FileName)) { - MainLog.Instance.Verbose("Userstorage: Attempting to load " + FileName); + MainLog.Instance.Verbose("USERSTORAGE", "Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose("Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + MainLog.Instance.Verbose("USERSTORAGE", "Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -75,7 +75,7 @@ namespace OpenSim.Framework.UserManagement { plug.Initialise(); _plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("Userstorage: Added IUserData Interface"); + MainLog.Instance.Verbose("USERSTORAGE", "Added IUserData Interface"); } #region Get UserProfile @@ -97,7 +97,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -116,7 +116,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception) { - MainLog.Instance.Verbose("Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); return new List(); } } @@ -141,8 +141,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - System.Console.WriteLine("EEK!"); - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -169,7 +168,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -193,7 +192,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -219,7 +218,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -241,7 +240,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -274,7 +273,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -388,7 +387,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } -- cgit v1.1 From 4bde56457f574060c1aaaca8effba1f6fe00b6c7 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 6 Dec 2007 01:41:41 +0000 Subject: removed some duplicate hard-coded port numbers. changed ports to uint. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- OpenSim/Framework/Communications/LoginResponse.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 51a4598..4603280 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.Capabilities public class Caps { private string m_httpListenerHostName; - private int m_httpListenPort; + private uint m_httpListenPort; private string m_capsObjectPath = "00001-"; private string m_requestPath = "0000/"; private string m_mapLayerPath = "0001/"; @@ -68,7 +68,7 @@ namespace OpenSim.Region.Capabilities public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; - public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, + public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { m_assetCache = assetCache; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index dccba1c..bce518b 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.UserManagement private string gendered; private string everLoggedIn; private string login; - private int simPort; + private uint simPort; private string simAddress; private string agentAccess; private Int32 circuitCode; @@ -369,7 +369,7 @@ namespace OpenSim.Framework.UserManagement set { everLoggedIn = value; } } // EverLoggedIn - public int SimPort + public uint SimPort { get { return simPort; } set { simPort = value; } -- cgit v1.1 From 395637acddca473380d09ba23acc3b6db0814e75 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 6 Dec 2007 14:08:22 +0000 Subject: * now the throttle timer is stopped whilst processing Queue so that it won't fire twice * started to refactored throttling method * some code convention refactorings --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index cb8b9f6..64e0e54 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -776,8 +776,13 @@ namespace OpenSim.Framework.Communications.Cache im.Header.Reliable = false; 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; + if (size > 1000) + { + size = 1000; + } + //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size); -- cgit v1.1 From 1ad83bcf1b71722a503ebca5540cc61015aad635 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 6 Dec 2007 20:13:02 +0000 Subject: reversing the r2599 patch, as this started causing CreateThread errors for me on Mono 1.2.4, which led to client crashes. I think the Timer.Stop() wasn't doing what was desired on Mono. The Queue refactoring should address the readability issues lbsa71 was working on as soon as I get the merge together. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 64e0e54..cb8b9f6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -776,13 +776,8 @@ namespace OpenSim.Framework.Communications.Cache im.Header.Reliable = false; 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; - } - + if (size > 1000) size = 1000; //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size); -- cgit v1.1 From 3d938f76b7c2f8ede862f9979383d79dfb21372c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 7 Dec 2007 08:54:31 +0000 Subject: Updates to LibSL revision 1498. Thanks Johan! --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 18 ++++++++++-------- .../Communications/Capabilities/LLSDStreamHandler.cs | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 4603280..f7cb20c 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -258,7 +258,7 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); + libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 8252a63..793c366 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Capabilities return sw.ToString(); } - public static void SerializeLLSDType(XmlTextWriter writer, object obj) + private static void SerializeLLSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -76,7 +76,8 @@ namespace OpenSim.Region.Capabilities writer.WriteStartElement(String.Empty, "key", String.Empty); writer.WriteString(fields[i].Name); writer.WriteEndElement(); - LLSD.LLSDWriteOne(writer, fieldValue); + libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); } } writer.WriteEndElement(); @@ -99,11 +100,12 @@ namespace OpenSim.Region.Capabilities } else { - LLSD.LLSDWriteOne(writer, obj); + libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); } } - - public static object DeserialiseLLSDMap(Hashtable llsd, object obj) + + public static object DeserialiseLLSDMap(libsecondlife.StructuredData.LLSDMap llsd, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -118,10 +120,10 @@ namespace OpenSim.Region.Capabilities FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { - if (enumerator.Value is Hashtable) + if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); + DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { @@ -143,4 +145,4 @@ namespace OpenSim.Region.Capabilities return obj; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 08e9563..ed25e71 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -31,6 +31,7 @@ using System.IO; using System.Text; using libsecondlife; using OpenSim.Framework.Servers; +using System.Xml; namespace OpenSim.Region.Capabilities { @@ -53,7 +54,8 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); + libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) + libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -64,4 +66,4 @@ namespace OpenSim.Region.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} \ No newline at end of file +} -- cgit v1.1 From a71f4c021b8d2fcf0e121145428aa797b8f7ca19 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 7 Dec 2007 22:29:16 +0000 Subject: "Borrowed" the LLSD class from a older version of libsl, so that our LLSD decoding (used by CAPS) works again. --- .../Framework/Communications/Capabilities/Caps.cs | 10 +- .../Framework/Communications/Capabilities/LLSD.cs | 648 +++++++++++++++++++++ .../Communications/Capabilities/LLSDCapsDetails.cs | 3 +- .../Communications/Capabilities/LLSDHelpers.cs | 20 +- .../Capabilities/LLSDStreamHandler.cs | 6 +- 5 files changed, 672 insertions(+), 15 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSD.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f7cb20c..dd30e9f 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.Capabilities private string m_requestPath = "0000/"; private string m_mapLayerPath = "0001/"; private string m_newInventory = "0002/"; - //private string m_requestTexture = "0003/"; + //private string m_requestTexture = "0003/"; private string m_notecardUpdatePath = "0004/"; //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -125,7 +125,7 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { - // Console.WriteLine("caps request " + request); + //Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); return result; } @@ -140,10 +140,11 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; + // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; + // caps.UpdateScriptTaskInventory = capsBaseUrl + m_requestTexture; return caps; } @@ -258,7 +259,8 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { - libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); + //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs new file mode 100644 index 0000000..60b5f75 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -0,0 +1,648 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using libsecondlife; +using System.Security.Cryptography; +using System.Text; + +namespace OpenSim.Region.Capabilities +{ + /// + /// + /// + public static class LLSD + { + /// + /// + /// + public class LLSDParseException : Exception + { + public LLSDParseException(string message) : base(message) { } + } + + /// + /// + /// + public class LLSDSerializeException : Exception + { + public LLSDSerializeException(string message) : base(message) { } + } + + /// + /// + /// + /// + /// + public static object LLSDDeserialize(byte[] b) + { + return LLSDDeserialize(new MemoryStream(b, false)); + } + + /// + /// + /// + /// + /// + public static object LLSDDeserialize(Stream st) + { + XmlTextReader reader = new XmlTextReader(st); + reader.Read(); + SkipWS(reader); + + if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd") + throw new LLSDParseException("Expected "); + + reader.Read(); + object ret = LLSDParseOne(reader); + SkipWS(reader); + + if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd") + throw new LLSDParseException("Expected "); + + return ret; + } + + /// + /// + /// + /// + /// + public static byte[] LLSDSerialize(object obj) + { + StringWriter sw = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(sw); + writer.Formatting = Formatting.None; + + writer.WriteStartElement(String.Empty, "llsd", String.Empty); + LLSDWriteOne(writer, obj); + writer.WriteEndElement(); + + writer.Close(); + + return Encoding.UTF8.GetBytes(sw.ToString()); + } + + /// + /// + /// + /// + /// + public static void LLSDWriteOne(XmlTextWriter writer, object obj) + { + if (obj == null) + { + writer.WriteStartElement(String.Empty, "undef", String.Empty); + writer.WriteEndElement(); + return; + } + + if (obj is string) + { + writer.WriteStartElement(String.Empty, "string", String.Empty); + writer.WriteString((string)obj); + writer.WriteEndElement(); + } + else if (obj is int) + { + writer.WriteStartElement(String.Empty, "integer", String.Empty); + writer.WriteString(obj.ToString()); + writer.WriteEndElement(); + } + else if (obj is double) + { + writer.WriteStartElement(String.Empty, "real", String.Empty); + writer.WriteString(obj.ToString()); + writer.WriteEndElement(); + } + else if (obj is bool) + { + bool b = (bool)obj; + writer.WriteStartElement(String.Empty, "boolean", String.Empty); + writer.WriteString(b ? "1" : "0"); + writer.WriteEndElement(); + } + else if (obj is ulong) + { + throw new Exception("ulong in LLSD is currently not implemented, fix me!"); + } + else if (obj is LLUUID) + { + LLUUID u = (LLUUID)obj; + writer.WriteStartElement(String.Empty, "uuid", String.Empty); + writer.WriteString(u.ToStringHyphenated()); + writer.WriteEndElement(); + } + else if (obj is Hashtable) + { + Hashtable h = obj as Hashtable; + writer.WriteStartElement(String.Empty, "map", String.Empty); + foreach (string key in h.Keys) + { + writer.WriteStartElement(String.Empty, "key", String.Empty); + writer.WriteString(key); + writer.WriteEndElement(); + LLSDWriteOne(writer, h[key]); + } + writer.WriteEndElement(); + } + else if (obj is ArrayList) + { + ArrayList a = obj as ArrayList; + writer.WriteStartElement(String.Empty, "array", String.Empty); + foreach (object item in a) + { + LLSDWriteOne(writer, item); + } + writer.WriteEndElement(); + } + else if (obj is byte[]) + { + byte[] b = obj as byte[]; + writer.WriteStartElement(String.Empty, "binary", String.Empty); + + writer.WriteStartAttribute(String.Empty, "encoding", String.Empty); + writer.WriteString("base64"); + writer.WriteEndAttribute(); + + //// Calculate the length of the base64 output + //long length = (long)(4.0d * b.Length / 3.0d); + //if (length % 4 != 0) length += 4 - (length % 4); + + //// Create the char[] for base64 output and fill it + //char[] tmp = new char[length]; + //int i = Convert.ToBase64CharArray(b, 0, b.Length, tmp, 0); + + //writer.WriteString(new String(tmp)); + + writer.WriteString(Convert.ToBase64String(b)); + writer.WriteEndElement(); + } + else + { + throw new LLSDSerializeException("Unknown type " + obj.GetType().Name); + } + } + + /// + /// + /// + /// + /// + public static object LLSDParseOne(XmlTextReader reader) + { + SkipWS(reader); + if (reader.NodeType != XmlNodeType.Element) + throw new LLSDParseException("Expected an element"); + + string dtype = reader.LocalName; + object ret = null; + + switch (dtype) + { + case "undef": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return null; + } + + reader.Read(); + SkipWS(reader); + ret = null; + break; + } + case "boolean": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return false; + } + + reader.Read(); + string s = reader.ReadString().Trim(); + + if (s == String.Empty || s == "false" || s == "0") + ret = false; + else if (s == "true" || s == "1") + ret = true; + else + throw new LLSDParseException("Bad boolean value " + s); + + break; + } + case "integer": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return 0; + } + + reader.Read(); + ret = Convert.ToInt32(reader.ReadString().Trim()); + break; + } + case "real": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return 0.0f; + } + + reader.Read(); + ret = Convert.ToDouble(reader.ReadString().Trim()); + break; + } + case "uuid": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return LLUUID.Zero; + } + + reader.Read(); + ret = new LLUUID(reader.ReadString().Trim()); + break; + } + case "string": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return String.Empty; + } + + reader.Read(); + ret = reader.ReadString(); + break; + } + case "binary": + { + if (reader.IsEmptyElement) + { + reader.Read(); + return new byte[0]; + } + + if (reader.GetAttribute("encoding") != null && + reader.GetAttribute("encoding") != "base64") + { + throw new LLSDParseException("Unknown encoding: " + reader.GetAttribute("encoding")); + } + + reader.Read(); + FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); + byte[] inp = Encoding.ASCII.GetBytes(reader.ReadString()); + ret = b64.TransformFinalBlock(inp, 0, inp.Length); + break; + } + case "date": + { + reader.Read(); + throw new Exception("LLSD TODO: date"); + } + case "map": + { + return LLSDParseMap(reader); + } + case "array": + { + return LLSDParseArray(reader); + } + default: + throw new LLSDParseException("Unknown element <" + dtype + ">"); + } + + if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != dtype) + { + throw new LLSDParseException("Expected "); + } + + reader.Read(); + return ret; + } + + /// + /// + /// + /// + /// + public static Hashtable LLSDParseMap(XmlTextReader reader) + { + Hashtable ret = new Hashtable(); + + if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "map") + throw new LLSDParseException("Expected "); + + if (reader.IsEmptyElement) + { + reader.Read(); + return ret; + } + + reader.Read(); + + while (true) + { + SkipWS(reader); + if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "map") + { + reader.Read(); + break; + } + + if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "key") + throw new LLSDParseException("Expected "); + + string key = reader.ReadString(); + + if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "key") + throw new LLSDParseException("Expected "); + + reader.Read(); + object val = LLSDParseOne(reader); + ret[key] = val; + } + + return ret; // TODO + } + + /// + /// + /// + /// + /// + public static ArrayList LLSDParseArray(XmlTextReader reader) + { + ArrayList ret = new ArrayList(); + + if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "array") + throw new LLSDParseException("Expected "); + + if (reader.IsEmptyElement) + { + reader.Read(); + return ret; + } + + reader.Read(); + + while (true) + { + SkipWS(reader); + + if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "array") + { + reader.Read(); + break; + } + + ret.Insert(ret.Count, LLSDParseOne(reader)); + } + + return ret; // TODO + } + + /// + /// + /// + /// + /// + private static string GetSpaces(int count) + { + StringBuilder b = new StringBuilder(); + for (int i = 0; i < count; i++) b.Append(" "); + return b.ToString(); + } + + /// + /// + /// + /// + /// + /// + public static String LLSDDump(object obj, int indent) + { + if (obj == null) + { + return GetSpaces(indent) + "- undef\n"; + } + else if (obj is string) + { + return GetSpaces(indent) + "- string \"" + (string)obj + "\"\n"; + } + else if (obj is int) + { + return GetSpaces(indent) + "- integer " + obj.ToString() + "\n"; + } + else if (obj is double) + { + return GetSpaces(indent) + "- float " + obj.ToString() + "\n"; + } + else if (obj is LLUUID) + { + return GetSpaces(indent) + "- uuid " + ((LLUUID)obj).ToStringHyphenated() + Environment.NewLine; + } + else if (obj is Hashtable) + { + StringBuilder ret = new StringBuilder(); + ret.Append(GetSpaces(indent) + "- map" + Environment.NewLine); + Hashtable map = (Hashtable)obj; + + foreach (string key in map.Keys) + { + ret.Append(GetSpaces(indent + 2) + "- key \"" + key + "\"" + Environment.NewLine); + ret.Append(LLSDDump(map[key], indent + 3)); + } + + return ret.ToString(); + } + else if (obj is ArrayList) + { + StringBuilder ret = new StringBuilder(); + ret.Append(GetSpaces(indent) + "- array\n"); + ArrayList list = (ArrayList)obj; + + foreach (object item in list) + { + ret.Append(LLSDDump(item, indent + 2)); + } + + return ret.ToString(); + } + else if (obj is byte[]) + { + return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[])obj, GetSpaces(indent)) + + Environment.NewLine; + } + else + { + return GetSpaces(indent) + "- unknown type " + obj.GetType().Name + Environment.NewLine; + } + } + + public static object ParseTerseLLSD(string llsd) + { + int notused; + return ParseTerseLLSD(llsd, out notused); + } + + public static object ParseTerseLLSD(string llsd, out int endPos) + { + if (llsd.Length == 0) + { + endPos = 0; + return null; + } + + // Identify what type of object this is + switch (llsd[0]) + { + case '!': + throw new LLSDParseException("Undefined value type encountered"); + case '1': + endPos = 1; + return true; + case '0': + endPos = 1; + return false; + case 'i': + { + if (llsd.Length < 2) throw new LLSDParseException("Integer value type with no value"); + int value; + endPos = FindEnd(llsd, 1); + + if (Int32.TryParse(llsd.Substring(1, endPos - 1), out value)) + return value; + else + throw new LLSDParseException("Failed to parse integer value type"); + } + case 'r': + { + if (llsd.Length < 2) throw new LLSDParseException("Real value type with no value"); + double value; + endPos = FindEnd(llsd, 1); + + if (Double.TryParse(llsd.Substring(1, endPos - 1), System.Globalization.NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat, out value)) + return value; + else + throw new LLSDParseException("Failed to parse double value type"); + } + case 'u': + { + if (llsd.Length < 17) throw new LLSDParseException("LLUUID value type with no value"); + LLUUID value; + endPos = FindEnd(llsd, 1); + + if (LLUUID.TryParse(llsd.Substring(1, endPos - 1), out value)) + return value; + else + throw new LLSDParseException("Failed to parse LLUUID value type"); + } + case 'b': + //byte[] value = new byte[llsd.Length - 1]; + // This isn't the actual binary LLSD format, just the terse format sent + // at login so I don't even know if there is a binary type + throw new LLSDParseException("Binary value type is unimplemented"); + case 's': + case 'l': + if (llsd.Length < 2) throw new LLSDParseException("String value type with no value"); + endPos = FindEnd(llsd, 1); + return llsd.Substring(1, endPos - 1); + case 'd': + // Never seen one before, don't know what the format is + throw new LLSDParseException("Date value type is unimplemented"); + case '[': + { + if (llsd.IndexOf(']') == -1) throw new LLSDParseException("Invalid array"); + + int pos = 0; + ArrayList array = new ArrayList(); + + while (llsd[pos] != ']') + { + ++pos; + + // Advance past comma if need be + if (llsd[pos] == ',') ++pos; + + // Allow a single whitespace character + if (pos < llsd.Length && llsd[pos] == ' ') ++pos; + + int end; + array.Add(ParseTerseLLSD(llsd.Substring(pos), out end)); + pos += end; + } + + endPos = pos + 1; + return array; + } + case '{': + { + if (llsd.IndexOf('}') == -1) throw new LLSDParseException("Invalid map"); + + int pos = 0; + Hashtable hashtable = new Hashtable(); + + while (llsd[pos] != '}') + { + ++pos; + + // Advance past comma if need be + if (llsd[pos] == ',') ++pos; + + // Allow a single whitespace character + if (pos < llsd.Length && llsd[pos] == ' ') ++pos; + + if (llsd[pos] != '\'') throw new LLSDParseException("Expected a map key"); + int endquote = llsd.IndexOf('\'', pos + 1); + if (endquote == -1 || (endquote + 1) >= llsd.Length || llsd[endquote + 1] != ':') + throw new LLSDParseException("Invalid map format"); + string key = llsd.Substring(pos, endquote - pos); + key = key.Replace("'", String.Empty); + pos += (endquote - pos) + 2; + + int end; + hashtable.Add(key, ParseTerseLLSD(llsd.Substring(pos), out end)); + pos += end; + } + + endPos = pos + 1; + return hashtable; + } + default: + throw new Exception("Unknown value type"); + } + } + + private static int FindEnd(string llsd, int start) + { + int end = llsd.IndexOfAny(new char[] { ',', ']', '}' }); + if (end == -1) end = llsd.Length - 1; + return end; + } + + /// + /// + /// + /// + private static void SkipWS(XmlTextReader reader) + { + while ( + reader.NodeType == XmlNodeType.Comment || + reader.NodeType == XmlNodeType.Whitespace || + reader.NodeType == XmlNodeType.SignificantWhitespace || + reader.NodeType == XmlNodeType.XmlDeclaration) + { + reader.Read(); + } + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index 35caa15..c50d0a9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -34,10 +34,11 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - // public string RequestTextureDownload = ""; + // public string RequestTextureDownload = ""; // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; + // public string UpdateScriptTaskInventory = ""; // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 793c366..99a8f35 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -76,8 +76,9 @@ namespace OpenSim.Region.Capabilities writer.WriteStartElement(String.Empty, "key", String.Empty); writer.WriteString(fields[i].Name); writer.WriteEndElement(); - libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); + LLSD.LLSDWriteOne(writer, fieldValue); + // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); } } writer.WriteEndElement(); @@ -100,12 +101,13 @@ namespace OpenSim.Region.Capabilities } else { - libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); + LLSD.LLSDWriteOne(writer, obj); + //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); } } - - public static object DeserialiseLLSDMap(libsecondlife.StructuredData.LLSDMap llsd, object obj) + + public static object DeserialiseLLSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -120,10 +122,12 @@ namespace OpenSim.Region.Capabilities FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { - if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) + // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) + if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); + DeserialiseLLSDMap((Hashtable)enumerator.Value, fieldValue); + // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index ed25e71..71cc358 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -54,8 +54,10 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) - libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); + // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) + // libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); + + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); -- cgit v1.1 From 0855066968e30a9965088c14234b2bc93daf0481 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Sat, 8 Dec 2007 14:27:12 +0000 Subject: This patch fixes mantis 105. Basically, it stops the index exception when no root folder is found and it makes the user server wait longer for the inventory server to do its work. From Justin Casey (IBM) --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 091d829..e86eaac 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -82,10 +82,12 @@ namespace OpenSim.Framework.Communications /// public List RequestFirstLevelFolders(LLUUID userID) { - List inventoryList = new List(); + List inventoryList = new List(); + InventoryFolderBase rootFolder = null; + foreach (KeyValuePair plugin in m_plugins) { - InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID); + rootFolder = plugin.Value.getUserRootFolder(userID); if (rootFolder != null) { inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); @@ -93,6 +95,13 @@ namespace OpenSim.Framework.Communications return inventoryList; } } + + if (null == rootFolder) + { + MainLog.Instance.Warn( + "INVENTORY", "Could not find a root folder belonging to user with ID " + userID); + } + return inventoryList; } @@ -235,4 +244,4 @@ namespace OpenSim.Framework.Communications public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} \ No newline at end of file +} -- cgit v1.1 From 383eccc543e402710bb48802c6951b94d185a6a8 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sat, 8 Dec 2007 20:41:37 +0000 Subject: hackish code to allow emptying of trash. This really should be done on the inventory server, and not from the region. Also: it appeared to work the first try, so I have probably done something horribly wrong. --- .../Cache/UserProfileCacheService.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index fb4c3a6..342bb0d 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, + public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { InventoryFolderImpl fold = null; @@ -181,6 +181,26 @@ namespace OpenSim.Framework.Communications.Cache } } + public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) + { + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); + if (subFolder != null) + { + List items=subFolder.RequestListOfItems(); + foreach(InventoryItemBase item in items) + { + userProfile.DeleteItem(remoteClient.AgentId, item); + } + } + } + } + } + public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) { if (ownerID == libraryRoot.agentID) -- cgit v1.1 From f2b175ef08066649a13b6a42f0a59d9bee503638 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 9 Dec 2007 05:59:49 +0000 Subject: * Added some inter-region comms glue for allowing sims to chat amongst themsevles about an agent behind the agent's back. * Will be using this glue Tomorrow/today to tell other regions what the agent's draw distance is and what region they're actually in so the region can make decisions on what prim to send, if any. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index e025223..e20c627 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); bool RegionUp(SearializableRegionInfo region, ulong regionhandle); + bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); -- cgit v1.1 From af6eb67999875f12270ef19ed33c179556696754 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 10 Dec 2007 05:25:16 +0000 Subject: saved OpenSim source code from the giant rampaging unterminated copyright notice of doom --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServer.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 4 ++-- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ++-- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 2 +- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 4 ++-- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDArray.cs | 4 ++-- .../Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDTest.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDType.cs | 4 ++-- OpenSim/Framework/Communications/CommunicationsManager.cs | 4 ++-- OpenSim/Framework/Communications/IGridServices.cs | 4 ++-- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 4 ++-- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 4 ++-- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 24 files changed, 44 insertions(+), 44 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index cb8b9f6..d5ac67b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -821,4 +821,4 @@ namespace OpenSim.Framework.Communications.Cache Callback = callback; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index fa421c7..e5cceaa 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -145,4 +145,4 @@ namespace OpenSim.Framework.Communications.Cache return (asset.UUID == _findID); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index cbf63ca..580c56a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -106,4 +106,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 9bc24e7..f972368 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -421,4 +421,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 81ee29b..a547c8a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -130,4 +130,4 @@ namespace OpenSim.Framework.Communications.Cache return result; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 580e528..e2924a4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -13,7 +13,7 @@ * 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 +* 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 diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index fd029cd..c07a15b 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -13,7 +13,7 @@ * 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 +* 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 diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index b4f29db..9d08785 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -115,4 +115,4 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 342bb0d..70aec47 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -13,7 +13,7 @@ * 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 +* 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 diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index dd30e9f..e439ed8 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -515,4 +515,4 @@ namespace OpenSim.Region.Capabilities } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 2ed7750..2bc1643 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index d054386..307e3e3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -41,4 +41,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index 06afac4..eb76d64 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 69c525c..101d9c0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -34,4 +34,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 99a8f35..60aa60c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -13,7 +13,7 @@ * 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 +* 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 diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 683e479..214b9c7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 1945a6c..48130b1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index c2a6054..70bfd2c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index a90ae03..7bbe16e 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -52,4 +52,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bfdd118..4614756 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -181,4 +181,4 @@ namespace OpenSim.Framework.Communications #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index b67db89..240d9c0 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -40,4 +40,4 @@ namespace OpenSim.Framework.Communications List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index e20c627..3aa20a3 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -47,4 +47,4 @@ namespace OpenSim.Framework.Communications void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index a812ac9..fd8ce38 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 88214cd..b901008 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -13,7 +13,7 @@ * 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 +* 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 @@ -398,4 +398,4 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); public abstract UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid); } -} \ No newline at end of file +} -- cgit v1.1 From 611327e1040fa706665c543f67f9331a7e0136c5 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 10 Dec 2007 13:27:23 +0000 Subject: more work on texture downloading. Refractored the TextureDownloadModule (but currently to make debugging easier, it is running as a non shared module, so this results in a instance of this module being created for each region (and a extra thread per region), this will be changed back soon. Removed the old texture handling/sending code from AssetCache. A few other small changes/fixes. --- .../Framework/Communications/Cache/AssetCache.cs | 303 +++------------------ .../Cache/AssetTransactionManager.cs | 4 +- .../Communications/Cache/AssetTransactions.cs | 127 ++++----- .../Framework/Communications/Capabilities/LLSD.cs | 2 +- 4 files changed, 107 insertions(+), 329 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d5ac67b..c164f0c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -36,8 +36,7 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { - public delegate void DownloadComplete(AssetCache.TextureSender sender); - + public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); /// @@ -57,21 +56,11 @@ namespace OpenSim.Framework.Communications.Cache public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server - public Dictionary SendingTextures = new Dictionary(); - public Dictionary RequestLists = new Dictionary(); - private BlockingQueue m_queueTextures = new BlockingQueue(); - private Dictionary> m_avatarReceivedTextures = new Dictionary>(); - - private Dictionary> m_timesTextureSent = - new Dictionary>(); - - private IAssetServer m_assetServer; private Thread m_assetCacheThread; - private Thread m_textureSenderThread; private LogBase m_log; /// @@ -88,9 +77,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetCacheThread.IsBackground = true; m_assetCacheThread.Start(); - m_textureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); - m_textureSenderThread.IsBackground = true; - m_textureSenderThread.Start(); + m_log = log; } @@ -104,7 +91,6 @@ namespace OpenSim.Framework.Communications.Cache try { ProcessAssetQueue(); - ProcessTextureQueue(); Thread.Sleep(500); } catch (Exception e) @@ -188,7 +174,7 @@ namespace OpenSim.Framework.Communications.Cache if (asset.Type == 0) { - if(Textures.ContainsKey(asset.FullID)) + if (Textures.ContainsKey(asset.FullID)) { result = "Duplicate ignored."; } @@ -250,67 +236,7 @@ namespace OpenSim.Framework.Communications.Cache return asset; } - /// - /// - /// - private void ProcessTextureQueue() - { - if (TextureRequests.Count == 0) - { - //no requests waiting - return; - } - int num; - num = TextureRequests.Count; - AssetRequest req; - for (int i = 0; i < num; i++) - { - req = (AssetRequest) TextureRequests[i]; - if (!SendingTextures.ContainsKey(req.ImageInfo.FullID)) - { - //Console.WriteLine("new texture to send"); - TextureSender sender = new TextureSender(req); - //sender.OnComplete += this.TextureSent; - SendingTextures.Add(req.ImageInfo.FullID, sender); - m_queueTextures.Enqueue(sender); - } - } - - TextureRequests.Clear(); - } - - public void ProcessTextureSenders() - { - while (true) - { - TextureSender sender = m_queueTextures.Dequeue(); - - bool finished = sender.SendTexture(); - if (finished) - { - TextureSent(sender); - } - else - { - // Console.WriteLine("readding texture"); - m_queueTextures.Enqueue(sender); - } - } - } - - /// - /// Event handler, called by a TextureSender object to say that texture has been sent - /// - /// - public void TextureSent(TextureSender sender) - { - if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) - { - SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.m_avatarReceivedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); - } - } public void AssetReceived(AssetBase asset, bool IsTexture) { @@ -354,7 +280,7 @@ namespace OpenSim.Framework.Communications.Cache if (assetInf.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int) (assetInf.Data.Length - 600 + 999)/1000; + req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; } else { @@ -400,6 +326,20 @@ namespace OpenSim.Framework.Communications.Cache //} } + private int CalculateNumPackets(int length) + { + int numPackets = 1; + + if (length > 600) + { + //over 600 bytes so split up file + int restData = (length - 600); + int restPackets = ((restData + 999) / 1000); + numPackets = 1 + restPackets; + } + + return numPackets; + } #region Assets /// @@ -458,7 +398,7 @@ namespace OpenSim.Framework.Communications.Cache if (asset.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int) (asset.Data.Length - 600 + 999)/1000; + req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; } else { @@ -473,6 +413,7 @@ namespace OpenSim.Framework.Communications.Cache /// private void ProcessAssetQueue() { + //should move the asset downloading to a module, like has been done with texture downloading if (AssetRequests.Count == 0) { //no requests waiting @@ -492,7 +433,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest) AssetRequests[i]; + req = (AssetRequest)AssetRequests[i]; //Console.WriteLine("sending asset " + req.RequestAssetID); TransferInfoPacket Transfer = new TransferInfoPacket(); Transfer.TransferInfo.ChannelType = 2; @@ -502,7 +443,7 @@ namespace OpenSim.Framework.Communications.Cache { Transfer.TransferInfo.Params = new byte[20]; Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int) req.AssetInf.Type; + int assType = (int)req.AssetInf.Type; Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); } else if (req.AssetRequestSource == 3) @@ -512,9 +453,9 @@ namespace OpenSim.Framework.Communications.Cache //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } - Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; + Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; - req.RequestUser.OutPacket(Transfer,ThrottleOutPacketType.Asset); + req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); if (req.NumPackets == 1) { @@ -573,79 +514,6 @@ namespace OpenSim.Framework.Communications.Cache #endregion - #region Textures - - /// - /// - /// - /// - /// - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) - { - // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); - //check to see if texture is in local cache, if not request from asset server - if (!m_avatarReceivedTextures.ContainsKey(userInfo.AgentId)) - { - m_avatarReceivedTextures.Add(userInfo.AgentId, new List()); - } - /* if(this.m_avatarReceivedTextures[userInfo.AgentId].Contains(imageID)) - { - //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); - return; - }*/ - - if (!Textures.ContainsKey(imageID)) - { - if (!RequestedTextures.ContainsKey(imageID)) - { - //not is cache so request from asset server - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = imageID; - request.IsTextureRequest = true; - request.DiscardLevel = discard; - RequestedTextures.Add(imageID, request); - m_assetServer.RequestAsset(imageID, true); - } - return; - } - - // System.Console.WriteLine("texture already in cache"); - TextureImage imag = Textures[imageID]; - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = imageID; - req.IsTextureRequest = true; - req.ImageInfo = imag; - req.DiscardLevel = discard; - - req.NumPackets = CalculateNumPackets(imag.Data.Length); - - if (packetNumber != 0) - { - req.PacketCounter = (int) packetNumber; - } - - TextureRequests.Add(req); - } - - private int CalculateNumPackets(int length) - { - int numPackets = 1; - - if (length > 600) - { - //over 600 bytes so split up file - int restData = (length - 600); - int restPackets = ((restData+999)/1000); - numPackets = 1 + restPackets; - } - - return numPackets; - } - - #endregion - public class AssetRequest { public IClientAPI RequestUser; @@ -702,123 +570,28 @@ namespace OpenSim.Framework.Communications.Cache } } - public class TextureSender - { - public AssetRequest request; - private int counter = 0; - - public TextureSender(AssetRequest req) - { - request = req; - } - - public bool SendTexture() - { - SendPacket(); - counter++; - - if ((request.PacketCounter >= request.NumPackets) || counter > 100 || (request.NumPackets == 1) || - (request.DiscardLevel == -1)) - { - return true; - } - return false; - } - public void SendPacket() - { - AssetRequest req = request; - //Console.WriteLine("sending " + req.ImageInfo.FullID); - if (req.PacketCounter == 0) - { - //first time for this request so send imagedata packet - if (req.NumPackets == 1) - { - //Console.WriteLine("only one packet so send whole file"); - ImageDataPacket im = new ImageDataPacket(); - im.Header.Reliable = false; - 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, ThrottleOutPacketType.Texture); - req.PacketCounter++; - //req.ImageInfo.l= time; - //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); - //Console.WriteLine("sending single packet for " + req.ImageInfo.FullID.ToStringHyphenated()); - } - else - { - //more than one packet so split file up - ImageDataPacket im = new ImageDataPacket(); - im.Header.Reliable = false; - 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, ThrottleOutPacketType.Texture); - - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent first packet of texture: " + req.ImageInfo.FullID); - //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.Header.Reliable = false; - 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; - //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); - 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, ThrottleOutPacketType.Texture); - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID); - } - } + public class AssetRequestsList + { + public LLUUID AssetID; + public List Requests = new List(); - private void SaveAssetToFile(string filename, byte[] data) + public AssetRequestsList(LLUUID assetID) { - FileStream fs = File.Create(filename); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); + AssetID = assetID; } } - } - - public class AssetRequestsList - { - public LLUUID AssetID; - public List Requests = new List(); - public AssetRequestsList(LLUUID assetID) + public class NewAssetRequest { - AssetID = assetID; - } - } - - public class NewAssetRequest - { - public LLUUID AssetID; - public AssetRequestCallback Callback; + public LLUUID AssetID; + public AssetRequestCallback Callback; - public NewAssetRequest(LLUUID assetID, AssetRequestCallback callback) - { - AssetID = assetID; - Callback = callback; + public NewAssetRequest(LLUUID assetID, AssetRequestCallback callback) + { + AssetID = assetID; + Callback = callback; + } } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 580c56a..7de84fa 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Communications.Cache } public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, - byte[] data, bool storeLocal) + byte[] data, bool storeLocal, bool tempFile) { // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { - uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal); + uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index f972368..51b80e5 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -113,66 +113,6 @@ namespace OpenSim.Framework.Communications.Cache } // Nested Types - public class AssetCapsUploader - { - // Fields - private BaseHttpServer httpListener; - private LLUUID inventoryItemID; - private string m_assetDescription = ""; - private string m_assetName = ""; - private LLUUID m_folderID; - private LLUUID newAssetID; - private bool m_dumpImageToFile; - private string uploaderPath = ""; - - // Events - public event UpLoadedAsset OnUpLoad; - - // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, - LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) - { - m_assetName = assetName; - m_assetDescription = assetDescription; - m_folderID = folderID; - newAssetID = assetID; - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - m_dumpImageToFile = dumpImageToFile; - } - - private void SaveImageToFile(string filename, byte[] data) - { - FileStream output = File.Create(filename); - BinaryWriter writer = new BinaryWriter(output); - writer.Write(data); - writer.Close(); - output.Close(); - } - - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inventoryItemID = this.inventoryItemID; - string text = ""; - LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = newAssetID.ToStringHyphenated(); - complete.new_inventory_item = inventoryItemID; - complete.state = "complete"; - text = LLSDHelpers.SerialiseLLSDReply(complete); - httpListener.RemoveStreamHandler("POST", uploaderPath); - if (m_dumpImageToFile) - { - SaveImageToFile(m_assetName + ".jp2", data); - } - if (OnUpLoad != null) - { - OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); - } - return text; - } - } - public class AssetXferUploader { // Fields @@ -230,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache } public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, - bool storeLocal) + bool storeLocal, bool tempFile) { ourClient = remoteClient; Asset = new AssetBase(); @@ -240,6 +180,9 @@ namespace OpenSim.Framework.Communications.Cache Asset.Data = data; Asset.Name = "blank"; Asset.Description = "empty"; + Asset.Local = storeLocal; + Asset.Temporary = tempFile; + TransactionID = transaction; m_storeLocal = storeLocal; if (Asset.Data.Length > 2) @@ -368,6 +311,67 @@ namespace OpenSim.Framework.Communications.Cache } } + #region Nested Classes currently not in use (waiting for them to be enabled) + public class AssetCapsUploader + { + // Fields + private BaseHttpServer httpListener; + private LLUUID inventoryItemID; + private string m_assetDescription = ""; + private string m_assetName = ""; + private LLUUID m_folderID; + private LLUUID newAssetID; + private bool m_dumpImageToFile; + private string uploaderPath = ""; + + // Events + public event UpLoadedAsset OnUpLoad; + + // Methods + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, + LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) + { + m_assetName = assetName; + m_assetDescription = assetDescription; + m_folderID = folderID; + newAssetID = assetID; + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; + m_dumpImageToFile = dumpImageToFile; + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream output = File.Create(filename); + BinaryWriter writer = new BinaryWriter(output); + writer.Write(data); + writer.Close(); + output.Close(); + } + + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inventoryItemID = this.inventoryItemID; + string text = ""; + LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); + complete.new_asset = newAssetID.ToStringHyphenated(); + complete.new_inventory_item = inventoryItemID; + complete.state = "complete"; + text = LLSDHelpers.SerialiseLLSDReply(complete); + httpListener.RemoveStreamHandler("POST", uploaderPath); + if (m_dumpImageToFile) + { + SaveImageToFile(m_assetName + ".jp2", data); + } + if (OnUpLoad != null) + { + OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); + } + return text; + } + } + public class NoteCardCapsUpdate { // Fields @@ -420,5 +424,6 @@ namespace OpenSim.Framework.Communications.Cache return text; } } + #endregion } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 60b5f75..4efeeb1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -10,7 +10,7 @@ using System.Text; namespace OpenSim.Region.Capabilities { /// - /// + /// Borrowed from (a older version of ) libsl for now, as their new llsd code doesn't work we our decoding code. /// public static class LLSD { -- cgit v1.1 From 712efda9b9cb45f93a1d310fc8ef76479fde0846 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 11 Dec 2007 01:26:06 +0000 Subject: added copyright notices --- .../Communications/Cache/AssetServerBase.cs | 28 ++++++++++++++++++++ .../Framework/Communications/Capabilities/LLSD.cs | 30 +++++++++++++++++++++- .../RestClient/GenericAsyncResult.cs | 28 ++++++++++++++++++++ .../Communications/RestClient/RestClient.cs | 28 ++++++++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 1a20cee..e117c93 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.IO; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 4efeeb1..ea8ee9d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -1,4 +1,32 @@ -using System; +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; using System.Collections; using System.Collections.Generic; using System.Xml; diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index 72d8f65..b67aad9 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Threading; diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 7a23e78..5c77193 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -1,3 +1,31 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + using System; using System.Collections.Generic; using System.IO; -- cgit v1.1 From 16903ec488f53fe1bab6b4c4408dde31d03367ff Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Tue, 11 Dec 2007 03:51:32 +0000 Subject: Implementing updateinventoryfolder: Should now be able to rename folders in inventory --- .../Communications/Cache/UserProfileCacheService.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 70aec47..32d941c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -127,6 +127,26 @@ namespace OpenSim.Framework.Communications.Cache } } + public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID) + { + CachedUserInfo userProfile; + + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + InventoryFolderBase baseFolder = new InventoryFolderBase(); + baseFolder.agentID = remoteClient.AgentId; + baseFolder.folderID = folderID; + baseFolder.name = name; + baseFolder.parentID = parentID; + baseFolder.type = (short)type; + baseFolder.version = userProfile.RootFolder.version; + m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); + } + } + } + /// /// Tell the client about the various child items and folders contained in the requested folder. /// -- cgit v1.1 From 8d995a5a5dd040c227b18ac8371d89f530a52194 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 13 Dec 2007 18:45:32 +0000 Subject: Minor cleanup --- OpenSim/Framework/Communications/UserManagerBase.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b901008..0e5e782 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -206,7 +206,7 @@ namespace OpenSim.Framework.UserManagement /// /// Loads a user agent by uuid (not called directly) /// - /// The agents UUID + /// The agent's UUID /// Agent profiles public UserAgentData getUserAgent(LLUUID uuid) { @@ -228,7 +228,7 @@ namespace OpenSim.Framework.UserManagement /// /// Loads a user agent by name (not called directly) /// - /// The agents name + /// The agent's name /// A user agent public UserAgentData getUserAgent(string name) { @@ -256,12 +256,11 @@ namespace OpenSim.Framework.UserManagement setUserProfile(profile); } - /// /// Loads a user agent by name (not called directly) /// - /// The agents firstname - /// The agents lastname + /// The agent's firstname + /// The agent's lastname /// A user agent public UserAgentData getUserAgent(string fname, string lname) { -- cgit v1.1 From fef8c77a8a40f150b11380cb2fd64c9f629cb42b Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 14 Dec 2007 00:54:12 +0000 Subject: patch from justincc for Mantis #163 - Opening a script in inventory longer than 1500characters can cause looping crash. --- .../Framework/Communications/Cache/AssetCache.cs | 47 +++++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c164f0c..3edc7eb 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -94,8 +94,8 @@ namespace OpenSim.Framework.Communications.Cache Thread.Sleep(500); } catch (Exception e) - { - System.Console.WriteLine(e.Message + " : " + e.StackTrace); + { + m_log.Error("ASSETCACHE", e.ToString()); } } } @@ -492,15 +492,40 @@ namespace OpenSim.Framework.Communications.Cache TransferPacket.TransferData.Status = 0; req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - 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, ThrottleOutPacketType.Asset); + int processedLength = 1000; + // libsecondlife tells us that the largest allowable chunk is 1500 bytes + // XXX Fix up this magic number (and others)! + int maxChunkSize = 1500; + int packetNumber = 1; + + while (processedLength < req.AssetInf.Data.Length) + { + TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = packetNumber; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + byte[] chunk1 = new byte[chunkSize]; + Array.Copy(req.AssetInf.Data, processedLength, chunk1, 0, chunk1.Length); + + TransferPacket.TransferData.Data = chunk1; + + // 0 indicates more packets to come, 1 indicates last packet + if (req.AssetInf.Data.Length - processedLength > maxChunkSize) + { + TransferPacket.TransferData.Status = 0; + } + else + { + TransferPacket.TransferData.Status = 1; + } + + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); + + processedLength += chunkSize; + packetNumber++; + } } } } -- cgit v1.1 From 79935881aa4ac16990625360b256aa5eebe12ce7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 14 Dec 2007 07:55:33 +0000 Subject: * Patch from Justincc that swaps out LLUUIDs for Guid on the inventory REST calls --- OpenSim/Framework/Communications/IInventoryServices.cs | 2 +- OpenSim/Framework/Communications/InventoryServiceBase.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 96bb7b3..191cdf2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -51,4 +51,4 @@ namespace OpenSim.Framework.Communications /// List RequestFirstLevelFolders(LLUUID userID); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index e86eaac..1f64187 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -74,14 +74,20 @@ namespace OpenSim.Framework.Communications } } } - + + public List RequestFirstLevelFolders(Guid rawUserID) + { + LLUUID userID = new LLUUID(rawUserID); + return RequestFirstLevelFolders(userID); + } + /// /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) /// /// /// public List RequestFirstLevelFolders(LLUUID userID) - { + { List inventoryList = new List(); InventoryFolderBase rootFolder = null; -- cgit v1.1 From 0a4a5bbcef8df5447b39c11ba52b2434a2f60be0 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 14 Dec 2007 08:47:15 +0000 Subject: * ARequest changed name to AssetRequest and moved to own file. * The AssetServerBase is now responsible for dequeueing, the server implementations merely recieves ProcessRequest( AssetRequest req ) * Catchall added around queue processing thread so thread won't abort on exceptions. --- .../Framework/Communications/Cache/AssetServer.cs | 54 +++++++------- .../Communications/Cache/AssetServerBase.cs | 25 ++++++- .../Communications/Cache/GridAssetClient.cs | 85 ++++++++++------------ .../Communications/Cache/SQLAssetServer.cs | 37 ++++------ 4 files changed, 97 insertions(+), 104 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index e5cceaa..00c2b2a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -72,37 +72,33 @@ namespace OpenSim.Framework.Communications.Cache } } - protected override void RunRequests() + protected override void ProcessRequest(AssetRequest req) { - while (true) + byte[] idata = null; + bool found = false; + AssetStorage foundAsset = null; + IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); + if (result.Count > 0) { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - ARequest req = _assetRequests.Dequeue(); - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage) result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); - } + foundAsset = (AssetStorage)result.Next(); + found = true; + } + + AssetBase asset = new AssetBase(); + if (found) + { + asset.FullID = foundAsset.UUID; + asset.Type = foundAsset.Type; + asset.InvType = foundAsset.Type; + asset.Name = foundAsset.Name; + idata = foundAsset.Data; + asset.Data = idata; + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + //asset.FullID = ; + _receiver.AssetNotFound(req.AssetID); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index e117c93..659b9c9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache public abstract class AssetServerBase : IAssetServer { protected IAssetReceiver _receiver; - protected BlockingQueue _assetRequests; + protected BlockingQueue _assetRequests; protected Thread _localAssetServerThread; protected IAssetProvider m_assetProviderPlugin; protected object syncLock = new object(); @@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); - protected abstract void RunRequests(); + protected abstract void ProcessRequest(AssetRequest req); public void LoadDefaultAssets() { @@ -64,13 +64,30 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); - _assetRequests = new BlockingQueue(); + _assetRequests = new BlockingQueue(); _localAssetServerThread = new Thread(RunRequests); _localAssetServerThread.IsBackground = true; _localAssetServerThread.Start(); } + private void RunRequests() + { + while (true) // Since it's a 'blocking queue' + { + try + { + AssetRequest req = _assetRequests.Dequeue(); + + ProcessRequest(req); + } + catch(Exception e) + { + MainLog.Instance.Error("ASSETSERVER", e.Message ); + } + } + } + public void LoadAsset(AssetBase info, bool image, string filename) { //should request Asset from storage manager @@ -97,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache public void RequestAsset(LLUUID assetID, bool isTexture) { - ARequest req = new ARequest(); + AssetRequest req = new AssetRequest(); req.AssetID = assetID; req.IsTexture = isTexture; MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID); diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index e2924a4..47104d7 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -36,7 +36,7 @@ using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications.Cache { - public class GridAssetClient : AssetServerBase + public class GridAssetClient : AssetServerBase { private string _assetServerUrl; @@ -47,53 +47,44 @@ namespace OpenSim.Framework.Communications.Cache #region IAssetServer Members - protected override void RunRequests() + protected override void ProcessRequest(AssetRequest req) { - while (true) + Stream s = null; + try { - ARequest req = _assetRequests.Dequeue(); + MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); - //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); + rc.RequestMethod = "GET"; + s = rc.Request(); - Stream s = null; - try + if (s.Length > 0) { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); - - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(req.AssetID.ToString()); - if (req.IsTexture) - rc.AddQueryParameter("texture"); - - rc.RequestMethod = "GET"; - s = rc.Request(); - - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase newAsset = (AssetBase)xs.Deserialize(s); - - _receiver.AssetReceived(newAsset, req.IsTexture); - } - else - { - MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString()); - _receiver.AssetNotFound(req.AssetID); - } + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + AssetBase newAsset = (AssetBase)xs.Deserialize(s); + + _receiver.AssetReceived(newAsset, req.IsTexture); } - catch (Exception e) + else { - MainLog.Instance.Error("ASSETCACHE", e.Message); - MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); - MainLog.Instance.Error("ASSETCACHE", e.StackTrace); + MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString()); + _receiver.AssetNotFound(req.AssetID); } - + } + catch (Exception e) + { + MainLog.Instance.Error("ASSETCACHE", e.Message); + MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); + MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } } - + public override void UpdateAsset(AssetBase asset) { @@ -104,18 +95,18 @@ namespace OpenSim.Framework.Communications.Cache { try { - // MemoryStream s = new MemoryStream(); + // MemoryStream s = new MemoryStream(); - // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - // xs.Serialize(s, asset); - // RestClient rc = new RestClient(_assetServerUrl); - MainLog.Instance.Verbose("ASSET", "Storing asset"); + // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + // xs.Serialize(s, asset); + // RestClient rc = new RestClient(_assetServerUrl); + MainLog.Instance.Verbose("ASSET", "Storing asset"); //rc.AddResourcePath("assets"); - // rc.RequestMethod = "POST"; - // rc.Request(s); - //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); - MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); - RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); + // rc.RequestMethod = "POST"; + // rc.Request(s); + //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); + MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); + RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); } catch (Exception e) { @@ -132,7 +123,7 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - + #endregion } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 9d08785..010581f 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache if (typeInterface != null) { IAssetProvider plug = - (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); @@ -65,12 +65,8 @@ namespace OpenSim.Framework.Communications.Cache "Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); } - - typeInterface = null; } } - - pluginAssembly = null; } @@ -81,27 +77,20 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } - protected override void RunRequests() + protected override void ProcessRequest(AssetRequest req) { - while (true) + AssetBase asset; + lock (syncLock) { - ARequest req = _assetRequests.Dequeue(); - - //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); - - AssetBase asset = null; - lock (syncLock) - { - asset = m_assetProviderPlugin.FetchAsset(req.AssetID); - } - if (asset != null) - { - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - _receiver.AssetNotFound(req.AssetID); - } + asset = m_assetProviderPlugin.FetchAsset(req.AssetID); + } + if (asset != null) + { + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + _receiver.AssetNotFound(req.AssetID); } } -- cgit v1.1 From 9ed2b262329d760d5ed52cabdcccfa59d9a1d50e Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 14 Dec 2007 15:29:51 +0000 Subject: * Just making Create public --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 2a24821..fdb2afe 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -117,7 +117,7 @@ namespace OpenSim.Framework.Communications.Cache Items.Add(item.inventoryID, item); } - private InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) + public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; -- cgit v1.1 From 4e7763f8def82f09fa7d1b2214ab337a3c4e1a90 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 14 Dec 2007 20:09:44 +0000 Subject: Thank you Justin for: 0000188: Clean up of some AssetCache.ProcessAssetQueue() code --- .../Framework/Communications/Cache/AssetCache.cs | 79 ++++++++-------------- 1 file changed, 27 insertions(+), 52 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3edc7eb..abaea23 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -469,63 +469,38 @@ namespace OpenSim.Framework.Communications.Cache } 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 = null; - if (req.AssetInf.Data.Length <= 1000) + int processedLength = 0; + // libsecondlife hardcodes 1500 as the maximum data chunk size + int maxChunkSize = 1500; + int packetNumber = 0; + + while (processedLength < req.AssetInf.Data.Length) { - chunk = new byte[req.AssetInf.Data.Length]; - Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length); - TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - } - else - { - chunk = new byte[1000]; - Array.Copy(req.AssetInf.Data, chunk, 1000); - + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = packetNumber; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + byte[] chunk = new byte[chunkSize]; + Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); + TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 0; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - int processedLength = 1000; - // libsecondlife tells us that the largest allowable chunk is 1500 bytes - // XXX Fix up this magic number (and others)! - int maxChunkSize = 1500; - int packetNumber = 1; - while (processedLength < req.AssetInf.Data.Length) + // 0 indicates more packets to come, 1 indicates last packet + if (req.AssetInf.Data.Length - processedLength > maxChunkSize) { - TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = packetNumber; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); - byte[] chunk1 = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk1, 0, chunk1.Length); - - TransferPacket.TransferData.Data = chunk1; - - // 0 indicates more packets to come, 1 indicates last packet - if (req.AssetInf.Data.Length - processedLength > maxChunkSize) - { - TransferPacket.TransferData.Status = 0; - } - else - { - TransferPacket.TransferData.Status = 1; - } - - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - processedLength += chunkSize; - packetNumber++; + TransferPacket.TransferData.Status = 0; } + else + { + TransferPacket.TransferData.Status = 1; + } + + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); + + processedLength += chunkSize; + packetNumber++; } } } -- cgit v1.1 From 0ef0c9f4fb3c7e8fb8f09a28e37b811f6b216bf4 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 14 Dec 2007 21:19:13 +0000 Subject: Thanks, Justin, for: Message to confirm inventory retrieval rather than simply relying on the absence of a not found message. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 1f64187..28b81d4 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -96,6 +96,10 @@ namespace OpenSim.Framework.Communications rootFolder = plugin.Value.getUserRootFolder(userID); if (rootFolder != null) { + MainLog.Instance.Verbose( + "INVENTORY", + "Found root folder for user with ID " + userID + ". Retrieving inventory contents."); + inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); inventoryList.Insert(0, rootFolder); return inventoryList; -- cgit v1.1 From 8a8c89a0f32b528bd588715bdbfc875c852e7187 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sat, 15 Dec 2007 04:57:14 +0000 Subject: Grid Inventory feature upgrade: renaming folders should now be correct, subfolders work, moving folders works. Tested only in MYSQL, but may work in MSSQL and sqlite. Probably not working in standalone mode. --- .../Communications/Cache/InventoryFolderImpl.cs | 10 +++++++ .../Cache/UserProfileCacheService.cs | 32 +++++++++++++++++----- .../Framework/Communications/IInventoryServices.cs | 1 + .../Communications/InventoryServiceBase.cs | 20 ++++++++++++++ 4 files changed, 56 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index c07a15b..1d2c920 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -142,5 +142,15 @@ namespace OpenSim.Framework.Communications.Cache } return itemList; } + + public List RequestListOfFolders() + { + List folderList = new List(); + foreach (InventoryFolderBase folder in SubFolders.Values) + { + folderList.Add(folder); + } + return folderList; + } } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 32d941c..bf7f5c1 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -147,6 +147,23 @@ namespace OpenSim.Framework.Communications.Cache } } + public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) + { + CachedUserInfo userProfile; + + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) + { + if (userProfile.RootFolder != null) + { + InventoryFolderBase baseFolder = new InventoryFolderBase(); + baseFolder.agentID = remoteClient.AgentId; + baseFolder.folderID = folderID; + baseFolder.parentID = parentID; + m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); + } + } + } + /// /// Tell the client about the various child items and folders contained in the requested folder. /// @@ -163,14 +180,15 @@ namespace OpenSim.Framework.Communications.Cache if (folderID == libraryRoot.folderID) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, - libraryRoot.RequestListOfItems(), libraryRoot.SubFoldersCount); + libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), libraryRoot.SubFoldersCount); return; } if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.SubFoldersCount); + System.Console.WriteLine("fetching librarysubfolder"); + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); return; } @@ -182,19 +200,19 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.RootFolder.folderID == folderID) { + System.Console.Write("fetching root folder"); if (fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.SubFoldersCount); + userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.RequestListOfFolders(), userProfile.RootFolder.SubFoldersCount); } } else { - InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(folderID); - - if (fetchItems && folder != null) + if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems(), folder.SubFoldersCount); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); + return; } } } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 191cdf2..9c493d4 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -40,6 +40,7 @@ namespace OpenSim.Framework.Communications { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); void CreateNewUserInventory(LLUUID user); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 28b81d4..1e13031 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -130,6 +130,17 @@ namespace OpenSim.Framework.Communications /// /// /// + public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.moveInventoryFolder(folder); + } + } + + /// + /// + /// /// /// public List RequestSubFolders(LLUUID parentFolderID) @@ -161,6 +172,14 @@ namespace OpenSim.Framework.Communications } } + public void MoveFolder(InventoryFolderBase folder) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.moveInventoryFolder(folder); + } + } + public void AddItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) @@ -251,6 +270,7 @@ namespace OpenSim.Framework.Communications InventoryItemInfo itemCallBack); public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -- cgit v1.1 From 019d6626068920283b700440e780c86c162ca7c6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 15 Dec 2007 21:58:07 +0000 Subject: Put out a more comprehensible message when user authentication fails than the current NullReferenceException based one --- .../Framework/Communications/UserManagerBase.cs | 63 +++++++--------------- 1 file changed, 20 insertions(+), 43 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0e5e782..a82a58d 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -37,6 +37,9 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement { + /// + /// Base class for user management (create, read, etc) + /// public abstract class UserManagerBase : IUserService { public UserConfig _config; @@ -84,22 +87,23 @@ namespace OpenSim.Framework.UserManagement /// Loads a user profile from a database by UUID /// /// The target UUID - /// A user profile + /// A user profile. Returns null if no user profile is found. public UserProfileData GetUserProfile(LLUUID uuid) { foreach (KeyValuePair plugin in _plugins) { - try + UserProfileData profile = plugin.Value.GetUserByUUID(uuid); + + if (null != profile) { - UserProfileData profile = plugin.Value.GetUserByUUID(uuid); profile.currentAgent = getUserAgent(profile.UUID); return profile; - } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } + } } + + MainLog.Instance.Notice( + "USERSTORAGE", + "Could not find user " + uuid.ToStringHyphenated() + " in persistent storage."); return null; } @@ -123,55 +127,28 @@ namespace OpenSim.Framework.UserManagement return pickerlist; } - - /// - /// Loads a user profile by name - /// - /// The target name - /// A user profile - public UserProfileData GetUserProfile(string name) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - UserProfileData profile = plugin.Value.GetUserByName(name); - profile.currentAgent = getUserAgent(profile.UUID); - return profile; - } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - /// /// Loads a user profile by name /// /// First name /// Last name - /// A user profile + /// A user profile. Returns null if no profile is found public UserProfileData GetUserProfile(string fname, string lname) { foreach (KeyValuePair plugin in _plugins) { - try - { - UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + if (profile != null) + { profile.currentAgent = getUserAgent(profile.UUID); - return profile; } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } } - + + MainLog.Instance.Notice( + "USERSTORAGE", "Could not find user " + fname + " " + lname + " in persistent storage."); + return null; } -- cgit v1.1 From 2061f55007a62c4855033b4ee0e4f83ce9694580 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 16 Dec 2007 13:57:08 +0000 Subject: Reposition 'user profile not found' messages to stop spurious messages caused by other usermanager usage This should stop the regular spurious messages in the grid user console --- OpenSim/Framework/Communications/LoginService.cs | 6 +++ .../Framework/Communications/UserManagerBase.cs | 51 ++++++++++------------ 2 files changed, 28 insertions(+), 29 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d18cf63..7c39e56 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -80,7 +80,13 @@ namespace OpenSim.Framework.UserManagement userProfile = GetTheUser(firstname, lastname); if (userProfile == null) + { + MainLog.Instance.Verbose( + "LOGIN", + "Could not find a profile for " + firstname + " " + lastname); + return logResponse.CreateLoginFailedResponse(); + } GoodLogin = AuthenticateUser(userProfile, passwd); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index a82a58d..cc540e7 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -99,11 +99,7 @@ namespace OpenSim.Framework.UserManagement profile.currentAgent = getUserAgent(profile.UUID); return profile; } - } - - MainLog.Instance.Notice( - "USERSTORAGE", - "Could not find user " + uuid.ToStringHyphenated() + " in persistent storage."); + } return null; } @@ -145,10 +141,7 @@ namespace OpenSim.Framework.UserManagement return profile; } } - - MainLog.Instance.Notice( - "USERSTORAGE", "Could not find user " + fname + " " + lname + " in persistent storage."); - + return null; } @@ -292,26 +285,26 @@ namespace OpenSim.Framework.UserManagement agent.currentPos = profile.homeLocation; // If user specified additional start, use that - if (requestData.ContainsKey("start")) - { - string startLoc = ((string) requestData["start"]).Trim(); - if (!(startLoc == "last" || startLoc == "home")) - { - // Format: uri:Ahern&162&213&34 - try - { - string[] parts = startLoc.Remove(0, 4).Split('&'); - //string region = parts[0]; - - //////////////////////////////////////////////////// - //SimProfile SimInfo = new SimProfile(); - //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); - } - catch (Exception) - { - } - } - } +// if (requestData.ContainsKey("start")) +// { +// string startLoc = ((string) requestData["start"]).Trim(); +// if (!(startLoc == "last" || startLoc == "home")) +// { +// // Format: uri:Ahern&162&213&34 +// try +// { +// string[] parts = startLoc.Remove(0, 4).Split('&'); +// //string region = parts[0]; +// +// //////////////////////////////////////////////////// +// //SimProfile SimInfo = new SimProfile(); +// //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); +// } +// catch (Exception) +// { +// } +// } +// } // What time did the user login? agent.loginTime = Util.UnixTimeSinceEpoch(); -- cgit v1.1 From 5bec7f5ff38e69800fc100b8ee57e28fa7d54ab8 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 16 Dec 2007 23:37:40 +0000 Subject: Clean up the Login message on UserServer console just before CustomizeResponse is called (this one redundant). --- OpenSim/Framework/Communications/LoginService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7c39e56..7012602 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -61,7 +61,8 @@ namespace OpenSim.Framework.UserManagement m_loginMutex.WaitOne(); try { - MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); + //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. + //CKF: MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 6702b0373371fd2a546a580ad82f5cc175fa29e0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 19 Dec 2007 08:44:25 +0000 Subject: Misc. cleanup: * added Util.Clip(value, min, max) * modified asset cache's numPackets calculation to use max packet size (600) instead of 1000 * removed a few magic numbers --- .../Framework/Communications/Cache/AssetCache.cs | 60 +++++----------------- 1 file changed, 14 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index abaea23..99356c2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -36,7 +36,6 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { - public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); /// @@ -77,7 +76,6 @@ namespace OpenSim.Framework.Communications.Cache m_assetCacheThread.IsBackground = true; m_assetCacheThread.Start(); - m_log = log; } @@ -100,7 +98,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public AssetBase GetAsset(LLUUID assetID) { AssetBase asset = null; @@ -154,7 +151,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public AssetBase GetAsset(LLUUID assetID, bool isTexture) { AssetBase asset = GetAsset(assetID); @@ -236,8 +232,6 @@ namespace OpenSim.Framework.Communications.Cache return asset; } - - 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 @@ -249,7 +243,7 @@ namespace OpenSim.Framework.Communications.Cache if (IsTexture) { - //Console.WriteLine("asset recieved from asset server"); + //Console.WriteLine("asset received from asset server"); TextureImage image = new TextureImage(asset); if (!Textures.ContainsKey(image.FullID)) @@ -260,7 +254,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req = RequestedTextures[image.FullID]; req.ImageInfo = image; - req.NumPackets = CalculateNumPackets(image.Data.Length); + req.NumPackets = CalculateNumPackets(image.Data); RequestedTextures.Remove(image.FullID); TextureRequests.Add(req); @@ -277,15 +271,7 @@ namespace OpenSim.Framework.Communications.Cache { AssetRequest req = 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; - } + req.NumPackets = CalculateNumPackets(assetInf.Data); RequestedAssets.Remove(assetInf.FullID); AssetRequests.Add(req); } @@ -326,16 +312,17 @@ namespace OpenSim.Framework.Communications.Cache //} } - private int CalculateNumPackets(int length) + private int CalculateNumPackets(byte[] data) { + const uint m_maxPacketSize = 600; int numPackets = 1; - if (length > 600) + if (data.LongLength > m_maxPacketSize) { - //over 600 bytes so split up file - int restData = (length - 600); - int restPackets = ((restData + 999) / 1000); - numPackets = 1 + restPackets; + // over max number of bytes so split up file + long restData = data.LongLength - m_maxPacketSize; + int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize); + numPackets += restPackets; } return numPackets; @@ -385,8 +372,7 @@ namespace OpenSim.Framework.Communications.Cache //it is in our cache AssetInfo asset = Assets[requestID]; - //work out how many packets it should be sent in - // and add to the AssetRequests list + // add to the AssetRequests list AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; req.RequestAssetID = requestID; @@ -394,17 +380,7 @@ namespace OpenSim.Framework.Communications.Cache req.AssetRequestSource = source; req.Params = transferRequest.TransferInfo.Params; 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; - } - + req.NumPackets = CalculateNumPackets(asset.Data); AssetRequests.Add(req); } @@ -419,17 +395,9 @@ namespace OpenSim.Framework.Communications.Cache //no requests waiting return; } - int num; + // if less than 5, do all of them + int num = Math.Min(5, AssetRequests.Count); - if (AssetRequests.Count < 5) - { - //lower than 5 so do all of them - num = AssetRequests.Count; - } - else - { - num = 5; - } AssetRequest req; for (int i = 0; i < num; i++) { -- cgit v1.1 From 45567b71b8c3c6f2e52dacdda92671048bb3faf0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 19 Dec 2007 18:05:45 +0000 Subject: Refactor asset request processing for consistent status information on whether an asset was actually found or not --- .../Framework/Communications/Cache/AssetServer.cs | 8 ++--- .../Communications/Cache/AssetServerBase.cs | 37 ++++++++++++++++++++-- .../Communications/Cache/GridAssetClient.cs | 14 +++----- .../Communications/Cache/SQLAssetServer.cs | 12 ++----- 4 files changed, 46 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 00c2b2a..4ad0f60 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache } } - protected override void ProcessRequest(AssetRequest req) + protected override AssetBase _ProcessRequest(AssetRequest req) { byte[] idata = null; bool found = false; @@ -93,12 +93,12 @@ namespace OpenSim.Framework.Communications.Cache asset.Name = foundAsset.Name; idata = foundAsset.Data; asset.Data = idata; - _receiver.AssetReceived(asset, req.IsTexture); + + return asset; } else { - //asset.FullID = ; - _receiver.AssetNotFound(req.AssetID); + return null; } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 659b9c9..4d03fee 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -48,7 +48,38 @@ namespace OpenSim.Framework.Communications.Cache protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); - protected abstract void ProcessRequest(AssetRequest req); + /// + /// This method must be implemented by a subclass to retrieve the asset named in the + /// AssetRequest. If the asset is not found, null should be returned. + /// + /// + /// + protected abstract AssetBase _ProcessRequest(AssetRequest req); + + /// + /// Process an asset request. This method will call _ProcessRequest(AssetRequest req) + /// on the subclass. + /// + /// + protected void ProcessRequest(AssetRequest req) + { + AssetBase asset = _ProcessRequest(req); + + if (asset != null) + { + MainLog.Instance.Verbose( + "ASSET", "Asset {0} received from asset server", req.AssetID); + + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + MainLog.Instance.Error( + "ASSET", "Asset {0} not found by asset server", req.AssetID); + + _receiver.AssetNotFound(req.AssetID); + } + } public void LoadDefaultAssets() { @@ -117,9 +148,9 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req = new AssetRequest(); req.AssetID = assetID; req.IsTexture = isTexture; - MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID); _assetRequests.Enqueue(req); - MainLog.Instance.Verbose("ASSET","Added {0} to request queue", assetID); + + MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); } public virtual void UpdateAsset(AssetBase asset) diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 47104d7..5801aa8 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Cache #region IAssetServer Members - protected override void ProcessRequest(AssetRequest req) + protected override AssetBase _ProcessRequest(AssetRequest req) { Stream s = null; try @@ -66,14 +66,8 @@ namespace OpenSim.Framework.Communications.Cache if (s.Length > 0) { XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase newAsset = (AssetBase)xs.Deserialize(s); - - _receiver.AssetReceived(newAsset, req.IsTexture); - } - else - { - MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString()); - _receiver.AssetNotFound(req.AssetID); + + return (AssetBase)xs.Deserialize(s); } } catch (Exception e) @@ -82,6 +76,8 @@ namespace OpenSim.Framework.Communications.Cache MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } + + return null; } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 010581f..4fa7684 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -77,21 +77,15 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } - protected override void ProcessRequest(AssetRequest req) + protected override AssetBase _ProcessRequest(AssetRequest req) { AssetBase asset; lock (syncLock) { asset = m_assetProviderPlugin.FetchAsset(req.AssetID); } - if (asset != null) - { - _receiver.AssetReceived(asset, req.IsTexture); - } - else - { - _receiver.AssetNotFound(req.AssetID); - } + + return asset; } protected override void StoreAsset(AssetBase asset) -- cgit v1.1 From be2ad79e52efb5eb543057e8e73fa601d0b91c87 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 20 Dec 2007 05:43:02 +0000 Subject: Added patch from Johan. First attempt to solve the LibSL.Packet GC problem. Works with LibSL rev>1532 --- .../Framework/Communications/Cache/AssetServerBase.cs | 2 +- .../Framework/Communications/Cache/AssetTransactions.cs | 4 ++-- .../Framework/Communications/Cache/LibraryRootFolder.cs | 6 +++--- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 4 ++-- OpenSim/Framework/Communications/LoginResponse.cs | 8 ++++---- OpenSim/Framework/Communications/LoginService.cs | 16 ++++++++-------- 7 files changed, 22 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 4d03fee..f5ebab7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < source.Configs.Count; i++) { // System.Console.WriteLine("loading asset into database"); - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString()); string name = source.Configs[i].GetString("name", ""); sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 51b80e5..57c1fa6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -355,7 +355,7 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToString(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); @@ -408,7 +408,7 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToString(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index fdb2afe..ffc94bf 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -144,8 +144,8 @@ namespace OpenSim.Framework.Communications.Cache item.avatarID = libOwner; item.creatorsID = libOwner; item.inventoryID = - new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); - item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); + new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToString())); + item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); item.inventoryDescription = source.Configs[i].GetString("description", ""); item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); @@ -167,4 +167,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index e439ed8..eb678a0 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -421,7 +421,7 @@ namespace OpenSim.Region.Capabilities LLUUID inv = inventoryItemID; string res = ""; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); - uploadComplete.new_asset = newAssetID.ToStringHyphenated(); + uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; @@ -489,7 +489,7 @@ namespace OpenSim.Region.Capabilities assetID = OnUpLoad(inv, data); } - uploadComplete.new_asset = assetID.ToStringHyphenated(); + uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index ea8ee9d..987d6e6 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -159,7 +159,7 @@ namespace OpenSim.Region.Capabilities { LLUUID u = (LLUUID)obj; writer.WriteStartElement(String.Empty, "uuid", String.Empty); - writer.WriteString(u.ToStringHyphenated()); + writer.WriteString(u.ToString()); writer.WriteEndElement(); } else if (obj is Hashtable) @@ -475,7 +475,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is LLUUID) { - return GetSpaces(indent) + "- uuid " + ((LLUUID)obj).ToStringHyphenated() + Environment.NewLine; + return GetSpaces(indent) + "- uuid " + ((LLUUID)obj).ToString() + Environment.NewLine; } else if (obj is Hashtable) { diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index bce518b..ede3148 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -266,9 +266,9 @@ namespace OpenSim.Framework.UserManagement responseData["sim_port"] = (Int32) SimPort; responseData["sim_ip"] = SimAddress; - responseData["agent_id"] = AgentID.ToStringHyphenated(); - responseData["session_id"] = SessionID.ToStringHyphenated(); - responseData["secure_session_id"] = SecureSessionID.ToStringHyphenated(); + responseData["agent_id"] = AgentID.ToString(); + responseData["session_id"] = SessionID.ToString(); + responseData["secure_session_id"] = SecureSessionID.ToString(); responseData["circuit_code"] = CircuitCode; responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; responseData["login-flags"] = loginFlags; @@ -585,7 +585,7 @@ namespace OpenSim.Framework.UserManagement Hashtable hTable = new Hashtable(); hTable["buddy_rights_has"] = BuddyRightsHave; hTable["buddy_rights_given"] = BuddyRightsGiven; - hTable["buddy_id"] = BuddyID.ToStringHyphenated(); + hTable["buddy_id"] = BuddyID.ToString(); return hTable; } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7012602..58dab9b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -126,7 +126,7 @@ namespace OpenSim.Framework.UserManagement ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); userProfile.rootInventoryFolderID = inventData.RootFolderID; @@ -136,9 +136,9 @@ namespace OpenSim.Framework.UserManagement logResponse.Lastname = userProfile.surname; logResponse.Firstname = userProfile.username; - logResponse.AgentID = agentID.ToStringHyphenated(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.AgentID = agentID.ToString(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -263,7 +263,7 @@ namespace OpenSim.Framework.UserManagement //return new ArrayList(); Hashtable TempHash = new Hashtable(); TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); + TempHash["parent_id"] = LLUUID.Zero.ToString(); TempHash["version"] = 1; TempHash["type_default"] = -1; TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; @@ -305,10 +305,10 @@ namespace OpenSim.Framework.UserManagement { TempHash = new Hashtable(); TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["parent_id"] = InvFolder.ParentID.ToString(); TempHash["version"] = (Int32) InvFolder.Version; TempHash["type_default"] = (Int32) InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + TempHash["folder_id"] = InvFolder.FolderID.ToString(); AgentInventoryArray.Add(TempHash); } @@ -327,4 +327,4 @@ namespace OpenSim.Framework.UserManagement } } } -} \ No newline at end of file +} -- cgit v1.1 From 8aae9094128069b83fbf11cb77503e29fd381b25 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 20 Dec 2007 06:31:03 +0000 Subject: * Added a configuration parameter on the Grid Server to disallow forceful banlists. * Added a way for Grid based configuration parameters to (generally used in overriding functionality) to get to the regions on Registration. --- OpenSim/Framework/Communications/IGridServices.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 240d9c0..d51f234 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - +using System.Collections; using System.Collections.Generic; namespace OpenSim.Framework.Communications @@ -37,6 +37,7 @@ namespace OpenSim.Framework.Communications bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); + Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -- cgit v1.1 From 42bc256e4fdd1b978b59fba117a78899b5a25c49 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 21 Dec 2007 19:47:45 +0000 Subject: Refix bug where inventory textures don't appear in prim edit texture selection box unless previously expanded in inventory. --- .../Communications/Cache/UserProfileCacheService.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index bf7f5c1..6a7be78 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -176,11 +176,14 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + // XXX We're not handling sortOrder yet! + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, - libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), libraryRoot.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), + libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; } @@ -188,7 +191,9 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { System.Console.WriteLine("fetching librarysubfolder"); - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + libraryRoot.agentID, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } @@ -203,15 +208,19 @@ namespace OpenSim.Framework.Communications.Cache System.Console.Write("fetching root folder"); if (fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.RequestListOfFolders(), userProfile.RootFolder.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), + userProfile.RootFolder.RequestListOfFolders(), + fetchFolders, fetchItems); } } else { if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + remoteClient.AgentId, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } } -- cgit v1.1 From ed0f8bd5728d0fbe992cc4a1d164983edda654e8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 22 Dec 2007 16:45:44 +0000 Subject: minor refactor --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 99356c2..d1ff9c9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -98,7 +98,12 @@ namespace OpenSim.Framework.Communications.Cache } } - public AssetBase GetAsset(LLUUID assetID) + /// + /// Only get an asset if we already have it in the cache. + /// + /// + /// + private AssetBase GetCachedAsset(LLUUID assetID) { AssetBase asset = null; if (Textures.ContainsKey(assetID)) @@ -153,7 +158,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetBase GetAsset(LLUUID assetID, bool isTexture) { - AssetBase asset = GetAsset(assetID); + AssetBase asset = GetCachedAsset(assetID); if (asset == null) { m_assetServer.RequestAsset(assetID, isTexture); @@ -223,7 +228,7 @@ namespace OpenSim.Framework.Communications.Cache public AssetBase CopyAsset(LLUUID assetID) { - AssetBase asset = GetAsset(assetID); + AssetBase asset = GetCachedAsset(assetID); if (asset == null) return null; -- cgit v1.1 From c470efea5734e4515baaf9023f2f2b2cd724725c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 22 Dec 2007 19:48:01 +0000 Subject: Make copying of scripts into prim inventories more reliable on the first attempt when the asset server is lagging by formalising the de facto polling. This may not be the best solution in the long run, but should improve things for now. This may also improve reliability when updating inventory item metadata (e.g. renaming an item) and in retrieving textures for the main map view. --- .../Framework/Communications/Cache/AssetCache.cs | 48 ++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d1ff9c9..4765548 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -156,16 +156,58 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Get an asset. If the asset isn't in the cache, a request will be made to the persistent store to + /// load it into the cache. + /// + /// XXX We'll keep polling the cache until we get the asset or we exceed + /// the allowed number of polls. This isn't a very good way of doing things since a single thread + /// is processing inbound packets, so if the asset server is slow, we could block this for up to + /// the timeout period. What we might want to do is register asynchronous callbacks on asset + /// receipt in the same manner as the nascent (but not yet active) TextureDownloadModule. Of course, + /// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the + /// asset is much more likely to have made it into the cache. + /// + /// + /// + /// null if the asset could not be retrieved public AssetBase GetAsset(LLUUID assetID, bool isTexture) { + // I'm not going over 3 seconds since this will be blocking processing of all the other inbound + // packets from the client. + int pollPeriod = 200; + int maxPolls = 15; + AssetBase asset = GetCachedAsset(assetID); - if (asset == null) + if (asset != null) { - m_assetServer.RequestAsset(assetID, isTexture); + return asset; } - return asset; + + m_assetServer.RequestAsset(assetID, isTexture); + + do + { + Thread.Sleep(pollPeriod); + + asset = GetCachedAsset(assetID); + if (asset != null) + { + return asset; + } + } + while (--maxPolls > 0); + + MainLog.Instance.Warn( + "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); + + return null; } + /// + /// Add an asset to both the persistent store and the cache. + /// + /// public void AddAsset(AssetBase asset) { string temporary = asset.Temporary ? "temporary" : ""; -- cgit v1.1 From c545cc8cd914d6ded605fa2a195461c7aaf3a615 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 23 Dec 2007 02:14:29 +0000 Subject: Miscellaneous small tweaks and more logging messages to move towards resolving inventory problems --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 6a7be78..23bddcf 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -27,6 +27,7 @@ */ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { @@ -61,12 +62,14 @@ namespace OpenSim.Framework.Communications.Cache if (userInfo.UserProfile != null) { - RequestInventoryForUser(userID, userInfo); + // The request itself will occur when the agent finishes logging on to the region + // so there's no need to do it here. + //RequestInventoryForUser(userID, userInfo); m_userProfiles.Add(userID, userInfo); } else { - System.Console.WriteLine("CACHE", "User profile for user not found"); + MainLog.Instance.Error("USERCACHE", "User profile for user {0} not found", userID); } } } -- cgit v1.1 From 77a2755e14c2e124f664804a965357bf71fe3543 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 23 Dec 2007 11:43:46 +0000 Subject: Yet more inventory debugging messages --- .../Cache/UserProfileCacheService.cs | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 23bddcf..47f970e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -193,7 +193,6 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { - System.Console.WriteLine("fetching librarysubfolder"); remoteClient.SendInventoryFolderDetails( libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); @@ -208,14 +207,12 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.RootFolder.folderID == folderID) { - System.Console.Write("fetching root folder"); - if (fetchItems) - { - remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), - userProfile.RootFolder.RequestListOfFolders(), - fetchFolders, fetchItems); - } + remoteClient.SendInventoryFolderDetails( + remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), + userProfile.RootFolder.RequestListOfFolders(), + fetchFolders, fetchItems); + + return; } else { @@ -224,11 +221,35 @@ namespace OpenSim.Framework.Communications.Cache remoteClient.SendInventoryFolderDetails( remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); + return; } } } + else + { + MainLog.Instance.Error( + "INVENTORYCACHE", "Could not find root folder for user {0}", remoteClient.Name); + + return; + } } + else + { + MainLog.Instance.Error( + "INVENTORYCACHE", + "Could not find user profile for {0} for folder {1}", + remoteClient.Name, folderID); + + return; + } + + // If we've reached this point then we couldn't find the folder, even though the client thinks + // it exists + MainLog.Instance.Error( + "INVENTORYCACHE", + "Could not find folder {0} for user {1}", + folderID, remoteClient.Name); } public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) -- cgit v1.1 From 280a5cba8b6ab1566b1f5d2dae96e2f8402c8ab4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 24 Dec 2007 22:35:01 +0000 Subject: Prim inventory script saving phase 1. Create necessary CAPS structures for correctly accepting prim inventory script updates. No user functionality yet. Refactoring to follow. --- .../Framework/Communications/Capabilities/Caps.cs | 203 ++++++++++++++++++++- .../Communications/Capabilities/LLSDCapsDetails.cs | 2 +- .../LLSDTaskInventoryUploadComplete.cs | 50 +++++ .../Capabilities/LLSDTaskScriptUpdate.cs | 51 ++++++ .../Framework/Communications/UserManagerBase.cs | 2 +- 5 files changed, 299 insertions(+), 9 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index eb678a0..a72abbe 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -42,21 +42,29 @@ namespace OpenSim.Region.Capabilities string inventoryType, string assetType); public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); + + public delegate LLUUID UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); + + public delegate LLUUID TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, + bool isScriptRunning, byte[] data); public class Caps { private string m_httpListenerHostName; private uint 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 m_notecardTaskUpdatePath = "0005/"; + //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; private LLUUID m_agentID; @@ -65,8 +73,11 @@ namespace OpenSim.Region.Capabilities private Queue m_capsEventQueue = new Queue(); private bool m_dumpAssetsToFile; + // These are callbacks which will be setup by the scene so that we can update scene data when we + // receive capability calls public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; + public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) @@ -100,9 +111,11 @@ namespace OpenSim.Region.Capabilities AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); + AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); } - catch + catch (Exception e) { + MainLog.Instance.Error("CAPS", e.ToString()); } } @@ -117,7 +130,7 @@ namespace OpenSim.Region.Capabilities } /// - /// + /// Construct a client response detailing all the capabilities this server can provide. /// /// /// @@ -131,7 +144,7 @@ namespace OpenSim.Region.Capabilities } /// - /// + /// Return an LLSDCapsDetails listing all the capabilities this server can provide /// /// protected LLSDCapsDetails GetCapabilities() @@ -144,7 +157,7 @@ namespace OpenSim.Region.Capabilities caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; - // caps.UpdateScriptTaskInventory = capsBaseUrl + m_requestTexture; + caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath; return caps; } @@ -249,9 +262,65 @@ namespace OpenSim.Region.Capabilities } #endregion + + /// + /// Callback for a client request for an upload url for a script task + /// inventory update + /// + /// + /// + /// + /// + public string ScriptTaskInventory(string request, string path, string param) + { + try + { +// MainLog.Instance.Debug("CAPS", "request: {0}, path: {1}, param: {2}", request, path, param); + + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); + + string capsBase = "/CAPS/" + m_capsObjectPath; + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + TaskInventoryScriptUpdater uploader = + new TaskInventoryScriptUpdater( + llsdUpdateRequest.item_id, + llsdUpdateRequest.task_id, + llsdUpdateRequest.is_script_running, + capsBase + uploaderPath, + m_httpListener, + m_dumpAssetsToFile); + uploader.OnUpLoad += TaskScriptUpdated; + + m_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"; + +// MainLog.Instance.Verbose( +// "CAPS", +// "ScriptTaskInventory response: {0}", +// LLSDHelpers.SerialiseLLSDReply(uploadResponse)); + + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); + } + catch (Exception e) + { + MainLog.Instance.Error("CAPS", e.ToString()); + } + + return null; + } /// - /// + /// Callback for a client request for an upload url for a notecard (or script) + /// agent inventory update /// /// /// @@ -265,11 +334,10 @@ namespace OpenSim.Region.Capabilities LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); string capsBase = "/CAPS/" + m_capsObjectPath; - LLUUID newInvItem = llsdRequest.item_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); ItemUpdater uploader = - new ItemUpdater(newInvItem, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); + new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); uploader.OnUpLoad += ItemUpdated; m_httpListener.AddStreamHandler( @@ -281,6 +349,8 @@ namespace OpenSim.Region.Capabilities uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; + MainLog.Instance.Verbose("CAPS", "NoteCardAgentInventory response: {0}", LLSDHelpers.SerialiseLLSDReply(uploadResponse)); + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -368,12 +438,36 @@ namespace OpenSim.Region.Capabilities } } + /// + /// Called when new asset data for an agent inventory item update has been uploaded. + /// + /// Item to update + /// New asset data + /// public LLUUID ItemUpdated(LLUUID itemID, byte[] data) { if (ItemUpdatedCall != null) { return ItemUpdatedCall(m_agentID, itemID, data); } + + return LLUUID.Zero; + } + + /// + /// Called when new asset data for an agent inventory item update has been uploaded. + /// + /// Item to update + /// Prim containing item to update + /// Signals whether the script to update is currently running + /// New asset data + public LLUUID TaskScriptUpdated(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data) + { + if (TaskScriptUpdatedCall != null) + { + return TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data); + } + return LLUUID.Zero; } @@ -452,6 +546,10 @@ namespace OpenSim.Region.Capabilities } } + /// + /// This class is a callback invoked when a client sends asset data to + /// an agent inventory notecard update url + /// public class ItemUpdater { public event UpdateItem OnUpLoad; @@ -514,5 +612,96 @@ namespace OpenSim.Region.Capabilities fs.Close(); } } + + /// + /// This class is a callback invoked when a client sends asset data to + /// a task inventory script update url + /// + public class TaskInventoryScriptUpdater + { + public event UpdateTaskScript OnUpLoad; + + private string uploaderPath = ""; + private LLUUID inventoryItemID; + private LLUUID primID; + private bool isScriptRunning; + private BaseHttpServer httpListener; + private bool m_dumpAssetToFile; + + public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, + string path, BaseHttpServer httpServer, bool dumpAssetToFile) + { + m_dumpAssetToFile = dumpAssetToFile; + + this.inventoryItemID = inventoryItemID; + this.primID = primID; + + // This comes in over the packet as an integer, but actually appears to be treated as a bool + this.isScriptRunning = (0 == isScriptRunning ? false : true); + + uploaderPath = path; + httpListener = httpServer; + } + + /// + /// + /// + /// + /// + /// + /// + public string uploaderCaps(byte[] data, string path, string param) + { + try + { +// MainLog.Instance.Verbose( +// "CAPS", +// "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", +// data, path, param); + + string res = ""; + LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); + LLUUID assetID = LLUUID.Zero; + + if (OnUpLoad != null) + { + assetID = OnUpLoad(inventoryItemID, primID, isScriptRunning, data); + } + + uploadComplete.item_id = inventoryItemID; + uploadComplete.task_id = primID; + uploadComplete.state = "complete"; + + res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); + + httpListener.RemoveStreamHandler("POST", uploaderPath); + + if (m_dumpAssetToFile) + { + SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); + } + +// MainLog.Instance.Verbose("CAPS", "TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); + + return res; + } + catch (Exception e) + { + MainLog.Instance.Error("CAPS", e.ToString()); + } + + // XXX Maybe this should be some meaningful error packet + return null; + } + + private void SaveAssetToFile(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/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index c50d0a9..dfb1683 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -38,7 +38,7 @@ namespace OpenSim.Region.Capabilities // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; - // public string UpdateScriptTaskInventory = ""; + public string UpdateScriptTaskInventory = ""; // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs new file mode 100644 index 0000000..3703efc --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -0,0 +1,50 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDTaskInventoryUploadComplete + { + /// + /// The task inventory item that was updated + /// + public LLUUID item_id; + + /// + /// The task that was updated + /// + public LLUUID task_id; + + /// + /// State of the upload. So far have only even seen this set to "complete" + /// + public string state; + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs new file mode 100644 index 0000000..6dcf2b5 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -0,0 +1,51 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDTaskScriptUpdate + { + /// + /// The item containing the script to update + /// + public LLUUID item_id; + + /// + /// The task containing the script + /// + public LLUUID task_id; + + /// + /// Signals whether the script is currently active + /// + public int is_script_running; + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index cc540e7..d946e00 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -260,7 +260,7 @@ namespace OpenSim.Framework.UserManagement /// The users loginrequest public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - Hashtable requestData = (Hashtable) request.Params[0]; + //Hashtable requestData = (Hashtable) request.Params[0]; UserAgentData agent = new UserAgentData(); -- cgit v1.1 From e9efd5bee204a92b3969ea3beeba89243d13e47a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 25 Dec 2007 18:11:56 +0000 Subject: Small non-functional inventory changes --- .../Framework/Communications/Capabilities/Caps.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a72abbe..e00f49d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -38,18 +38,18 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities { public delegate void UpLoadedAsset( - string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, - string inventoryType, string assetType); + string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, + byte[] data, string inventoryType, string assetType); public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); - public delegate LLUUID UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); + public delegate void UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); - public delegate LLUUID TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, + public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); public class Caps @@ -349,7 +349,10 @@ namespace OpenSim.Region.Capabilities uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; - MainLog.Instance.Verbose("CAPS", "NoteCardAgentInventory response: {0}", LLSDHelpers.SerialiseLLSDReply(uploadResponse)); +// MainLog.Instance.Verbose( +// "CAPS", +// "NoteCardAgentInventory response: {0}", +// LLSDHelpers.SerialiseLLSDReply(uploadResponse)); return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -461,14 +464,12 @@ namespace OpenSim.Region.Capabilities /// Prim containing item to update /// Signals whether the script to update is currently running /// New asset data - public LLUUID TaskScriptUpdated(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data) + public void TaskScriptUpdated(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data) { if (TaskScriptUpdatedCall != null) { - return TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data); + TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data); } - - return LLUUID.Zero; } public class AssetUploader @@ -661,11 +662,10 @@ namespace OpenSim.Region.Capabilities string res = ""; LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); - LLUUID assetID = LLUUID.Zero; if (OnUpLoad != null) { - assetID = OnUpLoad(inventoryItemID, primID, isScriptRunning, data); + OnUpLoad(inventoryItemID, primID, isScriptRunning, data); } uploadComplete.item_id = inventoryItemID; -- cgit v1.1 From c7fc0dbeb7a88bae1617222f119cc13308c3ffd9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 26 Dec 2007 21:06:51 +0000 Subject: * Patch from Charlie Omega for standard secondlife inventory folders: see mantis:0000246 * Deletes the solution file from OpenSim.Gui --- .../Communications/InventoryServiceBase.cs | 107 ++++++++++++++++++++- 1 file changed, 103 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 1e13031..6384408 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -241,8 +241,71 @@ namespace OpenSim.Framework.Communications folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); - folder.name = "Textures"; - folder.type = 0; + folder.name = "Accessories"; + folder.type = 8; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Animations"; + folder.type = 20; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "BodyParts"; + folder.type = 13; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Clothing"; + folder.type = 5; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Gestures"; + folder.type = 21; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Landmarks"; + folder.type = 3; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Lost And Found"; + folder.type = 3; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Notecards"; + folder.type = 7; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -259,8 +322,44 @@ namespace OpenSim.Framework.Communications folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); - folder.name = "Clothes"; - folder.type = 5; + folder.name = "Photo Album"; + folder.type = 15; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Scripts"; + folder.type = 10; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Sounds"; + folder.type = 1; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Textures"; + folder.type = 0; + folder.version = 1; + Folders.Add(folder.folderID, folder); + + folder = new InventoryFolderBase(); + folder.parentID = rootFolder; + folder.agentID = user; + folder.folderID = LLUUID.Random(); + folder.name = "Trash"; + folder.type = 14; folder.version = 1; Folders.Add(folder.folderID, folder); } -- cgit v1.1 From 87e2a694e200f5774f71d38041247912b5ccf98d Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 14:00:30 +0000 Subject: * AssetServerBase: _ProcessRequest is now called GetAsset * PrimitiveBaseShape: The textures are now exposed as a 'TextureEntry Textures'; all serialization still using the 'byte[] TextureEntry' for backwards compatibility. * Scene: Re-added AddTree, since the Tree type isn't gone from libsl, merely relocated. --- OpenSim/Framework/Communications/Cache/AssetServer.cs | 2 +- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 8 ++++---- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 4ad0f60..ae6494f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache } } - protected override AssetBase _ProcessRequest(AssetRequest req) + protected override AssetBase GetAsset(AssetRequest req) { byte[] idata = null; bool found = false; diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f5ebab7..43d3dd9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -54,16 +54,16 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - protected abstract AssetBase _ProcessRequest(AssetRequest req); + protected abstract AssetBase GetAsset(AssetRequest req); /// - /// Process an asset request. This method will call _ProcessRequest(AssetRequest req) + /// Process an asset request. This method will call GetAsset(AssetRequest req) /// on the subclass. /// /// - protected void ProcessRequest(AssetRequest req) + protected virtual void ProcessRequest(AssetRequest req) { - AssetBase asset = _ProcessRequest(req); + AssetBase asset = GetAsset(req); if (asset != null) { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 5801aa8..9c460c7 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Cache #region IAssetServer Members - protected override AssetBase _ProcessRequest(AssetRequest req) + protected override AssetBase GetAsset(AssetRequest req) { Stream s = null; try diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 4fa7684..7fcff10 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -77,7 +77,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } - protected override AssetBase _ProcessRequest(AssetRequest req) + protected override AssetBase GetAsset(AssetRequest req) { AssetBase asset; lock (syncLock) -- cgit v1.1 From 997a2907e2e26d6ee09c4e222bfbc017e3229418 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Dec 2007 15:17:22 +0000 Subject: Move hardcoded texture library inventory items out into OpenSimLibrary/xml. However, even before these change the five textures moved are not displaying (which is why default cubes are coming up as grey plywood unless you happen to have that texture cached). These were working before so they must have broken in the last month. Might be something to do with the fact that these identify (using file under linux) as jpeg2000 files, while all the other working textures identify simply as data. --- .../Framework/Communications/Cache/LibraryRootFolder.cs | 17 +---------------- .../Framework/Communications/InventoryServiceBase.cs | 4 ++-- OpenSim/Framework/Communications/LoginService.cs | 1 + 3 files changed, 4 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index ffc94bf..4c8eddf 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -81,22 +81,7 @@ namespace OpenSim.Framework.Communications.Cache private void CreateLibraryItems() { - InventoryItemBase item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000002"), "Plywood", "Plywood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); - m_textureFolder.Items.Add(item.inventoryID, item); - - item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000003"), "Rocks", "Rocks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); - m_textureFolder.Items.Add(item.inventoryID, item); - - item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000001"), "Bricks", "Bricks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); - m_textureFolder.Items.Add(item.inventoryID, item); - - item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000004"), "Granite", "Granite texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); - m_textureFolder.Items.Add(item.inventoryID, item); - - item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000005"), "Hardwood", "Hardwood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); - m_textureFolder.Items.Add(item.inventoryID, item); - - item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + InventoryItemBase item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 6384408..0797a84 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications { if (!String.IsNullOrEmpty(FileName)) { - MainLog.Instance.Verbose("Inventory", "Inventorystorage: Attempting to load " + FileName); + MainLog.Instance.Verbose("AGENTINVENTORY", "Inventorystorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("INVENTORY", "Added IInventoryData Interface"); + MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface"); } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 58dab9b..6d4cb68 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -277,6 +277,7 @@ namespace OpenSim.Framework.UserManagement TempHash["type_default"] = -1; TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; temp.Add(TempHash); + return temp; } -- cgit v1.1 From d508d771220a97e28a79f08c429d39dd0e87862d Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:06:44 +0000 Subject: * removed always true if --- .../Communications/InventoryServiceBase.cs | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 0797a84..534383a 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications if (typeInterface != null) { IInventoryData plug = - (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); m_plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface"); @@ -74,44 +74,41 @@ namespace OpenSim.Framework.Communications } } } - + public List RequestFirstLevelFolders(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); return RequestFirstLevelFolders(userID); } - + /// /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) /// /// /// public List RequestFirstLevelFolders(LLUUID userID) - { - List inventoryList = new List(); + { + List inventoryList = new List(); InventoryFolderBase rootFolder = null; - + foreach (KeyValuePair plugin in m_plugins) { rootFolder = plugin.Value.getUserRootFolder(userID); if (rootFolder != null) { MainLog.Instance.Verbose( - "INVENTORY", + "INVENTORY", "Found root folder for user with ID " + userID + ". Retrieving inventory contents."); - + inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); inventoryList.Insert(0, rootFolder); return inventoryList; } } - - if (null == rootFolder) - { - MainLog.Instance.Warn( - "INVENTORY", "Could not find a root folder belonging to user with ID " + userID); - } - + + MainLog.Instance.Warn( + "INVENTORY", "Could not find a root folder belonging to user with ID " + userID); + return inventoryList; } -- cgit v1.1 From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- .../Framework/Communications/Cache/AssetCache.cs | 49 +++++++------ .../Framework/Communications/Cache/AssetServer.cs | 6 +- .../Communications/Cache/AssetServerBase.cs | 10 +-- .../Cache/AssetTransactionManager.cs | 2 +- .../Communications/Cache/AssetTransactions.cs | 6 +- .../Communications/Cache/CachedUserInfo.cs | 2 +- .../Communications/Cache/GridAssetClient.cs | 15 ++-- .../Communications/Cache/InventoryFolderImpl.cs | 4 +- .../Communications/Cache/LibraryRootFolder.cs | 37 ++++++---- .../Communications/Cache/SQLAssetServer.cs | 8 +-- .../Cache/UserProfileCacheService.cs | 37 +++++----- .../Framework/Communications/Capabilities/Caps.cs | 82 +++++++++++----------- .../Framework/Communications/Capabilities/LLSD.cs | 42 ++++++----- .../Communications/Capabilities/LLSDArray.cs | 2 +- .../Capabilities/LLSDAssetUploadComplete.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 2 +- .../Communications/Capabilities/LLSDCapsDetails.cs | 2 +- .../Communications/Capabilities/LLSDEmpty.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 15 ++-- .../Communications/Capabilities/LLSDMapLayer.cs | 2 +- .../Capabilities/LLSDMapLayerResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 8 +-- .../LLSDTaskInventoryUploadComplete.cs | 14 ++-- .../Capabilities/LLSDTaskScriptUpdate.cs | 12 ++-- .../Communications/Capabilities/LLSDTest.cs | 2 +- .../Communications/Capabilities/LLSDType.cs | 2 +- .../Communications/CommunicationsManager.cs | 7 +- OpenSim/Framework/Communications/IGridServices.cs | 4 +- .../Communications/IInterRegionCommunications.cs | 6 +- .../Framework/Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 5 +- OpenSim/Framework/Communications/LoginResponse.cs | 6 +- OpenSim/Framework/Communications/LoginService.cs | 25 ++++--- .../Communications/Properties/AssemblyInfo.cs | 2 +- .../Communications/RestClient/RestClient.cs | 16 ++--- .../Framework/Communications/UserManagerBase.cs | 32 +++++---- 36 files changed, 241 insertions(+), 231 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4765548..664625e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Threading; using libsecondlife; using libsecondlife.Packets; @@ -92,7 +91,7 @@ namespace OpenSim.Framework.Communications.Cache Thread.Sleep(500); } catch (Exception e) - { + { m_log.Error("ASSETCACHE", e.ToString()); } } @@ -177,30 +176,29 @@ namespace OpenSim.Framework.Communications.Cache // packets from the client. int pollPeriod = 200; int maxPolls = 15; - + AssetBase asset = GetCachedAsset(assetID); if (asset != null) { return asset; } - - m_assetServer.RequestAsset(assetID, isTexture); - + + m_assetServer.RequestAsset(assetID, isTexture); + do { Thread.Sleep(pollPeriod); - + asset = GetCachedAsset(assetID); if (asset != null) { return asset; } - } - while (--maxPolls > 0); - + } while (--maxPolls > 0); + MainLog.Instance.Warn( "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); - + return null; } @@ -368,12 +366,13 @@ namespace OpenSim.Framework.Communications.Cache { // over max number of bytes so split up file long restData = data.LongLength - m_maxPacketSize; - int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize); + int restPackets = (int) ((restData + m_maxPacketSize - 1)/m_maxPacketSize); numPackets += restPackets; } return numPackets; } + #region Assets /// @@ -448,7 +447,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)AssetRequests[i]; + req = (AssetRequest) AssetRequests[i]; //Console.WriteLine("sending asset " + req.RequestAssetID); TransferInfoPacket Transfer = new TransferInfoPacket(); Transfer.TransferInfo.ChannelType = 2; @@ -458,7 +457,7 @@ namespace OpenSim.Framework.Communications.Cache { Transfer.TransferInfo.Params = new byte[20]; Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; + int assType = (int) req.AssetInf.Type; Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); } else if (req.AssetRequestSource == 3) @@ -468,7 +467,7 @@ namespace OpenSim.Framework.Communications.Cache //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); @@ -488,20 +487,20 @@ namespace OpenSim.Framework.Communications.Cache // libsecondlife hardcodes 1500 as the maximum data chunk size int maxChunkSize = 1500; int packetNumber = 0; - + while (processedLength < req.AssetInf.Data.Length) { TransferPacketPacket TransferPacket = new TransferPacketPacket(); TransferPacket.TransferData.Packet = packetNumber; TransferPacket.TransferData.ChannelType = 2; TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); byte[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - + Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); + TransferPacket.TransferData.Data = chunk; - + // 0 indicates more packets to come, 1 indicates last packet if (req.AssetInf.Data.Length - processedLength > maxChunkSize) { @@ -510,10 +509,10 @@ namespace OpenSim.Framework.Communications.Cache else { TransferPacket.TransferData.Status = 1; - } - + } + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - + processedLength += chunkSize; packetNumber++; } @@ -609,4 +608,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index ae6494f..692ee1e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); if (result.Count > 0) { - foundAsset = (AssetStorage)result.Next(); + foundAsset = (AssetStorage) result.Next(); found = true; } @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Cache asset.Name = foundAsset.Name; idata = foundAsset.Data; asset.Data = idata; - + return asset; } else @@ -141,4 +141,4 @@ namespace OpenSim.Framework.Communications.Cache return (asset.UUID == _findID); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 43d3dd9..1b2c836 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Verbose( "ASSET", "Asset {0} received from asset server", req.AssetID); - + _receiver.AssetReceived(asset, req.IsTexture); } else @@ -112,9 +112,9 @@ namespace OpenSim.Framework.Communications.Cache ProcessRequest(req); } - catch(Exception e) + catch (Exception e) { - MainLog.Instance.Error("ASSETSERVER", e.Message ); + MainLog.Instance.Error("ASSETSERVER", e.Message); } } } @@ -149,7 +149,7 @@ namespace OpenSim.Framework.Communications.Cache req.AssetID = assetID; req.IsTexture = isTexture; _assetRequests.Enqueue(req); - + MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); } @@ -253,4 +253,4 @@ namespace OpenSim.Framework.Communications.Cache assets.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 7de84fa..c9c9541 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -106,4 +106,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 57c1fa6..8aa567c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Communications.Cache Asset.Description = "empty"; Asset.Local = storeLocal; Asset.Temporary = tempFile; - + TransactionID = transaction; m_storeLocal = storeLocal; if (Asset.Data.Length > 2) @@ -312,6 +312,7 @@ namespace OpenSim.Framework.Communications.Cache } #region Nested Classes currently not in use (waiting for them to be enabled) + public class AssetCapsUploader { // Fields @@ -424,6 +425,7 @@ namespace OpenSim.Framework.Communications.Cache return text; } } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index a547c8a..1cf95b7 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -130,4 +130,4 @@ namespace OpenSim.Framework.Communications.Cache return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 9c460c7..cf54fa4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -27,10 +27,8 @@ */ using System; -using System.Collections.Generic; using System.IO; using System.Xml.Serialization; -using libsecondlife; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -65,9 +63,9 @@ namespace OpenSim.Framework.Communications.Cache if (s.Length > 0) { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - - return (AssetBase)xs.Deserialize(s); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + + return (AssetBase) xs.Deserialize(s); } } catch (Exception e) @@ -76,12 +74,11 @@ namespace OpenSim.Framework.Communications.Cache MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } - + return null; } - public override void UpdateAsset(AssetBase asset) { throw new Exception("The method or operation is not implemented."); @@ -119,8 +116,6 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - - #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 1d2c920..a1e79b2 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl subFold = new InventoryFolderImpl(); subFold.name = folderName; subFold.folderID = folderID; - subFold.type = (short)type; + subFold.type = (short) type; subFold.parentID = this.folderID; subFold.agentID = agentID; SubFolders.Add(subFold.folderID, subFold); @@ -153,4 +153,4 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 4c8eddf..fd93b19 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -49,8 +49,8 @@ namespace OpenSim.Framework.Communications.Cache folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); name = "OpenSim Library"; parentID = LLUUID.Zero; - type = (short)-1; - version = (ushort)1; + type = (short) -1; + version = (ushort) 1; InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; @@ -81,28 +81,41 @@ namespace OpenSim.Framework.Communications.Cache private void CreateLibraryItems() { - InventoryItemBase item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + InventoryItemBase item = + CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), + new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", + (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), + new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", + (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), + new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", + (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), + new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", + (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); } - public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) + public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, + int assetType, int invType, LLUUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; @@ -135,10 +148,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); if (item.assetType == 0) { item.parentFolderID = m_textureFolder.folderID; @@ -152,4 +165,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 7fcff10..e4c278f 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache if (typeInterface != null) { IAssetProvider plug = - (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); @@ -84,8 +84,8 @@ namespace OpenSim.Framework.Communications.Cache { asset = m_assetProviderPlugin.FetchAsset(req.AssetID); } - - return asset; + + return asset; } protected override void StoreAsset(AssetBase asset) @@ -98,4 +98,4 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 47f970e..14670fd 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -130,7 +130,8 @@ namespace OpenSim.Framework.Communications.Cache } } - public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID) + public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, + LLUUID parentID) { CachedUserInfo userProfile; @@ -143,7 +144,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.folderID = folderID; baseFolder.name = name; baseFolder.parentID = parentID; - baseFolder.type = (short)type; + baseFolder.type = (short) type; baseFolder.version = userProfile.RootFolder.version; m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } @@ -180,12 +181,12 @@ namespace OpenSim.Framework.Communications.Cache bool fetchFolders, bool fetchItems, int sortOrder) { // XXX We're not handling sortOrder yet! - + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), + libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -194,7 +195,7 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, folderID, fold.RequestListOfItems(), + libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -209,9 +210,9 @@ namespace OpenSim.Framework.Communications.Cache { remoteClient.SendInventoryFolderDetails( remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), - userProfile.RootFolder.RequestListOfFolders(), + userProfile.RootFolder.RequestListOfFolders(), fetchFolders, fetchItems); - + return; } else @@ -219,9 +220,9 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, fold.RequestListOfItems(), + remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); - + return; } } @@ -230,20 +231,20 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Error( "INVENTORYCACHE", "Could not find root folder for user {0}", remoteClient.Name); - + return; } } else { MainLog.Instance.Error( - "INVENTORYCACHE", - "Could not find user profile for {0} for folder {1}", - remoteClient.Name, folderID); - + "INVENTORYCACHE", + "Could not find user profile for {0} for folder {1}", + remoteClient.Name, folderID); + return; } - + // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists MainLog.Instance.Error( @@ -262,8 +263,8 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); if (subFolder != null) { - List items=subFolder.RequestListOfItems(); - foreach(InventoryItemBase item in items) + List items = subFolder.RequestListOfItems(); + foreach (InventoryItemBase item in items) { userProfile.DeleteItem(remoteClient.AgentId, item); } @@ -300,4 +301,4 @@ namespace OpenSim.Framework.Communications.Cache m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index e00f49d..4b42046 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -38,33 +38,33 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities { public delegate void UpLoadedAsset( - string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, + string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); - + public delegate void UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); - - public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, - bool isScriptRunning, byte[] data); + + public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, + bool isScriptRunning, byte[] data); public class Caps { private string m_httpListenerHostName; private uint 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_requestTexture = "0003/"; private string m_notecardUpdatePath = "0004/"; private string m_notecardTaskUpdatePath = "0005/"; - + //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; private LLUUID m_agentID; @@ -78,7 +78,7 @@ namespace OpenSim.Region.Capabilities public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; - + public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { @@ -138,7 +138,7 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { - //Console.WriteLine("caps request " + request); + //Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); return result; } @@ -153,7 +153,7 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; + // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; @@ -262,7 +262,7 @@ namespace OpenSim.Region.Capabilities } #endregion - + /// /// Callback for a client request for an upload url for a script task /// inventory update @@ -272,28 +272,28 @@ namespace OpenSim.Region.Capabilities /// /// public string ScriptTaskInventory(string request, string path, string param) - { + { try { // MainLog.Instance.Debug("CAPS", "request: {0}, path: {1}, param: {2}", request, path, param); - - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - + string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - + TaskInventoryScriptUpdater uploader = new TaskInventoryScriptUpdater( - llsdUpdateRequest.item_id, - llsdUpdateRequest.task_id, - llsdUpdateRequest.is_script_running, - capsBase + uploaderPath, - m_httpListener, - m_dumpAssetsToFile); + llsdUpdateRequest.item_id, + llsdUpdateRequest.task_id, + llsdUpdateRequest.is_script_running, + capsBase + uploaderPath, + m_httpListener, + m_dumpAssetsToFile); uploader.OnUpLoad += TaskScriptUpdated; - + m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + @@ -302,13 +302,13 @@ namespace OpenSim.Region.Capabilities LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; - + // MainLog.Instance.Verbose( // "CAPS", // "ScriptTaskInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse)); - - return LLSDHelpers.SerialiseLLSDReply(uploadResponse); + + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } catch (Exception e) { @@ -329,7 +329,7 @@ namespace OpenSim.Region.Capabilities public string NoteCardAgentInventory(string request, string path, string param) { //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -353,7 +353,7 @@ namespace OpenSim.Region.Capabilities // "CAPS", // "NoteCardAgentInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse)); - + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -453,7 +453,7 @@ namespace OpenSim.Region.Capabilities { return ItemUpdatedCall(m_agentID, itemID, data); } - + return LLUUID.Zero; } @@ -613,7 +613,7 @@ namespace OpenSim.Region.Capabilities fs.Close(); } } - + /// /// This class is a callback invoked when a client sends asset data to /// a task inventory script update url @@ -629,17 +629,17 @@ namespace OpenSim.Region.Capabilities private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, + public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; this.inventoryItemID = inventoryItemID; this.primID = primID; - + // This comes in over the packet as an integer, but actually appears to be treated as a bool this.isScriptRunning = (0 == isScriptRunning ? false : true); - + uploaderPath = path; httpListener = httpServer; } @@ -659,7 +659,7 @@ namespace OpenSim.Region.Capabilities // "CAPS", // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", // data, path, param); - + string res = ""; LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); @@ -668,7 +668,7 @@ namespace OpenSim.Region.Capabilities OnUpLoad(inventoryItemID, primID, isScriptRunning, data); } - uploadComplete.item_id = inventoryItemID; + uploadComplete.item_id = inventoryItemID; uploadComplete.task_id = primID; uploadComplete.state = "complete"; @@ -680,7 +680,7 @@ namespace OpenSim.Region.Capabilities { SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); } - + // MainLog.Instance.Verbose("CAPS", "TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); return res; @@ -689,9 +689,9 @@ namespace OpenSim.Region.Capabilities { MainLog.Instance.Error("CAPS", e.ToString()); } - + // XXX Maybe this should be some meaningful error packet - return null; + return null; } private void SaveAssetToFile(string filename, byte[] data) @@ -702,6 +702,6 @@ namespace OpenSim.Region.Capabilities bw.Close(); fs.Close(); } - } + } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 987d6e6..dab926c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,12 +28,12 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Xml; +using System.Globalization; using System.IO; -using libsecondlife; using System.Security.Cryptography; using System.Text; +using System.Xml; +using libsecondlife; namespace OpenSim.Region.Capabilities { @@ -47,7 +47,9 @@ namespace OpenSim.Region.Capabilities /// public class LLSDParseException : Exception { - public LLSDParseException(string message) : base(message) { } + public LLSDParseException(string message) : base(message) + { + } } /// @@ -55,7 +57,9 @@ namespace OpenSim.Region.Capabilities /// public class LLSDSerializeException : Exception { - public LLSDSerializeException(string message) : base(message) { } + public LLSDSerializeException(string message) : base(message) + { + } } /// @@ -129,7 +133,7 @@ namespace OpenSim.Region.Capabilities if (obj is string) { writer.WriteStartElement(String.Empty, "string", String.Empty); - writer.WriteString((string)obj); + writer.WriteString((string) obj); writer.WriteEndElement(); } else if (obj is int) @@ -146,7 +150,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is bool) { - bool b = (bool)obj; + bool b = (bool) obj; writer.WriteStartElement(String.Empty, "boolean", String.Empty); writer.WriteString(b ? "1" : "0"); writer.WriteEndElement(); @@ -157,7 +161,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is LLUUID) { - LLUUID u = (LLUUID)obj; + LLUUID u = (LLUUID) obj; writer.WriteStartElement(String.Empty, "uuid", String.Empty); writer.WriteString(u.ToString()); writer.WriteEndElement(); @@ -463,7 +467,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is string) { - return GetSpaces(indent) + "- string \"" + (string)obj + "\"\n"; + return GetSpaces(indent) + "- string \"" + (string) obj + "\"\n"; } else if (obj is int) { @@ -475,13 +479,13 @@ namespace OpenSim.Region.Capabilities } else if (obj is LLUUID) { - return GetSpaces(indent) + "- uuid " + ((LLUUID)obj).ToString() + Environment.NewLine; + return GetSpaces(indent) + "- uuid " + ((LLUUID) obj).ToString() + Environment.NewLine; } else if (obj is Hashtable) { StringBuilder ret = new StringBuilder(); ret.Append(GetSpaces(indent) + "- map" + Environment.NewLine); - Hashtable map = (Hashtable)obj; + Hashtable map = (Hashtable) obj; foreach (string key in map.Keys) { @@ -495,7 +499,7 @@ namespace OpenSim.Region.Capabilities { StringBuilder ret = new StringBuilder(); ret.Append(GetSpaces(indent) + "- array\n"); - ArrayList list = (ArrayList)obj; + ArrayList list = (ArrayList) obj; foreach (object item in list) { @@ -506,8 +510,8 @@ namespace OpenSim.Region.Capabilities } else if (obj is byte[]) { - return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[])obj, GetSpaces(indent)) + - Environment.NewLine; + return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[]) obj, GetSpaces(indent)) + + Environment.NewLine; } else { @@ -557,8 +561,8 @@ namespace OpenSim.Region.Capabilities double value; endPos = FindEnd(llsd, 1); - if (Double.TryParse(llsd.Substring(1, endPos - 1), System.Globalization.NumberStyles.Float, - Helpers.EnUsCulture.NumberFormat, out value)) + if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); @@ -652,7 +656,7 @@ namespace OpenSim.Region.Capabilities private static int FindEnd(string llsd, int start) { - int end = llsd.IndexOfAny(new char[] { ',', ']', '}' }); + int end = llsd.IndexOfAny(new char[] {',', ']', '}'}); if (end == -1) end = llsd.Length - 1; return end; } @@ -673,4 +677,4 @@ namespace OpenSim.Region.Capabilities } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 2bc1643..d641b5c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 307e3e3..f838c85 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -41,4 +41,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index eb76d64..3b8c077 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index dfb1683..7b09cb3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -34,7 +34,7 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - // public string RequestTextureDownload = ""; + // public string RequestTextureDownload = ""; // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 101d9c0..5e6e917 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -34,4 +34,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 60aa60c..28f838d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -30,7 +30,6 @@ using System.Collections; using System.IO; using System.Reflection; using System.Xml; -using libsecondlife; namespace OpenSim.Region.Capabilities { @@ -77,7 +76,7 @@ namespace OpenSim.Region.Capabilities writer.WriteString(fields[i].Name); writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); - // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( // writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); } } @@ -102,8 +101,8 @@ namespace OpenSim.Region.Capabilities else { LLSD.LLSDWriteOne(writer, obj); - //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); + //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); } } @@ -122,12 +121,12 @@ namespace OpenSim.Region.Capabilities FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { - // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) + // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable)enumerator.Value, fieldValue); - // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); + DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); + // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { @@ -149,4 +148,4 @@ namespace OpenSim.Region.Capabilities return obj; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 214b9c7..121b36a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 48130b1..93b0f83 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 71cc358..4321d7b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -29,9 +29,7 @@ using System.Collections; using System.IO; using System.Text; -using libsecondlife; using OpenSim.Framework.Servers; -using System.Xml; namespace OpenSim.Region.Capabilities { @@ -54,10 +52,10 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) + // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) // libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(request); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -68,4 +66,4 @@ namespace OpenSim.Region.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 3703efc..8d6550b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -25,10 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities -{ +{ [LLSDMap] public class LLSDTaskInventoryUploadComplete { @@ -36,15 +36,15 @@ namespace OpenSim.Region.Capabilities /// The task inventory item that was updated /// public LLUUID item_id; - + /// /// The task that was updated /// - public LLUUID task_id; - + public LLUUID task_id; + /// /// State of the upload. So far have only even seen this set to "complete" /// public string state; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 6dcf2b5..e9c77b8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -26,10 +26,10 @@ * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities -{ +{ [LLSDMap] public class LLSDTaskScriptUpdate { @@ -37,15 +37,15 @@ namespace OpenSim.Region.Capabilities /// The item containing the script to update /// public LLUUID item_id; - + /// /// The task containing the script /// public LLUUID task_id; - + /// /// Signals whether the script is currently active /// public int is_script_running; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index 70bfd2c..d10b0c0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 7bbe16e..e851742 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -52,4 +52,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 4614756..02c54e1 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -26,9 +26,9 @@ * */ using System; +using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using System.Collections.Generic; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -173,12 +173,13 @@ namespace OpenSim.Framework.Communications } } } + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { - List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); + List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); return pickerlist; } #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index d51f234..e2c2661 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections; using System.Collections.Generic; namespace OpenSim.Framework.Communications @@ -39,6 +38,5 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 3aa20a3..e2a96f6 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -31,8 +31,7 @@ namespace OpenSim.Framework.Communications { public interface IInterRegionCommunications { - - string rdebugRegionName{ get; set; } + string rdebugRegionName { get; set; } bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); bool RegionUp(SearializableRegionInfo region, ulong regionhandle); @@ -45,6 +44,5 @@ namespace OpenSim.Framework.Communications bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID); void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 9c493d4..f2e5cc5 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -52,4 +52,4 @@ namespace OpenSim.Framework.Communications /// List RequestFirstLevelFolders(LLUUID userID); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 534383a..098d08e 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -30,7 +30,6 @@ using System; using System.Collections.Generic; using System.Reflection; using libsecondlife; -using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications @@ -65,7 +64,7 @@ namespace OpenSim.Framework.Communications if (typeInterface != null) { IInventoryData plug = - (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); m_plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface"); @@ -370,4 +369,4 @@ namespace OpenSim.Framework.Communications public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index ede3148..954aecb 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -525,9 +525,9 @@ namespace OpenSim.Framework.UserManagement set { welcomeMessage = value; } } - public BuddyList BuddList + public BuddyList BuddList { - get{return m_buddyList;} + get { return m_buddyList; } set { m_buddyList = value; } } @@ -591,4 +591,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 6d4cb68..a284910 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.UserManagement //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. //CKF: MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); @@ -75,17 +75,17 @@ namespace OpenSim.Framework.UserManagement if (GoodXML) { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; + string firstname = (string) requestData["first"]; + string lastname = (string) requestData["last"]; + string passwd = (string) requestData["passwd"]; userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { MainLog.Instance.Verbose( - "LOGIN", + "LOGIN", "Could not find a profile for " + firstname + " " + lastname); - + return logResponse.CreateLoginFailedResponse(); } @@ -103,15 +103,14 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { userProfile.currentAgent = null; m_userManager.CommitAgent(ref userProfile); - + // Reject the login return logResponse.CreateAlreadyLoggedInResponse(); - } // Otherwise... // Create a new agent session @@ -132,7 +131,7 @@ namespace OpenSim.Framework.UserManagement userProfile.rootInventoryFolderID = inventData.RootFolderID; // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); + uint circode = (uint) (Util.RandomClass.Next()); logResponse.Lastname = userProfile.surname; logResponse.Firstname = userProfile.username; @@ -150,7 +149,7 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; + logResponse.CircuitCode = (Int32) circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten logResponse.Home = "!!null temporary value {home}!!"; // Overwritten @@ -277,7 +276,7 @@ namespace OpenSim.Framework.UserManagement TempHash["type_default"] = -1; TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; temp.Add(TempHash); - + return temp; } @@ -328,4 +327,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index fd8ce38..e9c7bf3 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 5c77193..1aaf68e 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -238,7 +238,7 @@ namespace OpenSim.Framework.Communications } } realuri = sb.ToString(); - MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); + MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); return new Uri(sb.ToString()); } @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications } public Stream Request(Stream src) - { + { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; @@ -374,16 +374,16 @@ namespace OpenSim.Framework.Communications _asyncException = null; _request.ContentLength = src.Length; - MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); - MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); + MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); + MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); - MainLog.Instance.Verbose("REST", "Seek is ok"); + MainLog.Instance.Verbose("REST", "Seek is ok"); Stream dst = _request.GetRequestStream(); - MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); + MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); - MainLog.Instance.Verbose("REST", "First Read is ok"); + MainLog.Instance.Verbose("REST", "First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); @@ -440,4 +440,4 @@ namespace OpenSim.Framework.Communications #endregion Async Invocation } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d946e00..f913d2c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -27,7 +27,6 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Security.Cryptography; @@ -93,13 +92,13 @@ namespace OpenSim.Framework.UserManagement foreach (KeyValuePair plugin in _plugins) { UserProfileData profile = plugin.Value.GetUserByUUID(uuid); - + if (null != profile) { profile.currentAgent = getUserAgent(profile.UUID); return profile; - } - } + } + } return null; } @@ -112,11 +111,11 @@ namespace OpenSim.Framework.UserManagement try { pickerlist = plugin.Value.GeneratePickerResults(queryID, query); - } catch (Exception) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); return new List(); } } @@ -162,7 +161,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -188,7 +188,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -210,7 +211,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -222,7 +224,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData profile = GetUserProfile(agentID); profile.currentAgent = null; - + setUserProfile(profile); } @@ -242,7 +244,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -356,7 +359,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -365,6 +369,6 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); - public abstract UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid); + public abstract UserProfileData SetupMasterUser(LLUUID uuid); } -} +} \ No newline at end of file -- cgit v1.1 From 1a484fcabfd7311757f2db699ced0bacd2b126a5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 28 Dec 2007 08:56:44 +0000 Subject: Set svn:eol-style. --- .../Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 8d6550b..6454ad7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities { [LLSDMap] diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index e9c77b8..52e13a7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -26,8 +26,8 @@ * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities { [LLSDMap] -- cgit v1.1 From 7cf9a8d4f9e1ea1f1d741a1b045ce63e20aa3fde Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Dec 2007 18:01:20 +0000 Subject: Move inventory contents configuration files to bin/inventory folder --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index fd93b19..216e13f 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache CreateLibraryItems(); - string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); + string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary.xml"); if (File.Exists(filePath)) { try @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (XmlException e) { - MainLog.Instance.Error("INVENTORY", "Error loading " + filePath + ": " + e.ToString()); + MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + filePath + ": " + e.ToString()); } } } @@ -165,4 +165,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} \ No newline at end of file +} -- cgit v1.1 From 4ae10034bd929c6451633c6fc5172c44e9280fa4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Dec 2007 22:13:43 +0000 Subject: Factor out common asset loading from AssetServerBase and Grid/AssetServer/Main --- .../Framework/Communications/Cache/AssetServer.cs | 3 +- .../Communications/Cache/AssetServerBase.cs | 102 +-------------------- 2 files changed, 6 insertions(+), 99 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 692ee1e..575e80a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -122,8 +122,7 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); - ForEachDefaultAsset(StoreAsset); - ForEachXmlAsset(StoreAsset); + base.LoadDefaultAssets(); } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 1b2c836..2153fbf 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -28,12 +28,10 @@ using System; using System.Collections.Generic; -using System.IO; using System.Threading; -using System.Xml; using libsecondlife; -using Nini.Config; using OpenSim.Framework.Console; +using OpenSim.Framework.AssetLoader.Filesystem; namespace OpenSim.Framework.Communications.Cache { @@ -45,6 +43,9 @@ namespace OpenSim.Framework.Communications.Cache protected IAssetProvider m_assetProviderPlugin; protected object syncLock = new object(); + // Temporarily hardcoded - should be a plugin + protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); + protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); @@ -85,8 +86,7 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); - ForEachDefaultAsset(StoreAsset); - ForEachXmlAsset(StoreAsset); + assetLoader.ForEachXmlAsset(StoreAsset); CommitAssets(); } @@ -119,25 +119,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public void LoadAsset(AssetBase info, bool image, string filename) - { - //should request Asset from storage manager - //but for now read from file - - string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; - string fileName = Path.Combine(dataPath, filename); - FileInfo fInfo = new FileInfo(fileName); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] idata = new byte[numBytes]; - BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int) numBytes); - br.Close(); - fStream.Close(); - info.Data = idata; - //info.loaded=true; - } - public void SetReceiver(IAssetReceiver receiver) { _receiver = receiver; @@ -179,78 +160,5 @@ namespace OpenSim.Framework.Communications.Cache public void SetServerInfo(string ServerUrl, string ServerKey) { } - - public virtual List GetDefaultAssets() - { - List assets = new List(); - return assets; - } - - public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) - { - return CreateAsset(assetIdStr, name, filename, true); - } - - public void ForEachDefaultAsset(Action action) - { - List assets = GetDefaultAssets(); - assets.ForEach(action); - } - - public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) - { - AssetBase asset = new AssetBase( - new LLUUID(assetIdStr), - name - ); - - if (!String.IsNullOrEmpty(filename)) - { - MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename); - - LoadAsset(asset, isImage, filename); - } - else - { - MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name); - } - - return asset; - } - - public void ForEachXmlAsset(Action action) - { - List assets = new List(); - // System.Console.WriteLine("trying loading asset into database"); - string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); - if (File.Exists(filePath)) - { - try - { - XmlConfigSource source = new XmlConfigSource(filePath); - - for (int i = 0; i < source.Configs.Count; i++) - { - // System.Console.WriteLine("loading asset into database"); - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString()); - string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - - AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); - - newAsset.Type = type; - newAsset.InvType = invType; - assets.Add(newAsset); - } - } - catch (XmlException e) - { - MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString()); - } - } - assets.ForEach(action); - } } } \ No newline at end of file -- cgit v1.1 From 40e89678b71937e7dd103e845794574f6a6ed73c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 29 Dec 2007 19:41:50 +0000 Subject: Make inventory items nominate explicit inventory folders rather than hardcoding --- .../Communications/Cache/LibraryRootFolder.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 216e13f..7ff2c97 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -142,8 +142,10 @@ namespace OpenSim.Framework.Communications.Cache item.avatarID = libOwner; item.creatorsID = libOwner; item.inventoryID = - new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToString())); + new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); + item.parentFolderID + = new LLUUID(source.Configs[i].GetString("folderID", LLUUID.Random().ToString())); item.inventoryDescription = source.Configs[i].GetString("description", ""); item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); @@ -152,16 +154,19 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); - if (item.assetType == 0) + + if (item.parentFolderID == folderID) { - item.parentFolderID = m_textureFolder.folderID; - m_textureFolder.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); } else { - item.parentFolderID = folderID; - Items.Add(item.inventoryID, item); - } + // Very temporary - will only work for immediate child folders + if (SubFolders.ContainsKey(item.parentFolderID)) + { + SubFolders[item.parentFolderID].Items.Add(item.inventoryID, item); + } + } } } } -- cgit v1.1 From 7d04cf8d4ecf995fc1f7da277aae8b3d5c4f7948 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 30 Dec 2007 19:05:11 +0000 Subject: Shift default OpenSim library into its own directory --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 7ff2c97..20ec58a 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache CreateLibraryItems(); - string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary.xml"); + string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); if (File.Exists(filePath)) { try -- cgit v1.1 From 76e74a7667867932ef08c0f402dcfc424fb51b0c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 30 Dec 2007 19:40:44 +0000 Subject: Add an extra check that we don't create new inventory folders for a user that already has a root folder --- .../Communications/InventoryServiceBase.cs | 26 ++++++++++++++++++---- OpenSim/Framework/Communications/LoginService.cs | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 098d08e..2f466a3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -112,8 +112,10 @@ namespace OpenSim.Framework.Communications } /// - /// + /// Get the root folder for a user /// + /// + /// null if no root folder was found public InventoryFolderBase RequestUsersRoot(LLUUID userID) { foreach (KeyValuePair plugin in m_plugins) @@ -204,11 +206,27 @@ namespace OpenSim.Framework.Communications } } + /// + /// Create a new set of inventory folders for the given user. + /// + /// public void CreateNewUserInventory(LLUUID user) { - UsersInventory inven = new UsersInventory(); - inven.CreateNewInventorySet(user); - AddNewInventorySet(inven); + InventoryFolderBase existingRootFolder = RequestUsersRoot(user); + + if (null != existingRootFolder) + { + MainLog.Instance.Error( + "AGENTINVENTORY", + "Did not create a new inventory for user {0} since they already have " + + "a root inventory folder with id {1}", user, existingRootFolder); + } + else + { + UsersInventory inven = new UsersInventory(); + inven.CreateNewInventorySet(user); + AddNewInventorySet(inven); + } } public class UsersInventory diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index a284910..bef20f7 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -214,7 +214,8 @@ namespace OpenSim.Framework.UserManagement /// Authenticated? public virtual bool AuthenticateUser(UserProfileData profile, string password) { - MainLog.Instance.Verbose("LOGIN", "Authenticating " + profile.username + " " + profile.surname); + MainLog.Instance.Verbose( + "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); password = password.Remove(0, 3); //remove $1$ -- cgit v1.1 From 60fa75ac0466101654c6043d0366965da34c35bc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Dec 2007 03:33:21 +0000 Subject: Standard library folders can now be configued in the xml in inventory/OpenSimLibrary - no hardcoded changes are required. For some reason, all the folders are currently showing up as texture folders, even though they are configured with the same types as the agent inventory folders. This should be resolved soon. --- .../Communications/Cache/LibraryRootFolder.cs | 125 ++++++++++++++++----- OpenSim/Framework/Communications/LoginService.cs | 50 +++++---- 2 files changed, 129 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 20ec58a..cb122df 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -26,10 +26,12 @@ * */ +using System.Collections.Generic; using System.IO; using System.Xml; using libsecondlife; using Nini.Config; + using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache @@ -41,44 +43,62 @@ namespace OpenSim.Framework.Communications.Cache public class LibraryRootFolder : InventoryFolderImpl { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - private InventoryFolderImpl m_textureFolder; + + /// + /// Holds the root library folder and all its descendents. This is really only used during inventory + /// setup so that we don't have to repeatedly search the tree of library folders. + /// + protected Dictionary libraryFolders + = new Dictionary(); public LibraryRootFolder() { + MainLog.Instance.Verbose("LIBRARYINVENTORY", "Loading library inventory"); + agentID = libOwner; folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); name = "OpenSim Library"; parentID = LLUUID.Zero; - type = (short) -1; + type = (short) 8; version = (ushort) 1; - - InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - folderInfo.agentID = libOwner; - folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); - folderInfo.name = "Texture Library"; - folderInfo.parentID = folderID; - folderInfo.type = -1; - folderInfo.version = 1; - SubFolders.Add(folderInfo.folderID, folderInfo); - m_textureFolder = folderInfo; + + libraryFolders.Add(folderID, this); + + string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml"); + if (File.Exists(foldersPath)) + { + try + { + XmlConfigSource source = new XmlConfigSource(foldersPath); + ReadFoldersFromFile(source); + } + catch (XmlException e) + { + MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString()); + } + } CreateLibraryItems(); - string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); - if (File.Exists(filePath)) + string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); + if (File.Exists(itemsPath)) { try { - XmlConfigSource source = new XmlConfigSource(filePath); + XmlConfigSource source = new XmlConfigSource(itemsPath); ReadItemsFromFile(source); } catch (XmlException e) { - MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + filePath + ": " + e.ToString()); + MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString()); } } } + /// + /// Hardcoded item creation. Please don't add any more items here - future items should be created + /// in the xml in the bin/inventory folder. + /// private void CreateLibraryItems() { InventoryItemBase item = @@ -133,7 +153,51 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryNextPermissions = 0x7FFFFFFF; return item; } + + /// + /// Read library inventory folders from an external source + /// + /// + private void ReadFoldersFromFile(IConfigSource source) + { + for (int i = 0; i < source.Configs.Count; i++) + { + IConfig config = source.Configs[i]; + + InventoryFolderImpl folderInfo = new InventoryFolderImpl(); + + folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); + folderInfo.name = config.GetString("name", "unknown"); + folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); + folderInfo.type = (short)config.GetInt("type", 8); + + folderInfo.agentID = libOwner; + folderInfo.version = 1; + + if (libraryFolders.ContainsKey(folderInfo.parentID)) + { + InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; + + libraryFolders.Add(folderInfo.folderID, folderInfo); + parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + +// MainLog.Instance.Verbose( +// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); + } + else + { + MainLog.Instance.Warn( + "LIBRARYINVENTORY", + "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", + folderInfo.name, folderInfo.folderID, folderInfo.parentID); + } + } + } + /// + /// Read library inventory items metadata from an external source + /// + /// private void ReadItemsFromFile(IConfigSource source) { for (int i = 0; i < source.Configs.Count; i++) @@ -145,7 +209,7 @@ namespace OpenSim.Framework.Communications.Cache new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); item.parentFolderID - = new LLUUID(source.Configs[i].GetString("folderID", LLUUID.Random().ToString())); + = new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString())); item.inventoryDescription = source.Configs[i].GetString("description", ""); item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); @@ -155,19 +219,30 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); - if (item.parentFolderID == folderID) + if (libraryFolders.ContainsKey(item.parentFolderID)) { - Items.Add(item.inventoryID, item); + InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; + + parentFolder.Items.Add(item.inventoryID, item); } else { - // Very temporary - will only work for immediate child folders - if (SubFolders.ContainsKey(item.parentFolderID)) - { - SubFolders[item.parentFolderID].Items.Add(item.inventoryID, item); - } - } + MainLog.Instance.Warn( + "LIBRARYINVENTORY", + "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", + item.inventoryName, item.inventoryID, item.parentFolderID); + } } } + + /// + /// Looks like a simple getter, but is written like this for some consistency with the other Request + /// methods in the superclass + /// + /// + public Dictionary RequestSelfAndDescendentFolders() + { + return libraryFolders; + } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index bef20f7..a9d5d8b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -28,9 +28,12 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Threading; using libsecondlife; using Nwc.XmlRpc; + +using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement @@ -40,10 +43,18 @@ namespace OpenSim.Framework.UserManagement protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; protected Mutex m_loginMutex = new Mutex(false); + + /// + /// Used during login to send the skeleton of the OpenSim Library to the client. + /// + protected LibraryRootFolder m_libraryRootFolder; - public LoginService(UserManagerBase userManager, string welcomeMess) + public LoginService( + UserManagerBase userManager, LibraryRootFolder libraryRootFolder, string welcomeMess) { m_userManager = userManager; + m_libraryRootFolder = libraryRootFolder; + if (welcomeMess != "") { m_welcomeMessage = welcomeMess; @@ -255,30 +266,27 @@ namespace OpenSim.Framework.UserManagement } /// - /// + /// Converts the inventory library skeleton into the form required by the rpc request. /// /// protected virtual ArrayList GetInventoryLibrary() { - //return new ArrayList(); - Hashtable TempHash = new Hashtable(); - TempHash["name"] = "OpenSim Library"; - TempHash["parent_id"] = LLUUID.Zero.ToString(); - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList temp = new ArrayList(); - temp.Add(TempHash); - - TempHash = new Hashtable(); - TempHash["name"] = "Texture Library"; - TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; - TempHash["version"] = 1; - TempHash["type_default"] = -1; - TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; - temp.Add(TempHash); - - return temp; + Dictionary rootFolders + = m_libraryRootFolder.RequestSelfAndDescendentFolders(); + ArrayList folderHashes = new ArrayList(); + + foreach (InventoryFolderBase folder in rootFolders.Values) + { + Hashtable TempHash = new Hashtable(); + TempHash["name"] = folder.name; + TempHash["parent_id"] = folder.parentID.ToString(); + TempHash["version"] = folder.version; + TempHash["type_default"] = folder.type; + TempHash["folder_id"] = folder.folderID.ToString(); + folderHashes.Add(TempHash); + } + + return folderHashes; } /// -- cgit v1.1 From 5ef1433e95ca388304c9eef2a4445062c7a082ae Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Dec 2007 18:26:24 +0000 Subject: Correctly output library inventory folder type and version information --- OpenSim/Framework/Communications/LoginService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index a9d5d8b..2ac34b1 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -280,8 +280,8 @@ namespace OpenSim.Framework.UserManagement Hashtable TempHash = new Hashtable(); TempHash["name"] = folder.name; TempHash["parent_id"] = folder.parentID.ToString(); - TempHash["version"] = folder.version; - TempHash["type_default"] = folder.type; + TempHash["version"] = (Int32)folder.version; + TempHash["type_default"] = (Int32)folder.type; TempHash["folder_id"] = folder.folderID.ToString(); folderHashes.Add(TempHash); } @@ -336,4 +336,4 @@ namespace OpenSim.Framework.UserManagement } } } -} \ No newline at end of file +} -- cgit v1.1 From 3180432debcd9078e8e838d4bbe3ddaf9cdfe110 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 31 Dec 2007 22:56:43 +0000 Subject: * Added database and UserManagerBase glue for FriendsList management * Don't forget to run prebuild --- OpenSim/Framework/Communications/LoginService.cs | 15 +++++ .../Framework/Communications/UserManagerBase.cs | 74 ++++++++++++++++++++++ 2 files changed, 89 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 2ac34b1..afc6c9a 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -168,6 +168,7 @@ namespace OpenSim.Framework.UserManagement //logResponse.SimAddress = "127.0.0.1"; //overwritten //logResponse.SimPort = 0; //overwritten logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); try { @@ -265,6 +266,20 @@ namespace OpenSim.Framework.UserManagement return m_welcomeMessage; } + private LoginResponse.BuddyList ConvertFriendListItem(List LFL) + { + LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); + foreach (FriendListItem fl in LFL) + { + LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); + buddyitem.BuddyID = fl.Friend; + buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; + buddyitem.BuddyRightsGiven = (int) fl.FriendPerms; + buddylistreturn.AddNewBuddy(buddyitem); + + } + return buddylistreturn; + } /// /// Converts the inventory library skeleton into the form required by the rpc request. /// diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f913d2c..5d62e5e 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -197,6 +197,80 @@ namespace OpenSim.Framework.UserManagement } /// + /// Loads a user's friend list + /// + /// the UUID of the friend list owner + /// A List of FriendListItems that contains info about the user's friends + public List GetUserFriendList(LLUUID ownerID) + { + + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetUserFriendList(ownerID); + } + catch (Exception e) + { + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + + } + + public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.AddNewUserFriend(friendlistowner,friend,perms); + } + catch (Exception e) + { + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + } + + + public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.RemoveUserFriend(friendlistowner, friend); + } + catch (Exception e) + { + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + + public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.UpdateUserFriendPerms(friendlistowner, friend, perms); + } + catch (Exception e) + { + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + /// /// Loads a user agent by name (not called directly) /// /// The agent's name -- cgit v1.1 From b8975ecbd9510bd8e766cb4ca06c5a70110187cd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Dec 2007 23:20:49 +0000 Subject: Make it possible for new inventory 'libraries' to be added without changing the default OpenSimLibrary files. Additional library folders and items can be added in a separate directory and linked in by an entry to inventory/Libraries.xml --- .../Communications/Cache/LibraryRootFolder.cs | 200 ++++++++++++--------- OpenSim/Framework/Communications/LoginService.cs | 1 + 2 files changed, 116 insertions(+), 85 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index cb122df..38cffeb 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -64,35 +64,9 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(folderID, this); - string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml"); - if (File.Exists(foldersPath)) - { - try - { - XmlConfigSource source = new XmlConfigSource(foldersPath); - ReadFoldersFromFile(source); - } - catch (XmlException e) - { - MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString()); - } - } + LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); CreateLibraryItems(); - - string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); - if (File.Exists(itemsPath)) - { - try - { - XmlConfigSource source = new XmlConfigSource(itemsPath); - ReadItemsFromFile(source); - } - catch (XmlException e) - { - MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString()); - } - } } /// @@ -155,84 +129,140 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Read library inventory folders from an external source + /// Use the asset set information at path to load assets + /// + /// + /// + protected void LoadLibraries(string librariesControlPath) + { + MainLog.Instance.Verbose( + "LIBRARYINVENTORY", "Loading libraries control file {0}", librariesControlPath); + + LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); + } + + /// + /// Read a library set from config + /// + /// + protected void ReadLibraryFromConfig(IConfig config) + { + string foldersPath + = Path.Combine( + Util.inventoryDir(), config.GetString("foldersFile", "")); + + LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); + + string itemsPath + = Path.Combine( + Util.inventoryDir(), config.GetString("itemsFile", "")); + + LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); + } + + /// + /// Read a library inventory folder from a loaded configuration /// /// - private void ReadFoldersFromFile(IConfigSource source) - { - for (int i = 0; i < source.Configs.Count; i++) - { - IConfig config = source.Configs[i]; - - InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - - folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); - folderInfo.name = config.GetString("name", "unknown"); - folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); - folderInfo.type = (short)config.GetInt("type", 8); + private void ReadFolderFromConfig(IConfig config) + { + InventoryFolderImpl folderInfo = new InventoryFolderImpl(); + + folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); + folderInfo.name = config.GetString("name", "unknown"); + folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); + folderInfo.type = (short)config.GetInt("type", 8); + + folderInfo.agentID = libOwner; + folderInfo.version = 1; + + if (libraryFolders.ContainsKey(folderInfo.parentID)) + { + InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; - folderInfo.agentID = libOwner; - folderInfo.version = 1; + libraryFolders.Add(folderInfo.folderID, folderInfo); + parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); - if (libraryFolders.ContainsKey(folderInfo.parentID)) - { - InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; - - libraryFolders.Add(folderInfo.folderID, folderInfo); - parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); - // MainLog.Instance.Verbose( // "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); - } - else - { - MainLog.Instance.Warn( - "LIBRARYINVENTORY", - "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", - folderInfo.name, folderInfo.folderID, folderInfo.parentID); - } + } + else + { + MainLog.Instance.Warn( + "LIBRARYINVENTORY", + "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", + folderInfo.name, folderInfo.folderID, folderInfo.parentID); } } /// - /// Read library inventory items metadata from an external source + /// Read a library inventory item metadata from a loaded configuration /// /// - private void ReadItemsFromFile(IConfigSource source) + private void ReadItemFromConfig(IConfig config) { - for (int i = 0; i < source.Configs.Count; i++) + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = libOwner; + item.creatorsID = libOwner; + item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString())); + item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); + item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString())); + item.inventoryDescription = config.GetString("description", ""); + item.inventoryName = config.GetString("name", ""); + item.assetType = config.GetInt("assetType", 0); + item.invType = config.GetInt("inventoryType", 0); + item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); + + if (libraryFolders.ContainsKey(item.parentFolderID)) { - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = - new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); - item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); - item.parentFolderID - = new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString())); - item.inventoryDescription = source.Configs[i].GetString("description", ""); - item.inventoryName = source.Configs[i].GetString("name", ""); - item.assetType = source.Configs[i].GetInt("assetType", 0); - item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; - if (libraryFolders.ContainsKey(item.parentFolderID)) + parentFolder.Items.Add(item.inventoryID, item); + } + else + { + MainLog.Instance.Warn( + "LIBRARYINVENTORY", + "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", + item.inventoryName, item.inventoryID, item.parentFolderID); + } + } + + private delegate void ConfigAction(IConfig config); + + /// + /// Load the given configuration at a path and perform an action on each Config contained within it + /// + /// + /// + /// + private void LoadFromFile(string path, string fileDescription, ConfigAction action) + { + if (File.Exists(path)) + { + try { - InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; - - parentFolder.Items.Add(item.inventoryID, item); + XmlConfigSource source = new XmlConfigSource(path); + + for (int i = 0; i < source.Configs.Count; i++) + { + action(source.Configs[i]); + } } - else + catch (XmlException e) { - MainLog.Instance.Warn( - "LIBRARYINVENTORY", - "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", - item.inventoryName, item.inventoryID, item.parentFolderID); + MainLog.Instance.Error( + "LIBRARYINVENTORY", "Error loading {0} : {1}", path, e); } } + else + { + MainLog.Instance.Error( + "LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path); + } } /// diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index afc6c9a..0531d6a 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -280,6 +280,7 @@ namespace OpenSim.Framework.UserManagement } return buddylistreturn; } + /// /// Converts the inventory library skeleton into the form required by the rpc request. /// -- cgit v1.1 From b4c9b6bd19c0725ae5bf60172db75ebc63ba72c6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 1 Jan 2008 06:12:04 +0000 Subject: * You can add and remove a friend in standalone now within the same simulator. It saves. * You can add and remove a friend in grid mode now within the same simulator. It doesn't save yet. * I got rid of Mr. OpenSim as a friend.. he bothers me /:b... --- .../Communications/CommunicationsManager.cs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 02c54e1..0c6d53f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -152,6 +152,49 @@ namespace OpenSim.Framework.Communications } } + #region Friend Methods + /// + /// Adds a new friend to the database for XUser + /// + /// The agent that who's friends list is being added to + /// The agent that being added to the friends list of the friends list owner + /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects + public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + { + m_userService.AddNewUserFriend(friendlistowner, friend, perms); + } + + /// + /// Delete friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The Ex-friend agent + public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + { + m_userService.RemoveUserFriend(friendlistowner, friend); + } + + /// + /// Update permissions for friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The agent that is getting or loosing permissions + /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects + public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + { + m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); + } + /// + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// + /// The agent that we're retreiving the friends Data. + public List GetUserFriendList(LLUUID friendlistowner) + { + return m_userService.GetUserFriendList(friendlistowner); + } + + #endregion + #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) -- cgit v1.1 From 20653830fbd0c0104a62e9c1b71744284b77b754 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 2 Jan 2008 07:13:34 +0000 Subject: * Refactored out function to load specified AssetSet Xml This commit dedicated to 'Mohawk - Bad Girls (Need Love Too)' --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 2153fbf..318082b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -82,11 +82,11 @@ namespace OpenSim.Framework.Communications.Cache } } - public void LoadDefaultAssets() + public virtual void LoadDefaultAssets() { MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); - assetLoader.ForEachXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(StoreAsset); CommitAssets(); } -- cgit v1.1 From 4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 2 Jan 2008 09:07:11 +0000 Subject: * Trying to address TextureSender issues * The BlockingQueue exposes Contains so we can make sure we don't add a TextureSender to the queue if there's already one present * introduced some TryGetValue and various code convention stuff --- .../Framework/Communications/Cache/AssetCache.cs | 6 ++-- .../Communications/Cache/AssetServerBase.cs | 38 +++++++++++----------- .../Communications/Cache/SQLAssetServer.cs | 20 ++++++------ 3 files changed, 32 insertions(+), 32 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 664625e..bd3437b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -56,10 +56,10 @@ namespace OpenSim.Framework.Communications.Cache public Dictionary RequestLists = new Dictionary(); - private IAssetServer m_assetServer; + private readonly IAssetServer m_assetServer; - private Thread m_assetCacheThread; - private LogBase m_log; + private readonly Thread m_assetCacheThread; + private readonly LogBase m_log; /// /// diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 318082b..f0ed968 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -37,11 +37,11 @@ namespace OpenSim.Framework.Communications.Cache { public abstract class AssetServerBase : IAssetServer { - protected IAssetReceiver _receiver; - protected BlockingQueue _assetRequests; - protected Thread _localAssetServerThread; - protected IAssetProvider m_assetProviderPlugin; - protected object syncLock = new object(); + protected IAssetReceiver m_receiver; + protected BlockingQueue m_assetRequests; + protected Thread m_localAssetServerThread; + protected IAssetProvider m_assetProvider; + protected object m_syncLock = new object(); // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); @@ -71,14 +71,14 @@ namespace OpenSim.Framework.Communications.Cache MainLog.Instance.Verbose( "ASSET", "Asset {0} received from asset server", req.AssetID); - _receiver.AssetReceived(asset, req.IsTexture); + m_receiver.AssetReceived(asset, req.IsTexture); } else { MainLog.Instance.Error( "ASSET", "Asset {0} not found by asset server", req.AssetID); - _receiver.AssetNotFound(req.AssetID); + m_receiver.AssetNotFound(req.AssetID); } } @@ -95,11 +95,11 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); - _assetRequests = new BlockingQueue(); + m_assetRequests = new BlockingQueue(); - _localAssetServerThread = new Thread(RunRequests); - _localAssetServerThread.IsBackground = true; - _localAssetServerThread.Start(); + m_localAssetServerThread = new Thread(RunRequests); + m_localAssetServerThread.IsBackground = true; + m_localAssetServerThread.Start(); } private void RunRequests() @@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache { try { - AssetRequest req = _assetRequests.Dequeue(); + AssetRequest req = m_assetRequests.Dequeue(); ProcessRequest(req); } @@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Cache public void SetReceiver(IAssetReceiver receiver) { - _receiver = receiver; + m_receiver = receiver; } public void RequestAsset(LLUUID assetID, bool isTexture) @@ -129,23 +129,23 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req = new AssetRequest(); req.AssetID = assetID; req.IsTexture = isTexture; - _assetRequests.Enqueue(req); + m_assetRequests.Enqueue(req); MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); } public virtual void UpdateAsset(AssetBase asset) { - lock (syncLock) + lock (m_syncLock) { - m_assetProviderPlugin.UpdateAsset(asset); - m_assetProviderPlugin.CommitAssets(); + m_assetProvider.UpdateAsset(asset); + m_assetProvider.CommitAssets(); } } public void StoreAndCommitAsset(AssetBase asset) { - lock (syncLock) + lock (m_syncLock) { StoreAsset(asset); CommitAssets(); @@ -154,7 +154,7 @@ namespace OpenSim.Framework.Communications.Cache public virtual void Close() { - _localAssetServerThread.Abort(); + m_localAssetServerThread.Abort(); } public void SetServerInfo(string ServerUrl, string ServerKey) diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index e4c278f..0a141c3 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache public SQLAssetServer(IAssetProvider assetProvider) { - m_assetProviderPlugin = assetProvider; + m_assetProvider = assetProvider; } public void AddPlugin(string FileName) @@ -58,12 +58,12 @@ namespace OpenSim.Framework.Communications.Cache { IAssetProvider plug = (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_assetProviderPlugin = plug; - m_assetProviderPlugin.Initialise(); + m_assetProvider = plug; + m_assetProvider.Initialise(); MainLog.Instance.Verbose("AssetStorage", - "Added " + m_assetProviderPlugin.Name + " " + - m_assetProviderPlugin.Version); + "Added " + m_assetProvider.Name + " " + + m_assetProvider.Version); } } } @@ -74,15 +74,15 @@ namespace OpenSim.Framework.Communications.Cache { base.Close(); - m_assetProviderPlugin.CommitAssets(); + m_assetProvider.CommitAssets(); } protected override AssetBase GetAsset(AssetRequest req) { AssetBase asset; - lock (syncLock) + lock (m_syncLock) { - asset = m_assetProviderPlugin.FetchAsset(req.AssetID); + asset = m_assetProvider.FetchAsset(req.AssetID); } return asset; @@ -90,12 +90,12 @@ namespace OpenSim.Framework.Communications.Cache protected override void StoreAsset(AssetBase asset) { - m_assetProviderPlugin.CreateAsset(asset); + m_assetProvider.CreateAsset(asset); } protected override void CommitAssets() { - m_assetProviderPlugin.CommitAssets(); + m_assetProvider.CommitAssets(); } } } \ No newline at end of file -- cgit v1.1 From db3edff5d5f1c9a31f377db77d1ac4e1fa685623 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 5 Jan 2008 06:05:25 +0000 Subject: * Applying jhurliman's LLSD login enablement patch. * I'm keeping it deactivated until some issues are resolved. * I'm patching it in deactivated so the patch doesn't get outdated * I've deactivated it by commenting out the handler for the application/xml+llsd content type. * While I've tested this as much as possible on my setup and found the deactivated code doesn't cause any problems, consider this update experimental (event though it's deactivated) --- OpenSim/Framework/Communications/LoginResponse.cs | 161 ++++++++++++++++++++- OpenSim/Framework/Communications/LoginService.cs | 132 +++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 38 ++++- 3 files changed, 329 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 954aecb..2239a9c 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -30,6 +30,7 @@ using System; using System.Collections; using System.Collections.Generic; using libsecondlife; +using libsecondlife.StructuredData; using Nwc.XmlRpc; using OpenSim.Framework.Console; @@ -197,11 +198,31 @@ namespace OpenSim.Framework.UserManagement return (xmlRpcResponse); } // GenerateResponse + public LLSD GenerateFailureResponseLLSD(string reason, string message, string login) + { + LLSDMap map = new LLSDMap(); + + // Ensure Login Failed message/reason; + ErrorMessage = message; + ErrorReason = reason; + + map["reason"] = LLSD.FromString(ErrorReason); + map["message"] = LLSD.FromString(ErrorMessage); + map["login"] = LLSD.FromString(login); + + return map; + } + public XmlRpcResponse CreateFailedResponse() { return (CreateLoginFailedResponse()); } // CreateErrorConnectingToGridResponse() + public LLSD CreateFailedResponseLLSD() + { + return CreateLoginFailedResponseLLSD(); + } + public XmlRpcResponse CreateLoginFailedResponse() { return @@ -210,6 +231,14 @@ namespace OpenSim.Framework.UserManagement "false")); } // LoginFailedResponse + public LLSD CreateLoginFailedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false"); + } + public XmlRpcResponse CreateAlreadyLoggedInResponse() { return @@ -218,6 +247,14 @@ namespace OpenSim.Framework.UserManagement "false")); } // CreateAlreadyLoggedInResponse() + public LLSD CreateAlreadyLoggedInResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", + "false"); + } + public XmlRpcResponse CreateDeadRegionResponse() { return @@ -226,6 +263,14 @@ namespace OpenSim.Framework.UserManagement "false")); } + public LLSD CreateDeadRegionResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false"); + } + public XmlRpcResponse CreateGridErrorResponse() { return @@ -234,6 +279,14 @@ namespace OpenSim.Framework.UserManagement "false")); } + public LLSD CreateGridErrorResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false"); + } + #endregion public XmlRpcResponse ToXmlRpcResponse() @@ -317,6 +370,112 @@ namespace OpenSim.Framework.UserManagement } } // ToXmlRpcResponse + public LLSD ToLLSDResponse() + { + try + { + LLSDMap map = new LLSDMap(); + + map["first_name"] = LLSD.FromString(Firstname); + map["last_name"] = LLSD.FromString(Lastname); + map["agent_access"] = LLSD.FromString(agentAccess); + + map["sim_port"] = LLSD.FromInteger(SimPort); + map["sim_ip"] = LLSD.FromString(SimAddress); + + map["agent_id"] = LLSD.FromUUID(AgentID); + map["session_id"] = LLSD.FromUUID(SessionID); + map["secure_session_id"] = LLSD.FromUUID(SecureSessionID); + map["circuit_code"] = LLSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = LLSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + + #region Login Flags + + LLSDMap loginFlagsLLSD = new LLSDMap(); + loginFlagsLLSD["daylight_savings"] = LLSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = LLSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = LLSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = LLSD.FromString(EverLoggedIn); + map["login-flags"] = WrapLLSDMap(loginFlagsLLSD); + + #endregion Login Flags + + #region Global Textures + + LLSDMap globalTexturesLLSD = new LLSDMap(); + globalTexturesLLSD["sun_texture_id"] = LLSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = LLSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = LLSD.FromString(MoonTexture); + + map["global-textures"] = WrapLLSDMap(globalTexturesLLSD); + + #endregion Global Textures + + map["seed_capability"] = LLSD.FromString(seedCapability); + + // FIXME: Need a function that will convert these ArrayLists in to LLSDArrays, + // and convert the data inside them to LLSD objects as well + + //map["event_categories"] = eventCategories; + //map["event_notifications"] = new LLSDArray(); // todo + //map["classified_categories"] = classifiedCategories; + + #region UI Config + + LLSDMap uiConfigLLSD = new LLSDMap(); + uiConfigLLSD["allow_first_life"] = LLSD.FromString(allowFirstLife); + map["ui-config"] = WrapLLSDMap(uiConfigLLSD); + + #endregion UI Config + + #region Inventory + + //map["inventory-skeleton"] = agentInventory; + //map["inventory-skel-lib"] = inventoryLibrary; + //map["inventory-root"] = inventoryRoot; + //map["inventory-lib-root"] = inventoryLibRoot; + //map["inventory-lib-owner"] = inventoryLibraryOwner; + + #endregion Inventory + + map["gestures"] = new LLSDArray(); // todo + + //responseData["initial-outfit"] = initialOutfit; + //responseData["start_location"] = startLocation; + + map["seed_capability"] = LLSD.FromString(seedCapability); + map["home"] = LLSD.FromString(home); + map["look_at"] = LLSD.FromString(lookAt); + map["message"] = LLSD.FromString(welcomeMessage); + map["region_x"] = LLSD.FromInteger(RegionX * 256); + map["region_y"] = LLSD.FromInteger(RegionY * 256); + + if (m_buddyList != null) + { + //map["buddy-list"] = m_buddyList.ToArray(); + } + + map["login"] = LLSD.FromString("true"); + + return map; + } + catch (Exception e) + { + MainLog.Instance.Warn( + "CLIENT", + "LoginResponse: Error creating XML-RPC Response: " + e.Message + ); + return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); + } + } + + private LLSDArray WrapLLSDMap(LLSDMap wrapMe) + { + LLSDArray array = new LLSDArray(); + array.Add(wrapMe); + return array; + } + public void SetEventCategories(string category, string value) { // this.eventCategoriesHash[category] = value; @@ -591,4 +750,4 @@ namespace OpenSim.Framework.UserManagement } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 0531d6a..9cfac1c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -31,6 +31,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading; using libsecondlife; +using libsecondlife.StructuredData; using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; @@ -198,6 +199,132 @@ namespace OpenSim.Framework.UserManagement } } + public LLSD LLSDLoginMethod(LLSD request) + { + // Temporary fix + m_loginMutex.WaitOne(); + + try + { + bool GoodLogin = false; + + UserProfileData userProfile = null; + LoginResponse logResponse = new LoginResponse(); + + if (request.Type == LLSDType.Map) + { + LLSDMap map = (LLSDMap)request; + + if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) + { + string firstname = map["first"].AsString(); + string lastname = map["last"].AsString(); + string passwd = map["passwd"].AsString(); + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + MainLog.Instance.Verbose( + "LOGIN", + "Could not find a profile for " + firstname + " " + lastname); + + return logResponse.CreateLoginFailedResponseLLSD(); + } + + GoodLogin = AuthenticateUser(userProfile, passwd); + } + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponseLLSD(); + } + else + { + // If we already have a session... + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + { + userProfile.currentAgent = null; + m_userManager.CommitAgent(ref userProfile); + + // Reject the login + return logResponse.CreateAlreadyLoggedInResponseLLSD(); + } + + // Otherwise... + // Create a new agent session + CreateAgent(userProfile, request); + + try + { + LLUUID agentID = userProfile.UUID; + + // Inventory Library Section + InventoryData inventData = CreateInventoryData(agentID); + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = inventData.RootFolderID; + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; + logResponse.AgentID = agentID.ToString(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + logResponse.InventoryLibRoot = InventoryLibRoot; + + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.CircuitCode = (Int32)circode; + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten + logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + + try + { + CustomiseResponse(logResponse, userProfile); + } + catch (Exception ex) + { + MainLog.Instance.Verbose("LOGIN", ex.ToString()); + return logResponse.CreateDeadRegionResponseLLSD(); + } + + CommitAgent(ref userProfile); + + return logResponse.ToLLSDResponse(); + } + catch (Exception ex) + { + MainLog.Instance.Verbose("LOGIN", ex.ToString()); + return logResponse.CreateFailedResponseLLSD(); + } + } + } + finally + { + m_loginMutex.ReleaseMutex(); + } + } + /// /// Customises the login response and fills in missing values. /// @@ -246,6 +373,11 @@ namespace OpenSim.Framework.UserManagement m_userManager.CreateAgent(profile, request); } + public void CreateAgent(UserProfileData profile, LLSD request) + { + m_userManager.CreateAgent(profile, request); + } + /// /// /// diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 5d62e5e..bea56ea 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Reflection; using System.Security.Cryptography; using libsecondlife; +using libsecondlife.StructuredData; using Nwc.XmlRpc; using OpenSim.Framework.Console; @@ -394,6 +395,41 @@ namespace OpenSim.Framework.UserManagement profile.currentAgent = agent; } + public void CreateAgent(UserProfileData profile, LLSD request) + { + UserAgentData agent = new UserAgentData(); + + // User connection + agent.agentOnline = true; + + // Generate sessions + RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); + byte[] randDataS = new byte[16]; + byte[] randDataSS = new byte[16]; + rand.GetBytes(randDataS); + rand.GetBytes(randDataSS); + + agent.secureSessionID = new LLUUID(randDataSS, 0); + agent.sessionID = new LLUUID(randDataS, 0); + + // Profile UUID + agent.UUID = profile.UUID; + + // Current position (from Home) + agent.currentHandle = profile.homeRegion; + agent.currentPos = profile.homeLocation; + + // What time did the user login? + agent.loginTime = Util.UnixTimeSinceEpoch(); + agent.logoutTime = 0; + + // Current location + agent.regionID = LLUUID.Zero; // Fill in later + agent.currentRegion = LLUUID.Zero; // Fill in later + + profile.currentAgent = agent; + } + /// /// Saves a target agent to the database /// @@ -445,4 +481,4 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); public abstract UserProfileData SetupMasterUser(LLUUID uuid); } -} \ No newline at end of file +} -- cgit v1.1 From 19ed64b11456b990ecbf6f6d4d33112005cd3722 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Wed, 9 Jan 2008 03:52:07 +0000 Subject: Third part of CharlieO's library rework. We now have library organization! Thanks CharlieO! --- .../Communications/Cache/LibraryRootFolder.cs | 67 +++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 38cffeb..46ae9ce 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -66,47 +66,50 @@ namespace OpenSim.Framework.Communications.Cache LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); - CreateLibraryItems(); + // CreateLibraryItems(); } /// /// Hardcoded item creation. Please don't add any more items here - future items should be created /// in the xml in the bin/inventory folder. /// - private void CreateLibraryItems() - { - InventoryItemBase item = - CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), - new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", - (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); + /// + /// Commented the following out due to sending it all through xml, remove this section once this is provin to work stable. + /// + //private void CreateLibraryItems() + //{ + // InventoryItemBase item = + // CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), + // new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", + // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); + // item.inventoryCurrentPermissions = 0; + // item.inventoryNextPermissions = 0; + // Items.Add(item.inventoryID, item); - item = - CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), - new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", - (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); + // item = + // CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), + // new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", + // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); + // item.inventoryCurrentPermissions = 0; + // item.inventoryNextPermissions = 0; + // Items.Add(item.inventoryID, item); - item = - CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), - new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", - (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); + // item = + // CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), + // new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", + // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); + // item.inventoryCurrentPermissions = 0; + // item.inventoryNextPermissions = 0; + // Items.Add(item.inventoryID, item); - item = - CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), - new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", - (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); - } + // item = + // CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), + // new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", + // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); + // item.inventoryCurrentPermissions = 0; + // item.inventoryNextPermissions = 0; + // Items.Add(item.inventoryID, item); + //} public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) -- cgit v1.1 From bafdac787408dcffb4ba28be159d44896cfe33b6 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Wed, 9 Jan 2008 03:57:53 +0000 Subject: dump_assets_to_file=true will now cause the asset to go into a UserAssets subdirectory of bin instead of cluttering up your bin directory (Thanks CharlieO!) --- .../Communications/Cache/AssetTransactions.cs | 19 ++++++-- .../Framework/Communications/Capabilities/Caps.cs | 53 +++++++++++++++++++--- 2 files changed, 62 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 8aa567c..dd1f8ba 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -237,10 +237,23 @@ namespace OpenSim.Framework.Communications.Cache SaveAssetToFile(filename, Asset.Data); } } - + ///Left this in and commented in case there are unforseen issues + //private void SaveAssetToFile(string filename, byte[] data) + //{ + // FileStream fs = File.Create(filename); + // BinaryWriter bw = new BinaryWriter(fs); + // bw.Write(data); + // bw.Close(); + // fs.Close(); + //} private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); + string assetPath = "UserAssets"; + if (!Directory.Exists(assetPath)) + { + Directory.CreateDirectory(assetPath); + } + FileStream fs = File.Create(Path.Combine(assetPath, filename)); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); @@ -428,4 +441,4 @@ namespace OpenSim.Framework.Communications.Cache #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 4b42046..74d8125 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -536,10 +536,23 @@ namespace OpenSim.Region.Capabilities return res; } - + ///Left this in and commented in case there are unforseen issues + //private void SaveAssetToFile(string filename, byte[] data) + //{ + // FileStream fs = File.Create(filename); + // BinaryWriter bw = new BinaryWriter(fs); + // bw.Write(data); + // bw.Close(); + // fs.Close(); + //} private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); + string assetPath = "UserAssets"; + if (!Directory.Exists(assetPath)) + { + Directory.CreateDirectory(assetPath); + } + FileStream fs = File.Create(Path.Combine(assetPath, filename)); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); @@ -603,10 +616,23 @@ namespace OpenSim.Region.Capabilities return res; } - + ///Left this in and commented in case there are unforseen issues + //private void SaveAssetToFile(string filename, byte[] data) + //{ + // FileStream fs = File.Create(filename); + // BinaryWriter bw = new BinaryWriter(fs); + // bw.Write(data); + // bw.Close(); + // fs.Close(); + //} private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); + string assetPath = "UserAssets"; + if (!Directory.Exists(assetPath)) + { + Directory.CreateDirectory(assetPath); + } + FileStream fs = File.Create(Path.Combine(assetPath, filename)); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); @@ -693,10 +719,23 @@ namespace OpenSim.Region.Capabilities // XXX Maybe this should be some meaningful error packet return null; } - + ///Left this in and commented in case there are unforseen issues + //private void SaveAssetToFile(string filename, byte[] data) + //{ + // FileStream fs = File.Create(filename); + // BinaryWriter bw = new BinaryWriter(fs); + // bw.Write(data); + // bw.Close(); + // fs.Close(); + //} private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); + string assetPath = "UserAssets"; + if (!Directory.Exists(assetPath)) + { + Directory.CreateDirectory(assetPath); + } + FileStream fs = File.Create(Path.Combine(assetPath, filename)); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); @@ -704,4 +743,4 @@ namespace OpenSim.Region.Capabilities } } } -} \ No newline at end of file +} -- cgit v1.1 From c0252073d0f1dbf01f82777f1451974eee4fa7df Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 9 Jan 2008 09:31:07 +0000 Subject: * removed another superfluous debug message --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f0ed968..09f8a0c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -68,8 +68,8 @@ namespace OpenSim.Framework.Communications.Cache if (asset != null) { - MainLog.Instance.Verbose( - "ASSET", "Asset {0} received from asset server", req.AssetID); + //MainLog.Instance.Verbose( + // "ASSET", "Asset {0} received from asset server", req.AssetID); m_receiver.AssetReceived(asset, req.IsTexture); } -- cgit v1.1 From 49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 9 Jan 2008 18:57:03 +0000 Subject: * This may be broken.. it hasn't been tested, however I wanted to get the last database changes in before sdauge changes them significantly. --- OpenSim/Framework/Communications/LoginService.cs | 149 ++++++++++++++++++++- .../Framework/Communications/UserManagerBase.cs | 17 +++ 2 files changed, 162 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 9cfac1c..f0a0a0b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Threading; using libsecondlife; using libsecondlife.StructuredData; @@ -79,7 +80,7 @@ namespace OpenSim.Framework.UserManagement Hashtable requestData = (Hashtable) request.Params[0]; bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && - requestData.Contains("passwd")); + (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); bool GoodLogin = false; UserProfileData userProfile; @@ -89,7 +90,8 @@ namespace OpenSim.Framework.UserManagement { string firstname = (string) requestData["first"]; string lastname = (string) requestData["last"]; - string passwd = (string) requestData["passwd"]; + + userProfile = GetTheUser(firstname, lastname); if (userProfile == null) @@ -100,8 +102,29 @@ namespace OpenSim.Framework.UserManagement return logResponse.CreateLoginFailedResponse(); } + if (requestData.Contains("passwd")) + { + string passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else if (requestData.Contains("web_login_key")) + { + LLUUID webloginkey = null; + try + { + webloginkey = new LLUUID((string)requestData["web_login_key"]); + } + catch (System.Exception) + { + return logResponse.CreateFailedResponse(); + } + GoodLogin = AuthenticateUser(userProfile, webloginkey); - GoodLogin = AuthenticateUser(userProfile, passwd); + } + else + { + return logResponse.CreateFailedResponse(); + } } else { @@ -334,6 +357,105 @@ namespace OpenSim.Framework.UserManagement { } + public Hashtable ProcessHTMLLogin(Hashtable keysvals) + { + Hashtable returnactions = new Hashtable(); + int statuscode = 200; + + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = GetDefaultLoginForm(); + + if (keysvals.ContainsKey("show_login_form")) + { + if ((string)keysvals["show_login_form"] == "TRUE") + { + + } + else + { + + + } + + } + return returnactions; + + } + + public string GetLoginForm() + { + string file = Path.Combine(Util.configDir(), "http_loginform.html"); + if (!File.Exists(file)) + return GetDefaultLoginForm(); + + StreamReader sr = File.OpenText(file); + string result = sr.ReadToEnd(); + sr.Close(); + return result; + } + + public string GetDefaultLoginForm() + { + string responseString = + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + "Second Life Login"; + responseString = responseString + ""; + responseString = responseString + "
"; + + responseString = responseString + "
"; + + responseString = responseString + "
[$errors]
"; + responseString = responseString + "
"; + responseString = responseString + "First Name:"; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + "
"; + responseString = responseString + "Last Name:"; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + "
"; + responseString = responseString + "Password:"; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + "
"; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + "
Connecting...
"; + + responseString = responseString + "
"; + responseString = responseString + "Create new account | "; + responseString = responseString + "Forgot password?"; + responseString = responseString + "
"; + + responseString = responseString + "
[$clientchannelinfo] | [$clientversion]=[$clientlanguage]
"; + responseString = responseString + "
"; + responseString = responseString + ""; + responseString = responseString + "
"; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + return responseString; + } + /// /// Saves a target agent to the database /// @@ -353,14 +475,33 @@ namespace OpenSim.Framework.UserManagement /// Authenticated? public virtual bool AuthenticateUser(UserProfileData profile, string password) { + bool passwordSuccess = false; MainLog.Instance.Verbose( "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + // Web Login method seems to also occasionally send the hashed password itself + + password = password.Remove(0, 3); //remove $1$ string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.passwordHash.Equals(password.ToString(),StringComparison.InvariantCultureIgnoreCase)); + + return passwordSuccess; + } + + public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) + { + bool passwordSuccess = false; + MainLog.Instance.Verbose( + "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + + // Match web login key unless it's the default weblogin key LLUUID.Zero + passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero); + + return passwordSuccess; } /// diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bea56ea..2d72629 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -222,6 +222,23 @@ namespace OpenSim.Framework.UserManagement } + public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) + { + + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.StoreWebLoginKey(agentID, webLoginKey); + } + catch (Exception e) + { + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { foreach (KeyValuePair plugin in _plugins) -- cgit v1.1 From 85fe8ed0857c075ebefabbad8a670499e047f41a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 9 Jan 2008 22:05:28 +0000 Subject: * This update enables the web_login method. * Remember, the client doesn't support web_login to other grids in the current RC, however the next RC will. --- OpenSim/Framework/Communications/LoginService.cs | 148 ++++++++++++++++++++--- 1 file changed, 134 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f0a0a0b..04b8501 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -30,6 +30,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using System.Text.RegularExpressions; using System.Threading; using libsecondlife; using libsecondlife.StructuredData; @@ -359,21 +360,103 @@ namespace OpenSim.Framework.UserManagement public Hashtable ProcessHTMLLogin(Hashtable keysvals) { + + // Matches all unspecified characters + // Currently specified,; lowercase letters, upper case letters, numbers, underline + // period, space, parens, and dash. + + Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); + Hashtable returnactions = new Hashtable(); int statuscode = 200; - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = GetDefaultLoginForm(); + string firstname = ""; + string lastname = ""; + string location = ""; + string region =""; + string grid = ""; + string channel = ""; + string version = ""; + string lang = ""; + string password = ""; + string errormessages = ""; + + // the client requires the HTML form field be named 'username' + // however, the data it sends when it loads the first time is 'firstname' + // another one of those little nuances. + + + if (keysvals.Contains("firstname")) + firstname = wfcut.Replace((string)keysvals["firstname"],"",99999); + if (keysvals.Contains("username")) + firstname = wfcut.Replace((string)keysvals["username"],"",99999); + + if (keysvals.Contains("lastname")) + lastname = wfcut.Replace((string)keysvals["lastname"],"",99999); + + if (keysvals.Contains("location")) + location = wfcut.Replace((string)keysvals["location"],"",99999); + + if (keysvals.Contains("region")) + region = wfcut.Replace((string)keysvals["region"],"",99999); + + if (keysvals.Contains("grid")) + grid = wfcut.Replace((string)keysvals["grid"],"",99999); + + if (keysvals.Contains("channel")) + channel = wfcut.Replace((string)keysvals["channel"],"",99999); + + if (keysvals.Contains("version")) + version = wfcut.Replace((string)keysvals["version"],"",99999); + + if (keysvals.Contains("lang")) + lang = wfcut.Replace((string)keysvals["lang"],"",99999); + + if (keysvals.Contains("password")) + password = wfcut.Replace((string)keysvals["password"], "", 99999); + + + // load our login form. + string loginform = GetLoginForm(firstname,lastname,location,region,grid,channel,version,lang,password,errormessages); if (keysvals.ContainsKey("show_login_form")) { if ((string)keysvals["show_login_form"] == "TRUE") { - + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; } else { + UserProfileData user = GetTheUser(firstname, lastname); + bool goodweblogin = false; + if (user != null) + goodweblogin = AuthenticateUser(user, password); + + if (goodweblogin) + { + LLUUID webloginkey = LLUUID.Random(); + m_userManager.StoreWebLoginKey(user.UUID, webloginkey); + statuscode = 301; + + string redirectURL = "secondlife:///app/login?first_name=" + firstname + "&last_name=" + + lastname + + "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString(); + + returnactions["int_response_code"] = statuscode; + returnactions["str_redirect_location"] = redirectURL; + returnactions["str_response_string"] = "GoodLogin"; + } + else + { + errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; + + loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; + + } } @@ -382,16 +465,36 @@ namespace OpenSim.Framework.UserManagement } - public string GetLoginForm() + public string GetLoginForm(string firstname, string lastname, string location, string region, + string grid, string channel, string version, string lang, + string password, string errormessages) { + // inject our values in the form at the markers + + string loginform=""; string file = Path.Combine(Util.configDir(), "http_loginform.html"); if (!File.Exists(file)) - return GetDefaultLoginForm(); - - StreamReader sr = File.OpenText(file); - string result = sr.ReadToEnd(); - sr.Close(); - return result; + { + loginform = GetDefaultLoginForm(); + } + else + { + StreamReader sr = File.OpenText(file); + loginform = sr.ReadToEnd(); + sr.Close(); + } + + loginform = loginform.Replace("[$firstname]", firstname); + loginform = loginform.Replace("[$lastname]", lastname); + loginform = loginform.Replace("[$location]", location); + loginform = loginform.Replace("[$region]", region); + loginform = loginform.Replace("[$grid]", grid); + loginform = loginform.Replace("[$channel]", channel); + loginform = loginform.Replace("[$version]", version); + loginform = loginform.Replace("[$lang]", lang); + loginform = loginform.Replace("[$password]", password); + loginform = loginform.Replace("[$errors]", errormessages); + return loginform; } public string GetDefaultLoginForm() @@ -405,7 +508,7 @@ namespace OpenSim.Framework.UserManagement responseString = responseString + ""; responseString = responseString + ""; responseString = responseString + "Second Life Login"; - responseString = responseString + ""; + responseString = responseString + "
"; responseString = responseString + "
"; responseString = responseString + "
"; @@ -434,6 +537,11 @@ namespace OpenSim.Framework.UserManagement responseString = responseString + ""; responseString = responseString + ""; responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; + responseString = responseString + ""; responseString = responseString + "
"; responseString = responseString + ""; responseString = responseString + "
"; @@ -444,7 +552,7 @@ namespace OpenSim.Framework.UserManagement responseString = responseString + "Forgot password?"; responseString = responseString + "
"; - responseString = responseString + "
[$clientchannelinfo] | [$clientversion]=[$clientlanguage]
"; + responseString = responseString + "
[$channel] | [$version]=[$lang]
"; responseString = responseString + ""; responseString = responseString + ""; - responseString = responseString + ""; - responseString = responseString + ""; - responseString = responseString + ""; - responseString = responseString + ""; + responseString += "
"; + + responseString += "
[$errors]
"; + responseString += "
"; + responseString += "First Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Last Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Password:"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += ""; + responseString += "
"; + responseString += "
Connecting...
"; + + responseString += "
"; + responseString += " | "; + responseString += ""; + responseString += "
"; + + responseString += "
[$channel] | [$version]=[$lang]
"; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; return responseString; } @@ -611,7 +602,6 @@ namespace OpenSim.Framework.UserManagement return m_userManager.CommitAgent(ref profile); } - /// /// Checks a user against it's password hash /// @@ -638,7 +628,7 @@ namespace OpenSim.Framework.UserManagement //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.passwordHash.Equals(password,StringComparison.InvariantCultureIgnoreCase)); + || profile.passwordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); return passwordSuccess; } @@ -699,7 +689,6 @@ namespace OpenSim.Framework.UserManagement buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; buddyitem.BuddyRightsGiven = (int) fl.FriendPerms; buddylistreturn.AddNewBuddy(buddyitem); - } return buddylistreturn; } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b8e3114..48807c2 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -194,7 +194,6 @@ namespace OpenSim.Framework.UserManagement /// A List of FriendListItems that contains info about the user's friends public List GetUserFriendList(LLUUID ownerID) { - foreach (KeyValuePair plugin in _plugins) { try @@ -208,12 +207,10 @@ namespace OpenSim.Framework.UserManagement } return null; - } public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) { - foreach (KeyValuePair plugin in _plugins) { try @@ -240,10 +237,8 @@ namespace OpenSim.Framework.UserManagement m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); } } - } - public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { foreach (KeyValuePair plugin in _plugins) @@ -273,6 +268,7 @@ namespace OpenSim.Framework.UserManagement } } } + /// /// Loads a user agent by name (not called directly) /// @@ -295,7 +291,10 @@ namespace OpenSim.Framework.UserManagement return null; } - // TODO: document + /// + /// Resets the currentAgent in the user profile + /// + /// The agent's ID public void clearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); @@ -459,7 +458,6 @@ namespace OpenSim.Framework.UserManagement // If currentagent is null, we can't reference it here or the UserServer crashes! m_log.Info("[LOGOUT]: didn't save logout position: " + userid.ToString()); } - } else { -- cgit v1.1 From 175dc285ff5162984a188edd2dc57f0aa0c6a2af Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 18 Mar 2008 03:51:59 +0000 Subject: Added copyright messages. Set svn:eol-style. Minor cleanup. --- .../Capabilities/LLSDInventoryItem.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 784b41c..48b1f3d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using libsecondlife; -- cgit v1.1 From 47180080f0f4b93c60232b47ca4e093bd7c73a1d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 18 Mar 2008 05:16:43 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/CAPSService.cs | 53 ++- .../Communications/Cache/AgentAssetTransactions.cs | 54 +-- .../Cache/AgentAssetTransactionsManager.cs | 53 ++- .../Framework/Communications/Cache/AssetCache.cs | 465 ++++++++++----------- .../Framework/Communications/Cache/AssetServer.cs | 53 ++- .../Communications/Cache/AssetServerBase.cs | 51 ++- .../Communications/Cache/CachedUserInfo.cs | 54 +-- .../Communications/Cache/GridAssetClient.cs | 51 ++- .../Communications/Cache/InventoryFolderImpl.cs | 54 +-- .../Communications/Cache/LibraryRootFolder.cs | 51 ++- .../Communications/Cache/SQLAssetServer.cs | 52 +-- .../Cache/UserProfileCacheService.cs | 53 ++- .../Framework/Communications/Capabilities/Caps.cs | 52 +-- .../Framework/Communications/Capabilities/LLSD.cs | 53 ++- .../Communications/Capabilities/LLSDArray.cs | 54 +-- .../Capabilities/LLSDAssetUploadComplete.cs | 54 +-- .../Capabilities/LLSDAssetUploadRequest.cs | 53 ++- .../Capabilities/LLSDAssetUploadResponse.cs | 51 ++- .../Communications/Capabilities/LLSDCapEvent.cs | 54 +-- .../Communications/Capabilities/LLSDCapsDetails.cs | 53 ++- .../Communications/Capabilities/LLSDEmpty.cs | 54 +-- .../Communications/Capabilities/LLSDHelpers.cs | 54 +-- .../Communications/Capabilities/LLSDItemUpdate.cs | 53 ++- .../Communications/Capabilities/LLSDMapLayer.cs | 54 +-- .../Capabilities/LLSDMapLayerResponse.cs | 54 +-- .../Communications/Capabilities/LLSDMapRequest.cs | 53 ++- .../Communications/Capabilities/LLSDMethod.cs | 53 ++- .../Capabilities/LLSDStreamHandler.cs | 53 ++- .../LLSDTaskInventoryUploadComplete.cs | 54 +-- .../Capabilities/LLSDTaskScriptUpdate.cs | 53 ++- .../Communications/Capabilities/LLSDTest.cs | 54 +-- .../Communications/Capabilities/LLSDType.cs | 54 +-- .../Communications/CommunicationsManager.cs | 52 +-- OpenSim/Framework/Communications/IGridServices.cs | 54 +-- .../Communications/IInterRegionCommunications.cs | 54 +-- .../Framework/Communications/IInventoryServices.cs | 53 ++- .../Communications/InventoryServiceBase.cs | 53 ++- OpenSim/Framework/Communications/LoginResponse.cs | 51 ++- OpenSim/Framework/Communications/LoginService.cs | 51 ++- .../Communications/Properties/AssemblyInfo.cs | 56 +-- .../RestClient/GenericAsyncResult.cs | 55 ++- .../Communications/RestClient/RestClient.cs | 51 ++- .../Framework/Communications/UserManagerBase.cs | 51 ++- 43 files changed, 1331 insertions(+), 1361 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index ada1405..133ba0d 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using OpenSim.Framework.Servers; @@ -51,4 +50,4 @@ namespace OpenSim.Framework.Communications return System.String.Empty; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs index 4aefe83..8ab958a 100644 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + //moved to a module, left here until the module is found to have no problems /* using System; @@ -555,4 +555,4 @@ namespace OpenSim.Framework.Communications.Cache #endregion } } -*/ \ No newline at end of file +*/ diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs index 97b716c..e9d042d 100644 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs +++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ //moved to a module, left here until the module is found to have no problems /* @@ -203,4 +202,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -*/ \ No newline at end of file +*/ diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 35a0088..ed2fcf4 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; @@ -131,7 +130,6 @@ namespace OpenSim.Framework.Communications.Cache m_log.InfoFormat("Image data: {0}kb Asset data: {1}kb", imageBytes / 1024, assetBytes / 1024); - } /// @@ -179,21 +177,21 @@ namespace OpenSim.Framework.Communications.Cache /// Process the asset queue which holds data which is packeted up and sent /// directly back to the client. /// - public void RunAssetManager() + public void RunAssetManager() + { + while (true) { - while (true) + try { - try - { - ProcessAssetQueue(); - Thread.Sleep(500); - } - catch (Exception e) - { - m_log.Error("[ASSET CACHE]: " + e.ToString()); - } + ProcessAssetQueue(); + Thread.Sleep(500); + } + catch (Exception e) + { + m_log.Error("[ASSET CACHE]: " + e.ToString()); } } + } /// /// Only get an asset if we already have it in the cache. @@ -508,19 +506,19 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver public void AssetNotFound(LLUUID assetID) { - // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); // Notify requesters for this asset AssetRequestsList reqList = null; lock (RequestLists) { - // m_log.Info("AssetCache: Lock taken on requestLists (AssetNotFound #1)"); + // m_log.Info("AssetCache: Lock taken on requestLists (AssetNotFound #1)"); if (RequestLists.ContainsKey(assetID)) { reqList = RequestLists[assetID]; } } - // m_log.Info("AssetCache: Lock released on requestLists (AssetNotFound #1)"); + // m_log.Info("AssetCache: Lock released on requestLists (AssetNotFound #1)"); if (reqList != null) { @@ -539,205 +537,202 @@ namespace OpenSim.Framework.Communications.Cache req.Callback(assetID, null); } } + } + /// + /// Calculate the number of packets required to send the asset to the client. + /// + /// + /// + private int CalculateNumPackets(byte[] data) + { + const uint m_maxPacketSize = 600; + int numPackets = 1; + + if (data.LongLength > m_maxPacketSize) + { + // over max number of bytes so split up file + long restData = data.LongLength - m_maxPacketSize; + int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); + numPackets += restPackets; + } + + return numPackets; } - - /// - /// Calculate the number of packets required to send the asset to the client. - /// - /// - /// - private int CalculateNumPackets(byte[] data) - { - const uint m_maxPacketSize = 600; - int numPackets = 1; - - if (data.LongLength > m_maxPacketSize) - { - // over max number of bytes so split up file - long restData = data.LongLength - m_maxPacketSize; - int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); - numPackets += restPackets; - } - - return numPackets; - } - - /// - /// Make an asset request the result of which will be packeted up and sent directly back to the client. - /// - /// - /// - public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) - { - LLUUID requestID = null; - byte source = 2; - if (transferRequest.TransferInfo.SourceType == 2) - { - //direct asset request - requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); - } - else if (transferRequest.TransferInfo.SourceType == 3) - { - //inventory asset request - requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); - source = 3; - //Console.WriteLine("asset request " + requestID); - } - //check to see if asset is in local cache, if not we need to request it from asset server. - //Console.WriteLine("asset request " + requestID); - if (!Assets.ContainsKey(requestID)) - { - //not found asset - // so request from asset server - if (!RequestedAssets.ContainsKey(requestID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = requestID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - request.AssetRequestSource = source; - request.Params = transferRequest.TransferInfo.Params; - RequestedAssets.Add(requestID, request); - m_assetServer.RequestAsset(requestID, false); - } - return; - } - //it is in our cache - AssetInfo asset = Assets[requestID]; - - // add to the AssetRequests list - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; - req.AssetRequestSource = source; - req.Params = transferRequest.TransferInfo.Params; - req.AssetInf = asset; - req.NumPackets = CalculateNumPackets(asset.Data); - AssetRequests.Add(req); - } - - /// - /// Process the asset queue which sends packets directly back to the client. - /// - private void ProcessAssetQueue() - { - //should move the asset downloading to a module, like has been done with texture downloading - if (AssetRequests.Count == 0) - { - //no requests waiting - return; - } - // if less than 5, do all of them - int num = Math.Min(5, AssetRequests.Count); - - AssetRequest req; - for (int i = 0; i < num; i++) - { - req = (AssetRequest)AssetRequests[i]; - //Console.WriteLine("sending asset " + req.RequestAssetID); - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - if (req.AssetRequestSource == 2) - { - Transfer.TransferInfo.Params = new byte[20]; - Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; - Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); - } - else if (req.AssetRequestSource == 3) - { - Transfer.TransferInfo.Params = req.Params; - // Transfer.TransferInfo.Params = new byte[100]; - //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); - } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); - - 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, ThrottleOutPacketType.Asset); - } - else - { - int processedLength = 0; - // libsecondlife hardcodes 1500 as the maximum data chunk size - int maxChunkSize = 1250; - int packetNumber = 0; - - while (processedLength < req.AssetInf.Data.Length) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = packetNumber; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); - byte[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - - TransferPacket.TransferData.Data = chunk; - - // 0 indicates more packets to come, 1 indicates last packet - if (req.AssetInf.Data.Length - processedLength > maxChunkSize) - { - TransferPacket.TransferData.Status = 0; - } - else - { - TransferPacket.TransferData.Status = 1; - } + /// + /// Make an asset request the result of which will be packeted up and sent directly back to the client. + /// + /// + /// + public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) + { + LLUUID requestID = null; + byte source = 2; + if (transferRequest.TransferInfo.SourceType == 2) + { + //direct asset request + requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); + } + else if (transferRequest.TransferInfo.SourceType == 3) + { + //inventory asset request + requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); + source = 3; + //Console.WriteLine("asset request " + requestID); + } + //check to see if asset is in local cache, if not we need to request it from asset server. + //Console.WriteLine("asset request " + requestID); + if (!Assets.ContainsKey(requestID)) + { + //not found asset + // so request from asset server + if (!RequestedAssets.ContainsKey(requestID)) + { + AssetRequest request = new AssetRequest(); + request.RequestUser = userInfo; + request.RequestAssetID = requestID; + request.TransferRequestID = transferRequest.TransferInfo.TransferID; + request.AssetRequestSource = source; + request.Params = transferRequest.TransferInfo.Params; + RequestedAssets.Add(requestID, request); + m_assetServer.RequestAsset(requestID, false); + } + return; + } + //it is in our cache + AssetInfo asset = Assets[requestID]; + + // add to the AssetRequests list + AssetRequest req = new AssetRequest(); + req.RequestUser = userInfo; + req.RequestAssetID = requestID; + req.TransferRequestID = transferRequest.TransferInfo.TransferID; + req.AssetRequestSource = source; + req.Params = transferRequest.TransferInfo.Params; + req.AssetInf = asset; + req.NumPackets = CalculateNumPackets(asset.Data); + AssetRequests.Add(req); + } - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - processedLength += chunkSize; - packetNumber++; - } - } - } - - //remove requests that have been completed - for (int i = 0; i < num; i++) - { - AssetRequests.RemoveAt(0); - } - } - - 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 byte AssetRequestSource = 2; - public byte[] Params = null; - //public bool AssetInCache; - //public int TimeRequested; - public int DiscardLevel = -1; - - public AssetRequest() - { - } - } - + /// + /// Process the asset queue which sends packets directly back to the client. + /// + private void ProcessAssetQueue() + { + //should move the asset downloading to a module, like has been done with texture downloading + if (AssetRequests.Count == 0) + { + //no requests waiting + return; + } + // if less than 5, do all of them + int num = Math.Min(5, AssetRequests.Count); + + AssetRequest req; + for (int i = 0; i < num; i++) + { + req = (AssetRequest)AssetRequests[i]; + //Console.WriteLine("sending asset " + req.RequestAssetID); + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + if (req.AssetRequestSource == 2) + { + Transfer.TransferInfo.Params = new byte[20]; + Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + int assType = (int)req.AssetInf.Type; + Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); + } + else if (req.AssetRequestSource == 3) + { + Transfer.TransferInfo.Params = req.Params; + // Transfer.TransferInfo.Params = new byte[100]; + //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); + } + Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.TransferID = req.TransferRequestID; + req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); + 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, ThrottleOutPacketType.Asset); + } + else + { + int processedLength = 0; + // libsecondlife hardcodes 1500 as the maximum data chunk size + int maxChunkSize = 1250; + int packetNumber = 0; + + while (processedLength < req.AssetInf.Data.Length) + { + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = packetNumber; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + byte[] chunk = new byte[chunkSize]; + Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); + + TransferPacket.TransferData.Data = chunk; + + // 0 indicates more packets to come, 1 indicates last packet + if (req.AssetInf.Data.Length - processedLength > maxChunkSize) + { + TransferPacket.TransferData.Status = 0; + } + else + { + TransferPacket.TransferData.Status = 1; + } + + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); + + processedLength += chunkSize; + packetNumber++; + } + } + } + + //remove requests that have been completed + for (int i = 0; i < num; i++) + { + AssetRequests.RemoveAt(0); + } + } + + 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 byte AssetRequestSource = 2; + public byte[] Params = null; + //public bool AssetInCache; + //public int TimeRequested; + public int DiscardLevel = -1; + + public AssetRequest() + { + } + } + public class AssetInfo : AssetBase { public AssetInfo() diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index c1cf100..3ce28c2 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System.IO; using Db4objects.Db4o; using Db4objects.Db4o.Query; @@ -142,4 +141,4 @@ namespace OpenSim.Framework.Communications.Cache return (asset.UUID == _findID); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 23cc884..261b697 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 1cf95b7..077a61d 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using libsecondlife; namespace OpenSim.Framework.Communications.Cache @@ -130,4 +130,4 @@ namespace OpenSim.Framework.Communications.Cache return result; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 50ca2e8..b952af2 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -1,30 +1,29 @@ /* -* 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. -* -*/ + * 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.IO; diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index a1e79b2..20edf51 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System.Collections.Generic; using libsecondlife; @@ -153,4 +153,4 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index a164e11..b624b15 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index d3a283a..4f1a304 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -1,30 +1,30 @@ /* -* 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. -* -*/ + * 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.Reflection; using OpenSim.Framework.Console; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b066fdc..17d9ae4 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; @@ -365,4 +364,4 @@ namespace OpenSim.Framework.Communications.Cache m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d38af7c..80949fe 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index dab926c..8e2a194 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections; @@ -677,4 +676,4 @@ namespace OpenSim.Region.Capabilities } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index d641b5c..a5cdd73 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System.Collections; namespace OpenSim.Region.Capabilities @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index e0afa5c..876b8d3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using libsecondlife; using System; @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 4a69097..fb64c75 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using libsecondlife; @@ -43,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 5d6b7bd..fb721f0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ namespace OpenSim.Region.Capabilities { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index 3b8c077..c1b15b4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index dc866ba..f9ab0ef 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; @@ -48,4 +47,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 5e6e917..5a44e26 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] @@ -34,4 +34,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 193927d..bf47be7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections; using System.IO; @@ -154,4 +154,4 @@ namespace OpenSim.Region.Capabilities return obj; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index e400877..6211c4f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using libsecondlife; @@ -39,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 121b36a..0cf82a8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using libsecondlife; namespace OpenSim.Region.Capabilities @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 93b0f83..205a645 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 15369ff..748c5ea 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ namespace OpenSim.Region.Capabilities { @@ -37,4 +36,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index e8eefc0..deb9223 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -1,32 +1,31 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ namespace OpenSim.Region.Capabilities { public delegate TResponse LLSDMethod(TRequest request); -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 288bf2c..545643a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System.Collections; using System.IO; @@ -66,4 +65,4 @@ namespace OpenSim.Region.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 6454ad7..22e45f4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using libsecondlife; namespace OpenSim.Region.Capabilities @@ -47,4 +47,4 @@ namespace OpenSim.Region.Capabilities /// public string state; } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 329ab8e..ed7e824 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using libsecondlife; @@ -48,4 +47,4 @@ namespace OpenSim.Region.Capabilities ///
public int is_script_running; } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index d10b0c0..d050176 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.Capabilities { [LLSDType("MAP")] @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index e851742..bdc8e79 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; namespace OpenSim.Region.Capabilities @@ -52,4 +52,4 @@ namespace OpenSim.Region.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 93117fd..d96709d 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections.Generic; using libsecondlife; diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index e2c2661..14baf3f 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System.Collections.Generic; namespace OpenSim.Framework.Communications @@ -39,4 +39,4 @@ namespace OpenSim.Framework.Communications Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index e93719e..e7e1737 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using libsecondlife; namespace OpenSim.Framework.Communications @@ -47,4 +47,4 @@ namespace OpenSim.Framework.Communications bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 0ad6fd6..bb46777 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System.Collections.Generic; using libsecondlife; @@ -97,4 +96,4 @@ namespace OpenSim.Framework.Communications /// InventoryFolderBase RequestNamedFolder(LLUUID userID, string folderName); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index ec20850..d4a501c 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; @@ -386,4 +385,4 @@ namespace OpenSim.Framework.Communications } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 715bc52..a093c9d 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections; diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index bb8cad5..dede607 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections; diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 8b6d937..9a53499 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -1,30 +1,30 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System.Reflection; using System.Runtime.InteropServices; @@ -37,7 +37,7 @@ using System.Runtime.InteropServices; [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("")] [assembly : AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index b67aad9..728e25b 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Threading; @@ -68,7 +67,6 @@ namespace OpenSim.Framework.Communications get { return m_asyncState; } } - public WaitHandle AsyncWaitHandle { get @@ -166,7 +164,6 @@ namespace OpenSim.Framework.Communications { } - public void SetAsCompleted(T result, bool completedSynchronously) { // Save the asynchronous operation's result @@ -183,4 +180,4 @@ namespace OpenSim.Framework.Communications return m_result; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index f1b2fc7..7212e5e 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 48807c2..d3ebbb0 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -1,30 +1,29 @@ /* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections; -- cgit v1.1 From 42857fe4e9e898c8e350da2f9acb3b252b31694a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 18 Mar 2008 05:44:25 +0000 Subject: * Added the ability to type the partial name of a region in the start location box and go to that region if it's there. If no close match was found, it sends you home. This is tested on mySQL. There's untested code on grids that are based on sqlite and MSSQL. The SQL statements *should* be right, but your results may very. * Ex, if you want to go to Wright Plaza, you simply need to type Wright Plaza in the start location in the client when you log-in. --- OpenSim/Framework/Communications/IGridServices.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 14baf3f..3e2a5da 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); + RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } -- cgit v1.1 From 443c66b43239038d50bf89e2233fdba778c250f7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 18 Mar 2008 06:03:50 +0000 Subject: Since we don't yet have a reliable way to release the lock that prevents a user from logging in a second time if they're already registered as logged in; * If a user logs in and they are noted as agentOnline. Set agentOnline = false and send a 'you're already logged in' message to the user asking them to wait 5 minutes. These 5 minutes are not enforced (because there's no foolproof interlock release yet without the grid operator getting a support call for every little sim crash). When the user gets the message, they can log-in immediately after it, but the user can expect weird results if they don't wait 5 minutes and log-in to the region they were in previously. --- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index a093c9d..a815662 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -244,7 +244,7 @@ namespace OpenSim.Framework.UserManagement { return (GenerateFailureResponse("presence", - "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", + "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner. Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", "false")); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index dede607..72b408b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -164,7 +164,7 @@ namespace OpenSim.Framework.UserManagement // If agentOnline could not turn from true back to false normally // because of some problem, for instance, the crashment of server or client, // the user cannot log in any longer. - userProfile.currentAgent = null; + userProfile.currentAgent.agentOnline = false; m_userManager.CommitAgent(ref userProfile); // Reject the login -- cgit v1.1 From bf8b5844f24d294c459f54147bd511e7112288bf Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 18 Mar 2008 14:51:42 +0000 Subject: Formatting cleanup. Minor refactoring. --- OpenSim/Framework/Communications/LoginResponse.cs | 10 +++++++--- OpenSim/Framework/Communications/LoginService.cs | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index a815662..4a31986 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -170,7 +170,6 @@ namespace OpenSim.Framework.UserManagement AddClassifiedCategory((Int32) 8, "Service"); AddClassifiedCategory((Int32) 9, "Personal"); - SessionID = LLUUID.Random(); SecureSessionID = LLUUID.Random(); AgentID = LLUUID.Random(); @@ -244,7 +243,10 @@ namespace OpenSim.Framework.UserManagement { return (GenerateFailureResponse("presence", - "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner. Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner. " + + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", "false")); } @@ -252,7 +254,9 @@ namespace OpenSim.Framework.UserManagement { return GenerateFailureResponseLLSD( "presence", - "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner", "false"); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 72b408b..be47258 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -121,6 +121,7 @@ namespace OpenSim.Framework.UserManagement return logResponse.CreateLoginFailedResponse(); } + if (requestData.Contains("passwd")) { string passwd = (string)requestData["passwd"]; @@ -494,8 +495,8 @@ namespace OpenSim.Framework.UserManagement } public string GetLoginForm(string firstname, string lastname, string location, string region, - string grid, string channel, string version, string lang, - string password, string errormessages) + string grid, string channel, string version, string lang, + string password, string errormessages) { // inject our values in the form at the markers @@ -522,6 +523,7 @@ namespace OpenSim.Framework.UserManagement loginform = loginform.Replace("[$lang]", lang); loginform = loginform.Replace("[$password]", password); loginform = loginform.Replace("[$errors]", errormessages); + return loginform; } @@ -588,6 +590,7 @@ namespace OpenSim.Framework.UserManagement responseString += ""; responseString += ""; responseString += ""; + return responseString; } -- cgit v1.1 From 18f9f1410d45dc0b81cd6b7527fea0db0661d203 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 18 Mar 2008 18:19:44 +0000 Subject: * Just inserting some exploratory comments into inventory code --- .../Communications/Cache/UserProfileCacheService.cs | 12 ++++++++++++ OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 17d9ae4..fcfb53a 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -133,6 +133,18 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Handle a client request to update the inventory folder + /// + /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE + /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, + /// and needs to be changed. + /// + /// + /// + /// + /// + /// public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID) { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index d4a501c..c73d45c 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -128,6 +128,7 @@ namespace OpenSim.Framework.Communications } } + // See IInventoryServices public virtual bool HasInventoryForUser(LLUUID userID) { return false; @@ -200,6 +201,9 @@ namespace OpenSim.Framework.Communications protected void AddFolder(InventoryFolderBase folder) { + m_log.DebugFormat( + "[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.name, folder.folderID, folder.parentID); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.addInventoryFolder(folder); -- cgit v1.1 From a0e1be3280e4be49cf0ca8d211b97ef8c1ddee2f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 19 Mar 2008 09:36:13 +0000 Subject: Fixed some comparisons of LLUUIDs to null. Thanks to DrSchofld for pointing this out. --- OpenSim/Framework/Communications/UserManagerBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d3ebbb0..5ba37e6 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -439,17 +439,15 @@ namespace OpenSim.Framework.UserManagement userAgent.agentOnline = false; userAgent.logoutTime = Util.UnixTimeSinceEpoch(); //userAgent.sessionID = LLUUID.Zero; - if (regionid != null) + if (regionid != LLUUID.Zero) { userAgent.currentRegion = regionid; } - userAgent.currentHandle = regionhandle; + userAgent.currentHandle = regionhandle; userAgent.currentPos = currentPos; - userProfile.currentAgent = userAgent; - CommitAgent(ref userProfile); } else -- cgit v1.1 From 20473af89240457c1517bb547f8fc239478fd720 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 20 Mar 2008 13:03:26 +0000 Subject: Another poxy patch which consists mainly of logging changes (some already commented out) to find out what CAPS is doing --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 80949fe..878b0cc 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -105,8 +105,8 @@ namespace OpenSim.Region.Capabilities ///
public void RegisterHandlers() { - m_log.Info("[CAPS]: Registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; + try { m_httpListener.AddStreamHandler( diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index bf47be7..a39f5aa 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -35,6 +35,9 @@ namespace OpenSim.Region.Capabilities { public class LLSDHelpers { +// private static readonly log4net.ILog m_log +// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public static string SerialiseLLSDReply(object obj) { StringWriter sw = new StringWriter(); @@ -44,6 +47,9 @@ namespace OpenSim.Region.Capabilities SerializeLLSDType(writer, obj); writer.WriteEndElement(); writer.Close(); + + //m_log.DebugFormat("[LLSD Helpers]: Generated serialized LLSD reply {0}", sw.ToString()); + return sw.ToString(); } -- cgit v1.1 From f61ea1998e07858a7553b2a805cfc3647aa89a5a Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 20 Mar 2008 15:33:08 +0000 Subject: Added back a fix that lbsa71 did aqes ago to fix a buffer overflow in the packetpool, which somewhere through time got lost/reverted --- OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 48b1f3d..36a2cbf 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -48,7 +48,6 @@ namespace OpenSim.Region.Capabilities public string name; public string desc; public int created_at; - } [LLSDMap] -- cgit v1.1 From c1beb85315aad09197ca7ffaa8ec194346af82cb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 20 Mar 2008 20:04:45 +0000 Subject: * First draft resolution of mantis 777, 734, 389 - scripts do not save in non-home regions * Should work in multi-region standalone and grid modes * This should also solve other non-home region caps issues (map requests, RC client inventory requests, etc) * We now pass CAPS information on to the destination region on region crossing, and set up a CAPS object when an agent becomes a master * Current limitation is that this will only work if your http_listener_port is 9000 * This is a very early code cut (lots of bad practice, hard coding and inefficiency). However, I wanted to get this out there for feedback and my own sanity. Next few patches will clean up the mess. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 878b0cc..fad4741 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -62,7 +62,12 @@ namespace OpenSim.Region.Capabilities private string m_httpListenerHostName; private uint m_httpListenPort; - private string m_capsObjectPath = "00001-"; + /// + /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. + /// + private string m_capsObjectPath; + public string CapsObjectPath { get { return m_capsObjectPath; } } + private string m_requestPath = "0000/"; private string m_mapLayerPath = "0001/"; private string m_newInventory = "0002/"; @@ -109,9 +114,12 @@ namespace OpenSim.Region.Capabilities try { + m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); + + m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, @@ -142,6 +150,7 @@ namespace OpenSim.Region.Capabilities private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { string capsBase = "/CAPS/" + m_capsObjectPath; + httpListener.RemoveStreamHandler("POST", capsBase + path); httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } -- cgit v1.1 From 7286bd60b07e809f33215256cc71b39c15437c65 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 21 Mar 2008 02:26:00 +0000 Subject: * Converted a large number of ASCII encodings to UTF8. * We should not be using ASCII anywhere except for legacy compatibility reasons. * A large number of UTF8 Encoders are being used in places where we should be using Util.StringToField instead. These have been tagged with // ENCODING FAULT * This should fix Mantis#799 - Japanese Profile Text does not work. --- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 8e2a194..b3e841c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -329,7 +329,7 @@ namespace OpenSim.Region.Capabilities reader.Read(); FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); - byte[] inp = Encoding.ASCII.GetBytes(reader.ReadString()); + byte[] inp = Encoding.UTF8.GetBytes(reader.ReadString()); ret = b64.TransformFinalBlock(inp, 0, inp.Length); break; } -- cgit v1.1 From 45ea15680444c3ebb009ebc7592c168707fbc0dd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 21 Mar 2008 19:16:29 +0000 Subject: * If a client session requests the same texture more than n times (currently n=5), we now drop the subsequent requests * This may improve region memory usage * This is a short-term response to a problem whereby some clients keep requesting the same texture even after we've sent it * This treats the symptom rather than the cause. * n can be adjusted by changing the constant at the top of UserTextureDownloadService if necessary --- OpenSim/Framework/Communications/IGridServices.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 3e2a5da..daa43ac 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -32,7 +32,14 @@ namespace OpenSim.Framework.Communications public interface IGridServices { string gdebugRegionName { get; set; } + + /// + /// Register a region with the grid service. + /// + /// + /// RegionCommsListener RegisterRegion(RegionInfo regionInfos); + bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); -- cgit v1.1 From 61ae75f3640a9861fbf22ae57b748710080631e7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 22 Mar 2008 20:44:15 +0000 Subject: * Catch the occasional resolution exception that comes out of SceneCommunicationService.EnableChildAgents so we can see what hostname is failing --- OpenSim/Framework/Communications/IGridServices.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index daa43ac..9e34672 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -41,7 +41,15 @@ namespace OpenSim.Framework.Communications RegionCommsListener RegisterRegion(RegionInfo regionInfos); bool DeregisterRegion(RegionInfo regionInfo); + + /// + /// Get information about the regions neighbouring the given co-ordinates. + /// + /// + /// + /// List RequestNeighbours(uint x, uint y); + RegionInfo RequestNeighbourInfo(ulong regionHandle); RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); -- cgit v1.1 From da531fa9e124394228a7c7597bd50e548af81efb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 23 Mar 2008 21:21:39 +0000 Subject: * Start passing around a region server's http port in RegionInfo. * This means that caps methods (editing scripts, poss map functions, etc) on non-home regions should now work with servers which are listening for http ports on a non default (9000) port. * If you are running a region server, this may only work properly once your grid server upgrades to this revision * PLEASE NOTE: This shouldn't cause inter-region problems if one end of the connection hasn't upgraded to this revision. However if it does, the instability will persist until the grid and region (and possibly all the region's neighbours) have upgraded to this revision. * This revision also adds extra login related messages, both for success and failure conditions --- OpenSim/Framework/Communications/LoginService.cs | 57 ++++++++++++++++-------- 1 file changed, 39 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index be47258..3e3216f 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework.UserManagement } /// - /// Main user login function + /// Called when we receive the client's initial /// /// The XMLRPC request /// The response to send @@ -94,25 +94,32 @@ namespace OpenSim.Framework.UserManagement string startLocationRequest = "last"; - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - m_log.Info("[LOGIN]: Client Requested Start: " + (string)requestData["start"]); - } - UserProfileData userProfile; LoginResponse logResponse = new LoginResponse(); + + string firstname = String.Empty; + string lastname = String.Empty; if (GoodXML) { - string firstname = (string) requestData["first"]; - string lastname = (string) requestData["last"]; + firstname = (string) requestData["first"]; + lastname = (string) requestData["last"]; + + m_log.InfoFormat( + "[LOGIN]: Received login request message from user {0} {1}", + firstname, lastname); if( requestData.Contains("version")) { string clientversion = (string)requestData["version"]; - m_log.Info("[LOGIN]: Client Version " + clientversion + " for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: Client version: " + clientversion); } + + if (requestData.Contains("start")) + { + startLocationRequest = (string)requestData["start"]; + m_log.Info("[LOGIN]: Client requested start location: " + (string)requestData["start"]); + } userProfile = GetTheUser(firstname, lastname); if (userProfile == null) @@ -134,31 +141,35 @@ namespace OpenSim.Framework.UserManagement { webloginkey = new LLUUID((string)requestData["web_login_key"]); } - catch (System.Exception) + catch (System.Exception e) { + m_log.InfoFormat( + "[LOGIN]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); + return logResponse.CreateFailedResponse(); } GoodLogin = AuthenticateUser(userProfile, webloginkey); } - else - { - return logResponse.CreateFailedResponse(); - } } else { + m_log.Info( + "[LOGIN]: login_to_simulator login message did not contain all the required data"); + return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { + m_log.InfoFormat("[LOGIN]: User {0} {1} failed authentication", firstname, lastname); + return logResponse.CreateLoginFailedResponse(); } else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { //TODO: The following statements can cause trouble: @@ -169,6 +180,11 @@ namespace OpenSim.Framework.UserManagement m_userManager.CommitAgent(ref userProfile); // Reject the login + + m_log.InfoFormat( + "[LOGIN]: Notifying user {0} {1} that they are already logged in", + firstname, lastname); + return logResponse.CreateAlreadyLoggedInResponse(); } // Otherwise... @@ -234,14 +250,19 @@ namespace OpenSim.Framework.UserManagement if (StatsManager.UserStats != null) StatsManager.UserStats.AddSuccessfulLogin(); + m_log.InfoFormat( + "[LOGIN]: Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + return logResponse.ToXmlRpcResponse(); } catch (Exception e) { - m_log.Info("[LOGIN]: " + e.ToString()); + m_log.Info("[LOGIN]: Login failed, exception" + e.ToString()); } - //} } + + m_log.Info("[LOGIN]: Login failed. Sending back blank XMLRPC response"); return response; } finally -- cgit v1.1 From ca6e5570750b7f5dc37e762db2d2239a50923ea8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 23 Mar 2008 21:32:30 +0000 Subject: * minor: check in the rest of a comment I forgot to finish off in the last revision --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 3e3216f..c04e8b9 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework.UserManagement } /// - /// Called when we receive the client's initial + /// Called when we receive the client's initial XMLRPC login_to_simulator request message /// /// The XMLRPC request /// The response to send -- cgit v1.1 From 8c0955321a5f0d4de21ceb9b98b4e329e1b56200 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 24 Mar 2008 18:21:06 +0000 Subject: * Refactor: Genericise request limit strategies and move to OpenSim.Framework.Communications.Limit --- .../Communications/Limit/IRequestLimitStrategy.cs | 68 +++++++++++++ .../Communications/Limit/RepeatLimitStrategy.cs | 113 +++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs create mode 100644 OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs new file mode 100644 index 0000000..ded9ffc --- /dev/null +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Framework.Communications.Limit +{ + /// + /// Interface for strategies that can limit requests from the client. Currently only used in the + /// texture modules to deal with repeated requests for certain textures. However, limiting strategies + /// could be used with other requests. + /// + public interface IRequestLimitStrategy + { + /// + /// Should the request be allowed? If the id is not monitored, then the request is always allowed. + /// Otherwise, the strategy criteria will be applied. + /// + /// + /// + bool AllowRequest(TId id); + + /// + /// Has the request been refused just once? + /// + /// False if the request has not yet been refused, or if the request has been refused more + /// than once. + bool IsFirstRefusal(TId id); + + /// + /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring + /// continues. + /// + /// + void MonitorRequests(TId id); + + /// + /// Is the id being monitored? + /// + /// + /// + bool IsMonitoringRequests(TId id); + } +} diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs new file mode 100644 index 0000000..6dd0fa1 --- /dev/null +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -0,0 +1,113 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; + +namespace OpenSim.Framework.Communications.Limit +{ + /// + /// Limit requests by discarding them after they've been repeated a certain number of times. + /// + public class RepeatLimitStrategy : IRequestLimitStrategy + { + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Record each asset request that we're notified about. + /// + private readonly Dictionary requestCounts = new Dictionary(); + + /// + /// The maximum number of requests that can be made before we drop subsequent requests. + /// + private readonly int m_maxRequests; + public int MaxRequests + { + get { return m_maxRequests; } + } + + /// + /// The maximum number of requests that may be served before all further + /// requests are dropped. + public RepeatLimitStrategy(int maxRequests) + { + m_maxRequests = maxRequests; + } + + /// + /// + /// + public bool AllowRequest(TId id) + { + if (requestCounts.ContainsKey(id)) + { + requestCounts[id] += 1; + + if (requestCounts[id] > m_maxRequests) + { + return false; + } + } + + return true; + } + + /// + /// + /// + public bool IsFirstRefusal(TId id) + { + if (m_maxRequests + 1 == requestCounts[id]) + { + return true; + } + + return false; + } + + /// + /// + /// + public void MonitorRequests(TId id) + { + if (!IsMonitoringRequests(id)) + { + requestCounts.Add(id, 1); + } + } + + /// + /// + /// + public bool IsMonitoringRequests(TId id) + { + return requestCounts.ContainsKey(id); + } + } +} -- cgit v1.1 From 1a970d8f2d6fe0831336d957848c225567bd4428 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 24 Mar 2008 18:25:50 +0000 Subject: * Create null limit strategy --- .../Communications/Limit/NullLimitStrategy.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs new file mode 100644 index 0000000..95cc1cd --- /dev/null +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -0,0 +1,42 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Framework.Communications.Limit +{ + /// + /// Strategy which enforces no limits + /// + public class NullLimitStrategy : IRequestLimitStrategy + { + bool AllowRequest(TId id) { return true; } + bool IsFirstRefusal(TId id) { return false; } + void MonitorRequests(TId id) { /* intentionally blank */ } + bool IsMonitoringRequests(TId id) { return false; } + } +} -- cgit v1.1 From 185dbb06afe0ce61d96f5e7876e928639d392dab Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 24 Mar 2008 18:26:43 +0000 Subject: * Picky comment change --- OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 95cc1cd..a5574f2 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -30,7 +30,7 @@ using System; namespace OpenSim.Framework.Communications.Limit { /// - /// Strategy which enforces no limits + /// Strategy which polices no limits /// public class NullLimitStrategy : IRequestLimitStrategy { -- cgit v1.1 From ca7c954a61aab9def435d668956fea3f035c224a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 24 Mar 2008 18:45:21 +0000 Subject: * Fix build break in last revision. Thanks to paulieFemto for pointing it out. --- OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index a5574f2..43b77a7 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -34,9 +34,9 @@ namespace OpenSim.Framework.Communications.Limit ///
public class NullLimitStrategy : IRequestLimitStrategy { - bool AllowRequest(TId id) { return true; } - bool IsFirstRefusal(TId id) { return false; } - void MonitorRequests(TId id) { /* intentionally blank */ } - bool IsMonitoringRequests(TId id) { return false; } + public bool AllowRequest(TId id) { return true; } + public bool IsFirstRefusal(TId id) { return false; } + public void MonitorRequests(TId id) { /* intentionally blank */ } + public bool IsMonitoringRequests(TId id) { return false; } } } -- cgit v1.1 From a8d9a58dd2e2ec270daa53ac4f94a245c6677224 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 25 Mar 2008 03:43:24 +0000 Subject: Fix a couple more warnings. --- OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index 6dd0fa1..82122fc 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -35,9 +35,6 @@ namespace OpenSim.Framework.Communications.Limit ///
public class RepeatLimitStrategy : IRequestLimitStrategy { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - /// /// Record each asset request that we're notified about. /// -- cgit v1.1 From 9d1b42c39a779c84dd091a817d2f6e5f434777c4 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 25 Mar 2008 03:49:08 +0000 Subject: Comment out unused private methods. --- .../Communications/RestClient/RestClient.cs | 101 +++++++++++---------- 1 file changed, 52 insertions(+), 49 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 7212e5e..1178fed 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -195,15 +195,16 @@ namespace OpenSim.Framework.Communications return s.Substring(s.Length - 1, 1) == "/"; } - /// - /// return a slash or blank. A slash will be returned if the string does not contain one - /// - /// stromg to be examined - /// slash '/' if not already present - private string slash(string s) - { - return isSlashed(s) ? String.Empty : "/"; - } +// TODO: unused +// /// +// /// return a slash or blank. A slash will be returned if the string does not contain one +// /// +// /// stromg to be examined +// /// slash '/' if not already present +// private string slash(string s) +// { +// return isSlashed(s) ? String.Empty : "/"; +// } /// /// Build a Uri based on the initial Url, path elements and parameters @@ -278,46 +279,48 @@ namespace OpenSim.Framework.Communications } } - /// - /// Async method, invoked when the initial response if received from the server - /// - /// - private void ResponseIsReadyDelegate(IAsyncResult ar) - { - try - { - // grab response - WebRequest wr = (WebRequest) ar.AsyncState; - _response = (HttpWebResponse) wr.EndGetResponse(ar); - - // get response stream, and setup async reading - Stream s = _response.GetResponseStream(); - IAsyncResult asynchronousResult = - s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - // wait until completed, or we timed out - // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - } - catch (Exception e) - { - _allDone.Set(); - _asyncException = e; - } - } - - // Abort the request if the timer fires. - private static void TimeoutCallback(object state, bool timedOut) - { - if (timedOut) - { - HttpWebRequest request = state as HttpWebRequest; - if (request != null) - { - request.Abort(); - } - } - } +// TODO: unused +// /// +// /// Async method, invoked when the initial response if received from the server +// /// +// /// +// private void ResponseIsReadyDelegate(IAsyncResult ar) +// { +// try +// { +// // grab response +// WebRequest wr = (WebRequest) ar.AsyncState; +// _response = (HttpWebResponse) wr.EndGetResponse(ar); + +// // get response stream, and setup async reading +// Stream s = _response.GetResponseStream(); +// IAsyncResult asynchronousResult = +// s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + +// // TODO! Implement timeout, without killing the server +// // wait until completed, or we timed out +// // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); +// } +// catch (Exception e) +// { +// _allDone.Set(); +// _asyncException = e; +// } +// } + +// TODO: unused +// // Abort the request if the timer fires. +// private static void TimeoutCallback(object state, bool timedOut) +// { +// if (timedOut) +// { +// HttpWebRequest request = state as HttpWebRequest; +// if (request != null) +// { +// request.Abort(); +// } +// } +// } #endregion Async communications with server -- cgit v1.1 From 301c25950d77c521f12bf75e90ea011c75c31aa3 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 25 Mar 2008 05:56:27 +0000 Subject: * Committing some voice related caps with hard coded responses so more debugging can occur. --- .../Framework/Communications/Capabilities/Caps.cs | 99 ++++++++++++++++++++++ .../Communications/Capabilities/LLSDCapsDetails.cs | 4 +- 2 files changed, 102 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index fad4741..194407f 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -75,6 +75,8 @@ namespace OpenSim.Region.Capabilities private string m_notecardUpdatePath = "0004/"; private string m_notecardTaskUpdatePath = "0005/"; private string m_fetchInventoryPath = "0006/"; + private string m_parcelVoiceInfoRequestPath = "0007/"; + private string m_provisionVoiceAccountRequestPath = "0008/"; //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -133,6 +135,8 @@ namespace OpenSim.Region.Capabilities AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); + AddLegacyCapsHandler(m_httpListener, m_parcelVoiceInfoRequestPath, ParcelVoiceInfoRequest); + AddLegacyCapsHandler(m_httpListener, m_provisionVoiceAccountRequestPath, ProvisionVoiceAccountRequest); AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); AddLegacyCapsHandler(m_httpListener, m_fetchInventoryPath, FetchInventoryRequest); @@ -184,6 +188,9 @@ namespace OpenSim.Region.Capabilities caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath; caps.FetchInventoryDescendents = capsBaseUrl + m_fetchInventoryPath; + caps.ParcelVoiceInfoRequest = capsBaseUrl + m_parcelVoiceInfoRequestPath; + caps.ProvisionVoiceAccountRequest = capsBaseUrl + m_provisionVoiceAccountRequestPath; + return caps; } @@ -411,6 +418,98 @@ namespace OpenSim.Region.Capabilities return null; } + + public string ParcelVoiceInfoRequest(string request, string path, string param) + { + try + { + m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); + + //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); + //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); + + //string capsBase = "/CAPS/" + m_capsObjectPath; + //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + //TaskInventoryScriptUpdater uploader = + //new TaskInventoryScriptUpdater( + //llsdUpdateRequest.item_id, + //llsdUpdateRequest.task_id, + //llsdUpdateRequest.is_script_running, + //capsBase + uploaderPath, + //m_httpListener, + //m_dumpAssetsToFile); + //uploader.OnUpLoad += TaskScriptUpdated; + + //m_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"; + + // m_log.InfoFormat("[CAPS]: " + + // "ScriptTaskInventory response: {0}", + // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); + + return LLSDHelpers.SerialiseLLSDReply("parcel_local_id16region_nameLimbovoice_credentialschannel_urisip:confctl-49730-1@bhr.vivox.com"); + } + catch (Exception e) + { + m_log.Error("[CAPS]: " + e.ToString()); + } + + return null; + } + + public string ProvisionVoiceAccountRequest(string request, string path, string param) + { + try + { + m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); + + //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); + //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); + + //string capsBase = "/CAPS/" + m_capsObjectPath; + //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + //TaskInventoryScriptUpdater uploader = + //new TaskInventoryScriptUpdater( + //llsdUpdateRequest.item_id, + //llsdUpdateRequest.task_id, + //llsdUpdateRequest.is_script_running, + //capsBase + uploaderPath, + //m_httpListener, + //m_dumpAssetsToFile); + //uploader.OnUpLoad += TaskScriptUpdated; + + //m_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"; + + // m_log.InfoFormat("[CAPS]: " + + // "ScriptTaskInventory response: {0}", + // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); + + return LLSDHelpers.SerialiseLLSDReply("eventsbodymajor_version1minor_version0region_nameCathedralmessageRequiredVoiceVersionid152477222"); + } + catch (Exception e) + { + m_log.Error("[CAPS]: " + e.ToString()); + } + + return null; + } /// /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index f9ab0ef..bd1c9da 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -40,8 +40,10 @@ namespace OpenSim.Region.Capabilities public string UpdateNotecardAgentInventory = String.Empty; public string UpdateScriptAgentInventory = String.Empty; public string UpdateScriptTaskInventory = String.Empty; - // public string ParcelVoiceInfoRequest = String.Empty; + public string ParcelVoiceInfoRequest = String.Empty; public string FetchInventoryDescendents = String.Empty; + public string ProvisionVoiceAccountRequest = String.Empty; + public LLSDCapsDetails() { -- cgit v1.1 From 3d1b4f8578e4dc3df0436c1c13f1b2983d3b55e7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 25 Mar 2008 16:09:43 +0000 Subject: * On Ray casting. Now returning the face normal of the collision face. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 194407f..cac0571 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -455,7 +455,7 @@ namespace OpenSim.Region.Capabilities // "ScriptTaskInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - return LLSDHelpers.SerialiseLLSDReply("parcel_local_id16region_nameLimbovoice_credentialschannel_urisip:confctl-49730-1@bhr.vivox.com"); + return LLSDHelpers.SerialiseLLSDReply("parcel_local_id16region_nameTeravus Testvoice_credentialschannel_urisip:conference@192.168.1.127\nsip:user@192.168.1.127"); } catch (Exception e) { @@ -501,7 +501,7 @@ namespace OpenSim.Region.Capabilities // "ScriptTaskInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - return LLSDHelpers.SerialiseLLSDReply("eventsbodymajor_version1minor_version0region_nameCathedralmessageRequiredVoiceVersionid152477222"); + return LLSDHelpers.SerialiseLLSDReply("eventsbodymajor_version1minor_version0region_nameTeravus TestmessageRequiredVoiceVersionid152477222"); } catch (Exception e) { -- cgit v1.1 From 2517fe7acd97fd93a73d936664415008c0099b00 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 25 Mar 2008 17:08:20 +0000 Subject: * Remove old CAPS http listeners when a client logs out from a scene * Not yet removing listeners when a client leaves a region without logging out --- .../Framework/Communications/Capabilities/Caps.cs | 60 ++++++++++++++-------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index cac0571..c9e7507 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -68,15 +68,15 @@ namespace OpenSim.Region.Capabilities private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } - 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 m_notecardTaskUpdatePath = "0005/"; - private string m_fetchInventoryPath = "0006/"; - private string m_parcelVoiceInfoRequestPath = "0007/"; - private string m_provisionVoiceAccountRequestPath = "0008/"; + private static readonly string m_requestPath = "0000/"; + private static readonly string m_mapLayerPath = "0001/"; + private static readonly string m_newInventory = "0002/"; + //private static readonly string m_requestTexture = "0003/"; + private static readonly string m_notecardUpdatePath = "0004/"; + private static readonly string m_notecardTaskUpdatePath = "0005/"; + private static readonly string m_fetchInventoryPath = "0006/"; + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -94,7 +94,6 @@ namespace OpenSim.Region.Capabilities // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; - public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { @@ -108,25 +107,23 @@ namespace OpenSim.Region.Capabilities } /// - /// + /// Register all CAPS http service handlers /// public void RegisterHandlers() { - string capsBase = "/CAPS/" + m_capsObjectPath; + DeregisterHandlers(); + + string capsBase = "/CAPS/" + m_capsObjectPath; try - { - m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); + { m_httpListener.AddStreamHandler( - new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, - GetMapLayer)); - - m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, NewAgentInventoryRequest)); - + // m_httpListener.AddStreamHandler( // new LLSDStreamhandler("POST", // capsBase + m_fetchInventory, @@ -147,14 +144,35 @@ namespace OpenSim.Region.Capabilities } } + /// + /// Remove all CAPS service handlers. + /// + /// FIXME: Would be much nicer to remove and all paths to a single list. However, this is a little awkward + /// than it could be as we set up some handlers differently (legacy and non-legacy) + /// + /// + /// + /// + public void DeregisterHandlers() + { + string capsBase = "/CAPS/" + m_capsObjectPath; + + m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_requestPath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardUpdatePath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardTaskUpdatePath); + m_httpListener.RemoveStreamHandler("POST", capsBase + m_fetchInventoryPath); + } //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] //Commented out the obsolete as at this time the first caps request can not use the new Caps method //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { - string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.RemoveStreamHandler("POST", capsBase + path); + string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } -- cgit v1.1 From 0609970f2e30615ffa38c0ddc852ffb9bfd1c47e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Mar 2008 18:26:01 +0000 Subject: * Correct asset type of Lost and Found folder - this might stop it appearing twice * Other minor corrections to initial inventory contents * These will only take affect for new users --- .../Communications/InventoryServiceBase.cs | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index c73d45c..b73340c 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -255,7 +255,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "My Inventory"; - folder.type = 8; + folder.type = (short)AssetType.Folder; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -265,8 +265,8 @@ namespace OpenSim.Framework.Communications folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); - folder.name = "Accessories"; - folder.type = 8; + folder.name = "Animations"; + folder.type = (short)AssetType.Animation; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -274,26 +274,26 @@ namespace OpenSim.Framework.Communications folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); - folder.name = "Animations"; - folder.type = 20; + folder.name = "Body Parts"; + folder.type = (short)AssetType.Bodypart; folder.version = 1; Folders.Add(folder.folderID, folder); - + folder = new InventoryFolderBase(); folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); - folder.name = "BodyParts"; - folder.type = 13; + folder.name = "Calling Cards"; + folder.type = (short)AssetType.CallingCard; folder.version = 1; - Folders.Add(folder.folderID, folder); + Folders.Add(folder.folderID, folder); folder = new InventoryFolderBase(); folder.parentID = rootFolder; folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Clothing"; - folder.type = 5; + folder.type = (short)AssetType.Clothing; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -302,7 +302,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Gestures"; - folder.type = 21; + folder.type = (short)AssetType.Gesture; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -311,7 +311,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Landmarks"; - folder.type = 3; + folder.type = (short)AssetType.Landmark; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Lost And Found"; - folder.type = 3; + folder.type = (short)AssetType.LostAndFoundFolder; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -329,7 +329,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Notecards"; - folder.type = 7; + folder.type = (short)AssetType.Notecard; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -338,7 +338,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Objects"; - folder.type = 6; + folder.type = (short)AssetType.Primitive; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -347,7 +347,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Photo Album"; - folder.type = 15; + folder.type = (short)AssetType.SnapshotFolder; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -356,7 +356,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Scripts"; - folder.type = 10; + folder.type = (short)AssetType.LSLText; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Sounds"; - folder.type = 1; + folder.type = (short)AssetType.Sound; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -374,7 +374,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Textures"; - folder.type = 0; + folder.type = (short)AssetType.Texture; folder.version = 1; Folders.Add(folder.folderID, folder); @@ -383,7 +383,7 @@ namespace OpenSim.Framework.Communications folder.agentID = user; folder.folderID = LLUUID.Random(); folder.name = "Trash"; - folder.type = 14; + folder.type = (short)AssetType.TrashFolder; folder.version = 1; Folders.Add(folder.folderID, folder); } -- cgit v1.1 From 830626999c08f959bf1434939298b7a453a4f548 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 28 Mar 2008 14:47:51 +0000 Subject: Applied patch from mantis# 825, thanks A_Biondi --- OpenSim/Framework/Communications/LoginResponse.cs | 39 +++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 4a31986..763274a 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -416,12 +416,9 @@ namespace OpenSim.Framework.UserManagement map["seed_capability"] = LLSD.FromString(seedCapability); - // FIXME: Need a function that will convert these ArrayLists in to LLSDArrays, - // and convert the data inside them to LLSD objects as well - - //map["event_categories"] = eventCategories; + map["event_categories"] = ArrayListToLLSDArray(eventCategories); //map["event_notifications"] = new LLSDArray(); // todo - //map["classified_categories"] = classifiedCategories; + map["classified_categories"] = ArrayListToLLSDArray(classifiedCategories); #region UI Config @@ -433,18 +430,19 @@ namespace OpenSim.Framework.UserManagement #region Inventory - //map["inventory-skeleton"] = agentInventory; - //map["inventory-skel-lib"] = inventoryLibrary; - //map["inventory-root"] = inventoryRoot; - //map["inventory-lib-root"] = inventoryLibRoot; - //map["inventory-lib-owner"] = inventoryLibraryOwner; + map["inventory-skeleton"] = ArrayListToLLSDArray(agentInventory); + + map["inventory-skel-lib"] = ArrayListToLLSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToLLSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToLLSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToLLSDArray(inventoryLibraryOwner); #endregion Inventory map["gestures"] = new LLSDArray(); // todo - //responseData["initial-outfit"] = initialOutfit; - //responseData["start_location"] = startLocation; + map["initial-outfit"] = ArrayListToLLSDArray(initialOutfit); + map["start_location"] = LLSD.FromString(startLocation); map["seed_capability"] = LLSD.FromString(seedCapability); map["home"] = LLSD.FromString(home); @@ -455,7 +453,7 @@ namespace OpenSim.Framework.UserManagement if (m_buddyList != null) { - //map["buddy-list"] = m_buddyList.ToArray(); + map["buddy-list"] = ArrayListToLLSDArray(m_buddyList.ToArray()); } map["login"] = LLSD.FromString("true"); @@ -470,6 +468,21 @@ namespace OpenSim.Framework.UserManagement } } + public LLSDArray ArrayListToLLSDArray(ArrayList arrlst) + { + LLSDArray llsdBack = new LLSDArray(); + foreach (Hashtable ht in arrlst) + { + LLSDMap mp = new LLSDMap(); + foreach (DictionaryEntry deHt in ht) + { + mp.Add((string)deHt.Key, LLSDString.FromObject(deHt.Value)); + } + llsdBack.Add(mp); + } + return llsdBack; + } + private LLSDArray WrapLLSDMap(LLSDMap wrapMe) { LLSDArray array = new LLSDArray(); -- cgit v1.1 From 512e52be4cd0c942105ef5bec71ac8b78ffe02c1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Mar 2008 16:27:29 +0000 Subject: * Remove pointless boolean on AgentInventory.CreateRootFolder() --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index b73340c..78de4a5 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications { if (!String.IsNullOrEmpty(FileName)) { - m_log.Info("[AGENTINVENTORY]: Inventorystorage: Attempting to load " + FileName); + m_log.Info("[AGENTINVENTORY]: Inventory storage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index c04e8b9..2286b59 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -757,7 +757,7 @@ namespace OpenSim.Framework.UserManagement protected virtual InventoryData CreateInventoryData(LLUUID userID) { AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); + userInventory.CreateRootFolder(userID); ArrayList AgentInventoryArray = new ArrayList(); Hashtable TempHash; -- cgit v1.1 From c8f79eb9b49a4704e32a26ec04aeec3ff4c02754 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Mar 2008 16:39:38 +0000 Subject: * Refactor: Rename CreateInventoryData() to GetInventorySkeleton() * Replace the unused default GetInventorySkeleton() impleemntation with an abstract declaration - less confusing this way imho * Add some comments --- OpenSim/Framework/Communications/LoginService.cs | 50 ++++++++---------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 2286b59..e738d0b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -41,7 +41,7 @@ using OpenSim.Framework.Statistics; namespace OpenSim.Framework.UserManagement { - public class LoginService + public abstract class LoginService { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -73,6 +73,20 @@ namespace OpenSim.Framework.UserManagement } /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); + + /// + /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. + /// + /// + /// + protected abstract InventoryData GetInventorySkeleton(LLUUID userID); + + /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message /// /// The XMLRPC request @@ -196,7 +210,7 @@ namespace OpenSim.Framework.UserManagement LLUUID agentID = userProfile.UUID; // Inventory Library Section - InventoryData inventData = CreateInventoryData(agentID); + InventoryData inventData = GetInventorySkeleton(agentID); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -338,7 +352,7 @@ namespace OpenSim.Framework.UserManagement LLUUID agentID = userProfile.UUID; // Inventory Library Section - InventoryData inventData = CreateInventoryData(agentID); + InventoryData inventData = GetInventorySkeleton(agentID); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -407,15 +421,6 @@ namespace OpenSim.Framework.UserManagement } } - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) - { - } - public Hashtable ProcessHTMLLogin(Hashtable keysvals) { // Matches all unspecified characters @@ -754,27 +759,6 @@ namespace OpenSim.Framework.UserManagement return inventoryLibOwner; } - protected virtual InventoryData CreateInventoryData(LLUUID userID) - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToString(); - TempHash["version"] = (Int32) InvFolder.Version; - TempHash["type_default"] = (Int32) InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToString(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - public class InventoryData { public ArrayList InventoryArray = null; -- cgit v1.1 From 35dec2e53a7e79f7a1cc6db954723ca9769c993b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Mar 2008 17:37:55 +0000 Subject: * Refactor: Eliminate RequestUsersRoot() redundant method --- .../Framework/Communications/InventoryServiceBase.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 78de4a5..595fa65 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -110,18 +110,9 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public InventoryFolderBase RequestUsersRoot(LLUUID userID) - { - foreach (KeyValuePair plugin in m_plugins) - { - return plugin.Value.getUserRootFolder(userID); - } - return null; - } - - // See IInventoryServices public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) { + // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin foreach (KeyValuePair plugin in m_plugins) { plugin.Value.moveInventoryFolder(folder); @@ -137,7 +128,12 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public InventoryFolderBase RequestRootFolder(LLUUID userID) { - return RequestUsersRoot(userID); + // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin + foreach (KeyValuePair plugin in m_plugins) + { + return plugin.Value.getUserRootFolder(userID); + } + return null; } // See IInventoryServices @@ -149,7 +145,7 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public void CreateNewUserInventory(LLUUID user) { - InventoryFolderBase existingRootFolder = RequestUsersRoot(user); + InventoryFolderBase existingRootFolder = RequestRootFolder(user); if (null != existingRootFolder) { -- cgit v1.1 From 0a47a75b8894942e43a132c8479b1b17e7d4e8b5 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Mar 2008 19:35:01 +0000 Subject: * Send full inventory folder skeleton to standalone client logins rather than just the root child folders * This may resolve some current problems with non root child folders on standalone installations. * A fix for the same problem in grid mode will come soon. --- .../Communications/Cache/CachedUserInfo.cs | 5 +++++ .../Cache/UserProfileCacheService.cs | 16 +++++++-------- .../Framework/Communications/IInventoryServices.cs | 8 ++++++++ .../Communications/InventoryServiceBase.cs | 24 ++++++++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 3 ++- 5 files changed, 46 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 077a61d..59e5b6e 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -31,6 +31,9 @@ namespace OpenSim.Framework.Communications.Cache { public class CachedUserInfo { + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly CommunicationsManager m_parentCommsManager; // Fields public InventoryFolderImpl RootFolder = null; @@ -44,6 +47,8 @@ namespace OpenSim.Framework.Communications.Cache // Methods public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { + //m_log.DebugFormat("[INVENTORY CACHE]: Received folder {0} {1} for user {2}", folderInfo.name, folderInfo.folderID, userID); + if (userID == UserProfile.UUID) { if (RootFolder == null) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index fcfb53a..67022c7 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[USERCACHE]: User profile for user {0} not found", userID); + m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found", userID); } } } @@ -244,15 +244,14 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORYCACHE]: Could not find root folder for user {0}", remoteClient.Name); + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", remoteClient.Name); return; } } else { - m_log.ErrorFormat("[INVENTORYCACHE]: " + - "Could not find user profile for {0} for folder {1}", + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find user profile for {0} for folder {1}", remoteClient.Name, folderID); return; @@ -260,8 +259,7 @@ namespace OpenSim.Framework.Communications.Cache // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists - m_log.ErrorFormat("[INVENTORYCACHE]: " + - "Could not find folder {0} for user {1}", + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find folder {0} for user {1}", folderID, remoteClient.Name); } @@ -303,14 +301,14 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORYCACHE]: Could not find root folder for user {0}", agentID.ToString()); + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID.ToString()); return new List(); ; } } else { - m_log.ErrorFormat("[INVENTORYCACHE]: " + + m_log.ErrorFormat("[INVENTORY CACHE]: " + "Could not find user profile for {0} for folder {1}", agentID.ToString(), folderID); return new List(); @@ -318,7 +316,7 @@ namespace OpenSim.Framework.Communications.Cache // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists - m_log.ErrorFormat("[INVENTORYCACHE]: " + + m_log.ErrorFormat("[INVENTORY CACHE]: " + "Could not find folder {0} for user {1}", folderID, agentID.ToString()); // } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index bb46777..d824e9d 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -87,6 +87,14 @@ namespace OpenSim.Framework.Communications /// /// List RequestFirstLevelFolders(LLUUID userID); + + /// + /// Returns a list of all the folders in a given user's inventory. + /// + /// + /// A flat list of the user's inventory folder tree. + /// Null if there is no inventory for this user + List GetInventorySkeleton(LLUUID userId); /// /// Returns the named folder in that users inventory, returns null if folder is not found. diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 595fa65..d105069 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -108,6 +108,30 @@ namespace OpenSim.Framework.Communications return inventoryList; } + + // See IInventoryServices + public List GetInventorySkeleton(LLUUID userId) + { +// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + + List userFolders = new List(); + + InventoryFolderBase rootFolder = RequestRootFolder(userId); + userFolders.Add(rootFolder); + + foreach (KeyValuePair plugin in m_plugins) + { + IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); + userFolders.AddRange(folders); + } + +// foreach (InventoryFolderBase folder in userFolders) +// { +// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); +// } + + return userFolders; + } // See IInventoryServices public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 5ba37e6..332583c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -43,7 +43,8 @@ namespace OpenSim.Framework.UserManagement /// public abstract class UserManagerBase : IUserService { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; private Dictionary _plugins = new Dictionary(); -- cgit v1.1 From 7fcffa3a3a231a77d00bf2ec1772f0914073d28f Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 29 Mar 2008 17:18:47 +0000 Subject: Re-enabled terrain texture generation for the world map. Adam can clean up/ sort it out when he gets time. Most likely doesn't really work in grid mode as the generated textures are marked as temporary and I don't think they are updated to the asset server. We have to either live with these textures being sent to the asset server, and manually clean them out from time to time or wait until there is some asset management system in place. Also currently the texture is only generated at region startup, it is not updated after terraforming. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index d105069..6e909da 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -260,7 +260,7 @@ namespace OpenSim.Framework.Communications { AddFolder(folder); } - } + } private class UsersInventory { -- cgit v1.1 From 875211b262ecda2eced68b217221dead20cbdb6b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 29 Mar 2008 22:18:44 +0000 Subject: * Various 1.19.0.5 grid inventory request fixes. These will only take affect once the region and the grid servers have upgraded to this revision * You may also need to clear your cache before seeing any effect. * These fixes may or may not affect inventory on the RC client. * These fixes should make non-root folders work better, stop inventory failure on first login, allow trash to be emptied and make texture picker in object edit view work properly * Fixes are 1) make initial root folder request wait for async inventory delivery, 2) deliver all folders in the initial login skeleton, not just the root child ones and 3) deal with situations where we receive child folders from the inventory service before their parent is received. --- .../Communications/Cache/CachedUserInfo.cs | 128 +++++++++++++++++---- .../Cache/UserProfileCacheService.cs | 35 +++++- .../Communications/InventoryServiceBase.cs | 21 +++- OpenSim/Framework/Communications/LoginService.cs | 2 +- 4 files changed, 159 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 59e5b6e..f2dd2bf 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Collections.Generic; + using libsecondlife; namespace OpenSim.Framework.Communications.Cache @@ -35,50 +38,135 @@ namespace OpenSim.Framework.Communications.Cache = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private readonly CommunicationsManager m_parentCommsManager; - // Fields + + // FIXME: These need to be hidden behind accessors public InventoryFolderImpl RootFolder = null; public UserProfileData UserProfile = null; + + /// + /// Stores received folders for which we have not yet received the parents. + /// + private IDictionary> pendingCategorizationFolders + = new Dictionary>(); public CachedUserInfo(CommunicationsManager commsManager) { m_parentCommsManager = commsManager; } - - // Methods - public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) + + /// + /// Store a folder pending categorization when its parent is received. + /// + /// + private void AddPendingFolder(InventoryFolderImpl folder) { - //m_log.DebugFormat("[INVENTORY CACHE]: Received folder {0} {1} for user {2}", folderInfo.name, folderInfo.folderID, userID); + LLUUID parentFolderId = folder.parentID; - if (userID == UserProfile.UUID) + if (pendingCategorizationFolders.ContainsKey(parentFolderId)) + { + pendingCategorizationFolders[parentFolderId].Add(folder); + } + else + { + IList folders = new List(); + folders.Add(folder); + + pendingCategorizationFolders[parentFolderId] = folders; + } + } + + /// + /// Add any pending folders which are children of parent + /// + /// + /// A + /// + private void ResolvePendingFolders(InventoryFolderImpl parent) + { + if (pendingCategorizationFolders.ContainsKey(parent.folderID)) { - if (RootFolder == null) + foreach (InventoryFolderImpl folder in pendingCategorizationFolders[parent.folderID]) { - if (folderInfo.parentID == LLUUID.Zero) +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", +// folder.name, folder.folderID, parent.name, parent.folderID); + + if (!parent.SubFolders.ContainsKey(folder.folderID)) { - RootFolder = folderInfo; - } + parent.SubFolders.Add(folder.folderID, folder); + } } - else if (RootFolder.folderID == folderInfo.parentID) + } + } + + /// + /// Callback invoked when a folder is received from an async request to the inventory service. + /// + /// + /// + public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) + { + // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these + // are simply being swallowed + try + { +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", +// folderInfo.name, folderInfo.folderID, userID); + + if (userID == UserProfile.UUID) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.folderID)) + if (RootFolder == null) { - RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + if (folderInfo.parentID == LLUUID.Zero) + { + RootFolder = folderInfo; + } } - } - else - { - InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); - if (folder != null) + else if (RootFolder.folderID == folderInfo.parentID) { - if (!folder.SubFolders.ContainsKey(folderInfo.folderID)) + if (!RootFolder.SubFolders.ContainsKey(folderInfo.folderID)) { - folder.SubFolders.Add(folderInfo.folderID, folderInfo); + RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); } + else + { + AddPendingFolder(folderInfo); + } } + else + { + InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); + if (folder != null) + { + if (!folder.SubFolders.ContainsKey(folderInfo.folderID)) + { + folder.SubFolders.Add(folderInfo.folderID, folderInfo); + } + } + else + { + AddPendingFolder(folderInfo); + } + } + + ResolvePendingFolders(folderInfo); } } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CACHE] {0}", e); + } } + /// + /// Callback invoked when an item is received from an async request to the inventory service. + /// + /// FIXME: We're assuming here that items are always received after all the folders have been + /// received. + /// + /// + /// public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { if ((userID == UserProfile.UUID) && (RootFolder != null)) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 67022c7..c3f51da 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -27,7 +27,10 @@ using System; using System.Collections.Generic; +using System.Threading; + using libsecondlife; + using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache @@ -65,9 +68,7 @@ namespace OpenSim.Framework.Communications.Cache if (userInfo.UserProfile != null) { - // The request itself will occur when the agent finishes logging on to the region - // so there's no need to do it here. - //RequestInventoryForUser(userID, userInfo); + // The inventory will be populated when the user actually enters the scene m_userProfiles.Add(userID, userInfo); } else @@ -219,10 +220,34 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { + // XXX: When a client crosses into a scene, their entire inventory is fetched + // asynchronously. However, if the client is logging on and does not have a cached root + // folder, then the root folder request usually comes in *before* the async completes, leading to + // inventory failure. + // + // This is a crude way of dealing with that by retrying the lookup. + if (userProfile.RootFolder == null) + { + int attempts = 5; + while (attempts-- > 0) + { + Thread.Sleep(3000); + + if (userProfile.RootFolder != null) + { + break; + } + } + } + if (userProfile.RootFolder != null) { if (userProfile.RootFolder.folderID == folderID) { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Found root folder {0} for client {1}", +// folderID, remoteClient.AgentId); + remoteClient.SendInventoryFolderDetails( remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.RequestListOfFolders(), @@ -234,6 +259,10 @@ namespace OpenSim.Framework.Communications.Cache { if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Found folder {0} for client {1}", +// folderID, remoteClient.AgentId); + remoteClient.SendInventoryFolderDetails( remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 6e909da..5515c77 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -76,12 +76,27 @@ namespace OpenSim.Framework.Communications #region IInventoryServices methods - // See IInventoryServices + /// + /// Guid to UUID wrapper for same name IInventoryServices method + /// + /// + /// public List RequestFirstLevelFolders(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); return RequestFirstLevelFolders(userID); } + + /// + /// Guid to UUID wrapper for same name IInventoryServices method + /// + /// + /// + public List GetInventorySkeleton(Guid rawUserID) + { + LLUUID userID = new LLUUID(rawUserID); + return GetInventorySkeleton(userID); + } // See IInventoryServices public List RequestFirstLevelFolders(LLUUID userID) @@ -112,7 +127,7 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { -// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); List userFolders = new List(); @@ -173,7 +188,7 @@ namespace OpenSim.Framework.Communications if (null != existingRootFolder) { - m_log.ErrorFormat("[AGENTINVENTORY]: " + + m_log.ErrorFormat("[AGENT INVENTORY]: " + "Did not create a new inventory for user {0} since they already have " + "a root inventory folder with id {1}", user, existingRootFolder); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e738d0b..cbe8783 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -272,7 +272,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - m_log.Info("[LOGIN]: Login failed, exception" + e.ToString()); + m_log.Info("[LOGIN]: Login failed, " + e.ToString()); } } -- cgit v1.1 From a6999f8a5d011d7540c04fa5434864fab53b2ef8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 29 Mar 2008 23:07:48 +0000 Subject: * Refactor: Remove unused inventory methods, some of which weren't properly implemented anyway. --- .../Framework/Communications/IInventoryServices.cs | 16 ----------- .../Communications/InventoryServiceBase.cs | 31 +++------------------- 2 files changed, 4 insertions(+), 43 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index d824e9d..eaa2350 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -79,14 +79,6 @@ namespace OpenSim.Framework.Communications /// /// null if no root folder was found InventoryFolderBase RequestRootFolder(LLUUID userID); - - /// - /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) - /// for the given user. - /// - /// - /// - List RequestFirstLevelFolders(LLUUID userID); /// /// Returns a list of all the folders in a given user's inventory. @@ -95,13 +87,5 @@ namespace OpenSim.Framework.Communications /// A flat list of the user's inventory folder tree. /// Null if there is no inventory for this user List GetInventorySkeleton(LLUUID userId); - - /// - /// Returns the named folder in that users inventory, returns null if folder is not found. - /// - /// - /// - /// - InventoryFolderBase RequestNamedFolder(LLUUID userID, string folderName); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 5515c77..719e0d6 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -74,31 +74,14 @@ namespace OpenSim.Framework.Communications #endregion - #region IInventoryServices methods + #region IInventoryServices methods /// - /// Guid to UUID wrapper for same name IInventoryServices method + /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) + /// for the given user. /// - /// + /// /// - public List RequestFirstLevelFolders(Guid rawUserID) - { - LLUUID userID = new LLUUID(rawUserID); - return RequestFirstLevelFolders(userID); - } - - /// - /// Guid to UUID wrapper for same name IInventoryServices method - /// - /// - /// - public List GetInventorySkeleton(Guid rawUserID) - { - LLUUID userID = new LLUUID(rawUserID); - return GetInventorySkeleton(userID); - } - - // See IInventoryServices public List RequestFirstLevelFolders(LLUUID userID) { List inventoryList = new List(); @@ -176,12 +159,6 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public virtual InventoryFolderBase RequestNamedFolder(LLUUID userID, string folderName) - { - return null; - } - - // See IInventoryServices public void CreateNewUserInventory(LLUUID user) { InventoryFolderBase existingRootFolder = RequestRootFolder(user); -- cgit v1.1 From 2fddd775f48d9261772f804f0396bb24768afae7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 30 Mar 2008 00:45:04 +0000 Subject: * Stop the grid inventory service sending all folder and item details twice * This change will have no functional impact - we were already filtering out the dupes on the other end. --- .../Communications/InventoryServiceBase.cs | 33 +--------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 719e0d6..a0228e8 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -75,42 +75,11 @@ namespace OpenSim.Framework.Communications #endregion #region IInventoryServices methods - - /// - /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) - /// for the given user. - /// - /// - /// - public List RequestFirstLevelFolders(LLUUID userID) - { - List inventoryList = new List(); - InventoryFolderBase rootFolder = null; - - foreach (KeyValuePair plugin in m_plugins) - { - rootFolder = plugin.Value.getUserRootFolder(userID); - if (rootFolder != null) - { - m_log.Info( - "[INVENTORY]: Found root folder for user with ID " + userID + ". Retrieving inventory contents."); - - inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); - inventoryList.Insert(0, rootFolder); - return inventoryList; - } - } - - m_log.Warn( - "[INVENTORY]: Could not find a root folder belonging to user with ID " + userID); - - return inventoryList; - } // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { - m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + //m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); List userFolders = new List(); -- cgit v1.1 From fd2caf5f1673ad14702d89db9804f841c5cb861a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 30 Mar 2008 08:01:47 +0000 Subject: This update has good news and bad news, first the bad. * This update breaks inter-region communications, sorry. * You will need to run prebuild. Next, the good; * This update solves the unexpected binary element when Linux simulators inform windows simulators and vice versa. So Linux Simulators and Windows simulators are 100% compatible again. * This update introduces an Integer in the prim crossing method to tell the receiving simulator which XML method to use to load the prim that crossed the border. If the receiving prim doesn't support the method, the prim crossing fails and no prims are lost. That being said, it's best to update all your simulators to this revision at once. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index e7e1737..f018dd6 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -35,7 +35,7 @@ namespace OpenSim.Framework.Communications bool Available { get; } void CheckRegion(string address, uint port); bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); + bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData, int XMLMethod); bool RegionUp(SearializableRegionInfo region, ulong regionhandle); bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); -- cgit v1.1 From d53dd8a7cc883baf611e480d538f7a9d240681b3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 14:19:40 +0000 Subject: * Minor change on region grid asset client to change two store log messages to one --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index b952af2..3e703d2 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -94,19 +94,22 @@ namespace OpenSim.Framework.Communications.Cache // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); // xs.Serialize(s, asset); // RestClient rc = new RestClient(_assetServerUrl); - m_log.Info("[GRID ASSET CLIENT]: Storing asset"); + + string assetUrl = _assetServerUrl + "/assets/"; + //rc.AddResourcePath("assets"); // rc.RequestMethod = "POST"; // rc.Request(s); //m_log.InfoFormat("[ASSET]: Stored {0}", rc); - m_log.Info("[GRID ASSET CLIENT]: Sending to " + _assetServerUrl + "/assets/"); - RestObjectPoster.BeginPostObject(_assetServerUrl + "/assets/", asset); + m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); + + RestObjectPoster.BeginPostObject(assetUrl, asset); } catch (Exception e) { - m_log.Error("[GRID ASSET CLIENT]: " + e.Message); + m_log.ErrorFormat("[GRID ASSET CLIENT]: {0}", e); } } -- cgit v1.1 From af3118eccd0d471b748a1dd89e6899b51ae0332c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 17:08:58 +0000 Subject: * Fix problem where inventory code throws a swallowed exception on grid mode if the avatar has never logged in before --- .../Communications/InventoryServiceBase.cs | 50 ++++++++++++++-------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index a0228e8..3187215 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -79,25 +79,41 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { - //m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); - - List userFolders = new List(); - - InventoryFolderBase rootFolder = RequestRootFolder(userId); - userFolders.Add(rootFolder); - - foreach (KeyValuePair plugin in m_plugins) + try { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); - userFolders.AddRange(folders); - } - -// foreach (InventoryFolderBase folder in userFolders) -// { -// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); -// } + m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + + List userFolders = new List(); + + InventoryFolderBase rootFolder = RequestRootFolder(userId); + + // Agent is completely new and has no inventory structure yet. + if (null == rootFolder) + { + return null; + } + + userFolders.Add(rootFolder); + + foreach (KeyValuePair plugin in m_plugins) + { + IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); + userFolders.AddRange(folders); + } + + // foreach (InventoryFolderBase folder in userFolders) + // { + // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); + // } + + return userFolders; + } + catch (Exception e) + { + m_log.ErrorFormat("GetInventorySkeleton() exception {0}", e); + } - return userFolders; + return null; } // See IInventoryServices -- cgit v1.1 From 48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 17:34:32 +0000 Subject: * Log exceptions which make it up to the top of the http request frame, rather than having them disappear off into the ether --- .../Communications/InventoryServiceBase.cs | 52 +++++++++------------- 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 3187215..f38abd3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -79,41 +79,31 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { - try + m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + + InventoryFolderBase rootFolder = RequestRootFolder(userId); + + // Agent is completely new and has no inventory structure yet. + if (null == rootFolder) { - m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); - - List userFolders = new List(); - - InventoryFolderBase rootFolder = RequestRootFolder(userId); - - // Agent is completely new and has no inventory structure yet. - if (null == rootFolder) - { - return null; - } - - userFolders.Add(rootFolder); - - foreach (KeyValuePair plugin in m_plugins) - { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); - userFolders.AddRange(folders); - } - - // foreach (InventoryFolderBase folder in userFolders) - // { - // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); - // } - - return userFolders; + return null; } - catch (Exception e) + + List userFolders = new List(); + userFolders.Add(rootFolder); + + foreach (KeyValuePair plugin in m_plugins) { - m_log.ErrorFormat("GetInventorySkeleton() exception {0}", e); - } + IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); + userFolders.AddRange(folders); + } - return null; +// foreach (InventoryFolderBase folder in userFolders) +// { +// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); +// } + + return userFolders; } // See IInventoryServices -- cgit v1.1 From 93303072dd4edbb7d41ed629787bd22494b30cc1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 18:29:08 +0000 Subject: * Minor: If a user exists but has no inventory in standalone, automatically create new inventory folders * This mirrors the grid behaviour --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index f38abd3..feb0cca 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -79,7 +79,7 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { - m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); +// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); InventoryFolderBase rootFolder = RequestRootFolder(userId); @@ -87,9 +87,10 @@ namespace OpenSim.Framework.Communications if (null == rootFolder) { return null; - } + } + + List userFolders = new List(); - List userFolders = new List(); userFolders.Add(rootFolder); foreach (KeyValuePair plugin in m_plugins) -- cgit v1.1 From 106fd2f616cdd7086cf55325faf78b597d11f092 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 18:41:24 +0000 Subject: * From: Dr Scofield * (and Ansgar/Ansi) * Fleshes out the voice stubs to better interact with the viewer CAPS requests - no actual voice support yet! * In his own words "the attached patch enhances the existing voice support by returning a proper voice account user and password and is preparing the config file so that we can specify a SIP server (not yet working). currently the SIP is hardcoded. the next step is to refactor voice support into a region module. working on that. " --- .../Framework/Communications/Capabilities/Caps.cs | 132 +++++++++------------ .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 52 ++++++++ .../Capabilities/LLSDVoiceAccountResponse.cs | 49 ++++++++ 3 files changed, 159 insertions(+), 74 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index c9e7507..66de991 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -55,6 +55,12 @@ namespace OpenSim.Region.Capabilities public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); + /// + /// FIXME This is a temporary delegate, and should disappear once the voice code is fleshed out and moved into its + /// own region module. + /// + public delegate CachedUserInfo GetUserDetailsCAPS(LLUUID agentID); + public class Caps { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -67,7 +73,7 @@ namespace OpenSim.Region.Capabilities /// private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } - + private static readonly string m_requestPath = "0000/"; private static readonly string m_mapLayerPath = "0001/"; private static readonly string m_newInventory = "0002/"; @@ -93,6 +99,7 @@ namespace OpenSim.Region.Capabilities public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; + public GetUserDetailsCAPS CAPSGetUserDetails = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) @@ -436,98 +443,75 @@ namespace OpenSim.Region.Capabilities return null; } - - public string ParcelVoiceInfoRequest(string request, string path, string param) - { + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(string request, string path, string param) { try { - m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - - //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); - //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - - //string capsBase = "/CAPS/" + m_capsObjectPath; - //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - //TaskInventoryScriptUpdater uploader = - //new TaskInventoryScriptUpdater( - //llsdUpdateRequest.item_id, - //llsdUpdateRequest.task_id, - //llsdUpdateRequest.is_script_running, - //capsBase + uploaderPath, - //m_httpListener, - //m_dumpAssetsToFile); - //uploader.OnUpLoad += TaskScriptUpdated; - - //m_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"; - - // m_log.InfoFormat("[CAPS]: " + - // "ScriptTaskInventory response: {0}", - // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply("parcel_local_id16region_nameTeravus Testvoice_credentialschannel_urisip:conference@192.168.1.127\nsip:user@192.168.1.127"); + m_log.DebugFormat("[CAPS][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); + + // XXX brutal hack, we need to get channel_uri, region + // name, and parcel_local_id from somewhere + Hashtable creds = new Hashtable(); + + creds["channel_uri"] = "sip:testroom@testserver.com"; + + LLSDParcelVoiceInfoResponse parcelVoiceInfo = + new LLSDParcelVoiceInfoResponse("OpenSim Test", 1, creds); + + // XXX for debugging purposes: + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + m_log.DebugFormat("[CAPS][PARCELVOICE]: {0}", r); + + return r; } catch (Exception e) { m_log.Error("[CAPS]: " + e.ToString()); } - + return null; } - public string ProvisionVoiceAccountRequest(string request, string path, string param) - { + /// + /// Callback for a client request for Voice Account Details + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(string request, string path, string param) { try { - m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - - //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); - //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - - //string capsBase = "/CAPS/" + m_capsObjectPath; - //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - //TaskInventoryScriptUpdater uploader = - //new TaskInventoryScriptUpdater( - //llsdUpdateRequest.item_id, - //llsdUpdateRequest.task_id, - //llsdUpdateRequest.is_script_running, - //capsBase + uploaderPath, - //m_httpListener, - //m_dumpAssetsToFile); - //uploader.OnUpLoad += TaskScriptUpdated; - - //m_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"; - - // m_log.InfoFormat("[CAPS]: " + - // "ScriptTaskInventory response: {0}", - // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply("eventsbodymajor_version1minor_version0region_nameTeravus TestmessageRequiredVoiceVersionid152477222"); + m_log.DebugFormat("[CAPS][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); + + if (null == CAPSGetUserDetails) throw new Exception("CAPSGetUserDetails null"); + + string voiceUser = "x" + Convert.ToBase64String(m_agentID.GetBytes()); + voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); + + CachedUserInfo userInfo = CAPSGetUserDetails(m_agentID); + if (null == userInfo) throw new Exception("CAPSGetUserDetails returned null"); + + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash); + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); + return r; } catch (Exception e) { - m_log.Error("[CAPS]: " + e.ToString()); + m_log.Error("[CAPS][PROVISIONVOICE]: " + e.ToString()); } return null; } + /// /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs new file mode 100644 index 0000000..4fb0544 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -0,0 +1,52 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System.Collections; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDParcelVoiceInfoResponse + { + public int parcel_local_id; + public string region_name; + public Hashtable voice_credentials; + + public LLSDParcelVoiceInfoResponse() + { + } + + public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) + { + region_name = region; + parcel_local_id = localID; + voice_credentials = creds; + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs new file mode 100644 index 0000000..8a18213 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -0,0 +1,49 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDVoiceAccountResponse + { + public string username; + public string password; + + public LLSDVoiceAccountResponse() + { + } + + public LLSDVoiceAccountResponse(string user, string pass) + { + username = user; + password = pass; + } + } +} \ No newline at end of file -- cgit v1.1 From a0a0229fdfc980b1a716e94c33812937431671e6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 31 Mar 2008 23:54:49 +0000 Subject: * Set Svn Properties eol-style: |337 --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index cbe8783..413a934 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.UserManagement string clientversion = (string)requestData["version"]; m_log.Info("[LOGIN]: Client version: " + clientversion); } - + if (requestData.Contains("start")) { startLocationRequest = (string)requestData["start"]; -- cgit v1.1 From b790a16e986a0296b3a006f0db2b1011e5377ce9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 2 Apr 2008 01:03:31 +0000 Subject: * Updating the version of the ODE library. (big update). The Mac library needs to be updated still. * Adding some XMPP stuff that's incomplete. --- OpenSim/Framework/Communications/XMPP/Stanza.cs | 31 ++++++++++++++++++++++ .../Framework/Communications/XMPP/XMPPParser.cs | 14 ++++++++++ 2 files changed, 45 insertions(+) create mode 100644 OpenSim/Framework/Communications/XMPP/Stanza.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XMPPParser.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/Stanza.cs b/OpenSim/Framework/Communications/XMPP/Stanza.cs new file mode 100644 index 0000000..4c57114 --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/Stanza.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace OpenSim.Framework.Communications.XMPP +{ + public class Stanza + { + + public string localName = String.Empty; + public JId to; + public JId from; + string id; + string lang; + string nodeName; + + public Stanza(XmlNode node, Object defaults, bool hasID) + { + + } + //public virtual XmlElement getNode() + //{ + //return new XmlElement(); + //} + public virtual string generateId() + { + return ""; + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs new file mode 100644 index 0000000..0539afb --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using OpenSim.Framework; + + +namespace OpenSim.Framework.Communications.XMPP +{ + public class XMPPParser + { + + } +} -- cgit v1.1 From f27f8610726b1e148d17e69c7fef34d2fc814bd3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 2 Apr 2008 16:46:58 +0000 Subject: * Attempt to resolve mantis 873 by placing caps removal operations in a critical section --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 66de991..53cad66 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -401,7 +401,7 @@ namespace OpenSim.Region.Capabilities { try { -// m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); + //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); -- cgit v1.1 From 5fe4a39927754ce797aa728ed41d189cab95b058 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 3 Apr 2008 15:28:50 +0000 Subject: * Adding request time limiting strategy for texture requests, though this isn't useable yet --- .../Communications/Limit/RepeatLimitStrategy.cs | 2 +- .../Communications/Limit/TimeLimitStrategy.cs | 140 +++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100755 OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index 82122fc..85ff2bd 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Limit /// public bool IsFirstRefusal(TId id) { - if (m_maxRequests + 1 == requestCounts[id]) + if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) { return true; } diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs new file mode 100755 index 0000000..b2b4f14 --- /dev/null +++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs @@ -0,0 +1,140 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; + +namespace OpenSim.Framework.Communications.Limit +{ + /// + /// Limit requests by discarding repeat attempts that occur within a given time period + /// + /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests + /// for the same texture at different resolutions. + /// + public class TimeLimitStrategy : IRequestLimitStrategy + { + /// + /// Record the time at which an asset request occurs. + /// + private readonly Dictionary requests = new Dictionary(); + + /// + /// The minimum time period between which requests for the same data will be serviced. + /// + private readonly TimeSpan m_repeatPeriod; + public TimeSpan RepeatPeriod + { + get { return m_repeatPeriod; } + } + + /// + /// + public TimeLimitStrategy(TimeSpan repeatPeriod) + { + m_repeatPeriod = repeatPeriod; + } + + /// + /// + /// + public bool AllowRequest(TId id) + { + if (IsMonitoringRequests(id)) + { + DateTime now = DateTime.Now; + TimeSpan elapsed = now - requests[id].Time; + + if (elapsed < RepeatPeriod) + { + requests[id].Refusals += 1; + return false; + } + + requests[id].Time = now; + } + + return true; + } + + /// + /// + /// + public bool IsFirstRefusal(TId id) + { + if (IsMonitoringRequests(id)) + { + if (1 == requests[id].Refusals) + { + return true; + } + } + + return false; + } + + /// + /// + /// + public void MonitorRequests(TId id) + { + if (!IsMonitoringRequests(id)) + { + requests.Add(id, new Request(System.DateTime.Now)); + } + } + + /// + /// + /// + public bool IsMonitoringRequests(TId id) + { + return requests.ContainsKey(id); + } + } + + /// + /// Private request details. + /// + class Request + { + /// + /// Time of last request + /// + public DateTime Time; + + /// + /// Number of refusals associated with this request + /// + public int Refusals; + + public Request(DateTime time) + { + Time = time; + } + } +} -- cgit v1.1 From 042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 3 Apr 2008 15:44:20 +0000 Subject: * From: Dr Scofield * This patch removes voice code into a region module. This required the implementation of events and other code to allow region modules to register their own caps handlers, and should allow different voice module implementations. * CAVEAT: This does not provide complete voice support, it merely provides the hooks so that it can be plugged in. --- .../Framework/Communications/Capabilities/Caps.cs | 189 ++++++--------------- .../Communications/Capabilities/CapsHandlers.cs | 144 ++++++++++++++++ .../Communications/Capabilities/LLSDCapsDetails.cs | 52 ------ 3 files changed, 192 insertions(+), 193 deletions(-) create mode 100755 OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 53cad66..886ca49 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -55,25 +55,22 @@ namespace OpenSim.Region.Capabilities public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); - /// - /// FIXME This is a temporary delegate, and should disappear once the voice code is fleshed out and moved into its - /// own region module. - /// - public delegate CachedUserInfo GetUserDetailsCAPS(LLUUID agentID); - public class Caps { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private string m_httpListenerHostName; private uint m_httpListenPort; - + /// /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. /// private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } + private CapsHandlers m_capsHandlers; + private static readonly string m_requestPath = "0000/"; private static readonly string m_mapLayerPath = "0001/"; private static readonly string m_newInventory = "0002/"; @@ -99,7 +96,6 @@ namespace OpenSim.Region.Capabilities public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; - public GetUserDetailsCAPS CAPSGetUserDetails = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) @@ -111,6 +107,7 @@ namespace OpenSim.Region.Capabilities m_httpListenPort = httpPort; m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; + m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort); } /// @@ -123,27 +120,31 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; try - { - m_httpListener.AddStreamHandler( - new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); - m_httpListener.AddStreamHandler( + { + // the root of all evil + m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); + m_capsHandlers["MapLayer"] = + new LLSDStreamhandler("POST", + capsBase + m_mapLayerPath, + GetMapLayer); + m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler("POST", capsBase + m_newInventory, - NewAgentInventoryRequest)); - - // m_httpListener.AddStreamHandler( - // new LLSDStreamhandler("POST", - // capsBase + m_fetchInventory, - // FetchInventory)); - - - AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); - //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); - AddLegacyCapsHandler(m_httpListener, m_parcelVoiceInfoRequestPath, ParcelVoiceInfoRequest); - AddLegacyCapsHandler(m_httpListener, m_provisionVoiceAccountRequestPath, ProvisionVoiceAccountRequest); - AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); - AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); - AddLegacyCapsHandler(m_httpListener, m_fetchInventoryPath, FetchInventoryRequest); + NewAgentInventoryRequest); + m_capsHandlers["UpdateNotecardAgentInventory"] = + new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); + m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; + m_capsHandlers["UpdateScriptTaskInventory"] = + new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); + m_capsHandlers["FetchInventoryDescendents"] = + new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); + // m_capsHandlers["FetchInventoryDescendents"] = + // new LLSDStreamhandler("POST", + // capsBase + m_fetchInventory, + // FetchInventory)); + // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", + // capsBase + m_requestTexture, + // RequestTexture); } catch (Exception e) { @@ -152,35 +153,29 @@ namespace OpenSim.Region.Capabilities } /// + /// Register a handler. This allows modules to register handlers. + /// + /// + /// + public void RegisterHandler(string capName, IRequestHandler handler) + { + m_capsHandlers[capName] = handler; + m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); + } + + /// /// Remove all CAPS service handlers. /// - /// FIXME: Would be much nicer to remove and all paths to a single list. However, this is a little awkward - /// than it could be as we set up some handlers differently (legacy and non-legacy) /// /// /// /// public void DeregisterHandlers() { - string capsBase = "/CAPS/" + m_capsObjectPath; - - m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_requestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardUpdatePath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardTaskUpdatePath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_fetchInventoryPath); - } - - //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] - //Commented out the obsolete as at this time the first caps request can not use the new Caps method - //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. - private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) - { - string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); + foreach(string capsName in m_capsHandlers.Caps) + { + m_capsHandlers.Remove(capsName); + } } /// @@ -193,31 +188,12 @@ namespace OpenSim.Region.Capabilities public string CapsRequest(string request, string path, string param) { //Console.WriteLine("caps request " + request); - string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); + string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); return result; } - /// - /// Return an LLSDCapsDetails listing all the capabilities this server can provide - /// - /// - protected LLSDCapsDetails GetCapabilities() - { - LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + - m_capsObjectPath; - caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; - caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; - caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; - caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath; - caps.FetchInventoryDescendents = capsBaseUrl + m_fetchInventoryPath; - caps.ParcelVoiceInfoRequest = capsBaseUrl + m_parcelVoiceInfoRequestPath; - caps.ProvisionVoiceAccountRequest = capsBaseUrl + m_provisionVoiceAccountRequestPath; - - return caps; - } + // FIXME: these all should probably go into the respective region + // modules public string FetchInventoryRequest(string request, string path, string param) { @@ -443,75 +419,6 @@ namespace OpenSim.Region.Capabilities return null; } - /// - /// Callback for a client request for ParcelVoiceInfo - /// - /// - /// - /// - /// - public string ParcelVoiceInfoRequest(string request, string path, string param) { - try - { - m_log.DebugFormat("[CAPS][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); - - // XXX brutal hack, we need to get channel_uri, region - // name, and parcel_local_id from somewhere - Hashtable creds = new Hashtable(); - - creds["channel_uri"] = "sip:testroom@testserver.com"; - - LLSDParcelVoiceInfoResponse parcelVoiceInfo = - new LLSDParcelVoiceInfoResponse("OpenSim Test", 1, creds); - - // XXX for debugging purposes: - string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[CAPS][PARCELVOICE]: {0}", r); - - return r; - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - - return null; - } - - /// - /// Callback for a client request for Voice Account Details - /// - /// - /// - /// - /// - public string ProvisionVoiceAccountRequest(string request, string path, string param) { - try - { - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); - - if (null == CAPSGetUserDetails) throw new Exception("CAPSGetUserDetails null"); - - string voiceUser = "x" + Convert.ToBase64String(m_agentID.GetBytes()); - voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); - - CachedUserInfo userInfo = CAPSGetUserDetails(m_agentID); - if (null == userInfo) throw new Exception("CAPSGetUserDetails returned null"); - - LLSDVoiceAccountResponse voiceAccountResponse = - new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash); - string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); - return r; - } - catch (Exception e) - { - m_log.Error("[CAPS][PROVISIONVOICE]: " + e.ToString()); - } - - return null; - } - /// /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. /// diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs new file mode 100755 index 0000000..a3d6b71 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -0,0 +1,144 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; + +namespace OpenSim.Region.Capabilities +{ + /// + /// CapsHandlers is a cap handler container but also takes + /// care of adding and removing cap handlers to and from the + /// supplied BaseHttpServer. + /// + public class CapsHandlers + { + private Dictionary m_capsHandlers = new Dictionary(); + private BaseHttpServer m_httpListener; + private string m_httpListenerHostName; + private uint m_httpListenerPort; + + /// + /// base HTTP server + /// host name of the HTTP + /// server + /// HTTP port + public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) + { + m_httpListener = httpListener; + m_httpListenerHostName = httpListenerHostname; + m_httpListenerPort = httpListenerPort; + } + + /// + /// Remove the cap handler for a capability. + /// + /// name of the capability of the cap + /// handler to be removed + public void Remove(string capsName) + { + m_capsHandlers.Remove(capsName); + } + + public bool ContainsCap(string cap) + { + return m_capsHandlers.ContainsKey(cap); + } + + /// + /// The indexer allows us to treat the CapsHandlers object + /// in an intuitive dictionary like way. + /// + /// + /// The indexer will throw an exception when you try to + /// retrieve a cap handler for a cap that is not contained in + /// CapsHandlers. + /// + public IRequestHandler this[string idx] + { + get + { + return m_capsHandlers[idx]; + } + + set + { + if (m_capsHandlers.ContainsKey(idx)) + { + m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); + m_capsHandlers.Remove(idx); + } + + if (null == value) return; + + m_capsHandlers[idx] = value; + m_httpListener.AddStreamHandler(value); + } + } + + /// + /// Return the list of cap names for which this CapsHandlers + /// object contains cap handlers. + /// + public string[] Caps + { + get + { + string[] __keys = new string[m_capsHandlers.Keys.Count]; + m_capsHandlers.Keys.CopyTo(__keys, 0); + return __keys; + } + } + + /// + /// Return an LLSD-serializable Hashtable describing the + /// capabilities and their handler details. + /// + public Hashtable CapsDetails + { + get + { + Hashtable caps = new Hashtable(); + string baseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); + foreach (string capsName in m_capsHandlers.Keys) + { + // skip SEED cap + if ("SEED" == capsName) continue; + caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; + } + return caps; + } + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs deleted file mode 100644 index bd1c9da..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDCapsDetails - { - public string MapLayer = String.Empty; - public string NewFileAgentInventory = String.Empty; - //public string EventQueueGet = String.Empty; - // public string RequestTextureDownload = String.Empty; - // public string ChatSessionRequest = String.Empty; - public string UpdateNotecardAgentInventory = String.Empty; - public string UpdateScriptAgentInventory = String.Empty; - public string UpdateScriptTaskInventory = String.Empty; - public string ParcelVoiceInfoRequest = String.Empty; - public string FetchInventoryDescendents = String.Empty; - public string ProvisionVoiceAccountRequest = String.Empty; - - - public LLSDCapsDetails() - { - } - } -} -- cgit v1.1 From 4f174fbf57160acc05911e9e3b342e8da9eb3644 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 3 Apr 2008 18:25:01 +0000 Subject: Update svn properties. --- .../Communications/Capabilities/CapsHandlers.cs | 288 ++++++++++----------- .../Communications/Limit/TimeLimitStrategy.cs | 0 2 files changed, 144 insertions(+), 144 deletions(-) mode change 100755 => 100644 OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs mode change 100755 => 100644 OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs old mode 100755 new mode 100644 index a3d6b71..3518e20 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -1,144 +1,144 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using libsecondlife; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; - -namespace OpenSim.Region.Capabilities -{ - /// - /// CapsHandlers is a cap handler container but also takes - /// care of adding and removing cap handlers to and from the - /// supplied BaseHttpServer. - /// - public class CapsHandlers - { - private Dictionary m_capsHandlers = new Dictionary(); - private BaseHttpServer m_httpListener; - private string m_httpListenerHostName; - private uint m_httpListenerPort; - - /// - /// base HTTP server - /// host name of the HTTP - /// server - /// HTTP port - public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) - { - m_httpListener = httpListener; - m_httpListenerHostName = httpListenerHostname; - m_httpListenerPort = httpListenerPort; - } - - /// - /// Remove the cap handler for a capability. - /// - /// name of the capability of the cap - /// handler to be removed - public void Remove(string capsName) - { - m_capsHandlers.Remove(capsName); - } - - public bool ContainsCap(string cap) - { - return m_capsHandlers.ContainsKey(cap); - } - - /// - /// The indexer allows us to treat the CapsHandlers object - /// in an intuitive dictionary like way. - /// - /// - /// The indexer will throw an exception when you try to - /// retrieve a cap handler for a cap that is not contained in - /// CapsHandlers. - /// - public IRequestHandler this[string idx] - { - get - { - return m_capsHandlers[idx]; - } - - set - { - if (m_capsHandlers.ContainsKey(idx)) - { - m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); - m_capsHandlers.Remove(idx); - } - - if (null == value) return; - - m_capsHandlers[idx] = value; - m_httpListener.AddStreamHandler(value); - } - } - - /// - /// Return the list of cap names for which this CapsHandlers - /// object contains cap handlers. - /// - public string[] Caps - { - get - { - string[] __keys = new string[m_capsHandlers.Keys.Count]; - m_capsHandlers.Keys.CopyTo(__keys, 0); - return __keys; - } - } - - /// - /// Return an LLSD-serializable Hashtable describing the - /// capabilities and their handler details. - /// - public Hashtable CapsDetails - { - get - { - Hashtable caps = new Hashtable(); - string baseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); - foreach (string capsName in m_capsHandlers.Keys) - { - // skip SEED cap - if ("SEED" == capsName) continue; - caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; - } - return caps; - } - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; + +namespace OpenSim.Region.Capabilities +{ + /// + /// CapsHandlers is a cap handler container but also takes + /// care of adding and removing cap handlers to and from the + /// supplied BaseHttpServer. + /// + public class CapsHandlers + { + private Dictionary m_capsHandlers = new Dictionary(); + private BaseHttpServer m_httpListener; + private string m_httpListenerHostName; + private uint m_httpListenerPort; + + /// + /// base HTTP server + /// host name of the HTTP + /// server + /// HTTP port + public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) + { + m_httpListener = httpListener; + m_httpListenerHostName = httpListenerHostname; + m_httpListenerPort = httpListenerPort; + } + + /// + /// Remove the cap handler for a capability. + /// + /// name of the capability of the cap + /// handler to be removed + public void Remove(string capsName) + { + m_capsHandlers.Remove(capsName); + } + + public bool ContainsCap(string cap) + { + return m_capsHandlers.ContainsKey(cap); + } + + /// + /// The indexer allows us to treat the CapsHandlers object + /// in an intuitive dictionary like way. + /// + /// + /// The indexer will throw an exception when you try to + /// retrieve a cap handler for a cap that is not contained in + /// CapsHandlers. + /// + public IRequestHandler this[string idx] + { + get + { + return m_capsHandlers[idx]; + } + + set + { + if (m_capsHandlers.ContainsKey(idx)) + { + m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); + m_capsHandlers.Remove(idx); + } + + if (null == value) return; + + m_capsHandlers[idx] = value; + m_httpListener.AddStreamHandler(value); + } + } + + /// + /// Return the list of cap names for which this CapsHandlers + /// object contains cap handlers. + /// + public string[] Caps + { + get + { + string[] __keys = new string[m_capsHandlers.Keys.Count]; + m_capsHandlers.Keys.CopyTo(__keys, 0); + return __keys; + } + } + + /// + /// Return an LLSD-serializable Hashtable describing the + /// capabilities and their handler details. + /// + public Hashtable CapsDetails + { + get + { + Hashtable caps = new Hashtable(); + string baseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); + foreach (string capsName in m_capsHandlers.Keys) + { + // skip SEED cap + if ("SEED" == capsName) continue; + caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; + } + return caps; + } + } + } +} diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs old mode 100755 new mode 100644 -- cgit v1.1 From 75b192a2a0ae832f74a91f1a7b40d31eed5af50a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 4 Apr 2008 05:50:46 +0000 Subject: * Fixing permissions on items returned via CAPS based inventory --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 886ca49..6e78452 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -198,6 +198,7 @@ namespace OpenSim.Region.Capabilities public string FetchInventoryRequest(string request, string path, string param) { request = request.Replace("folders", ""); + request = request.Replace("\n", ""); request = request.Replace("", ""); //Console.WriteLine("inventory request " + request); @@ -249,7 +250,7 @@ namespace OpenSim.Region.Capabilities llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.invType).ToLower(); llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.creatorsID; - llsdItem.permissions.base_mask = (int)invItem.inventoryBasePermissions; + llsdItem.permissions.base_mask = (int)invItem.inventoryCurrentPermissions; llsdItem.permissions.everyone_mask = (int)invItem.inventoryEveryOnePermissions; llsdItem.permissions.group_id = LLUUID.Zero; llsdItem.permissions.group_mask = 0; -- cgit v1.1 From 42e428427700663a9eef179e27bb02b6dd9abb16 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 4 Apr 2008 08:07:49 +0000 Subject: * Fixes CAPS InventoryDescendants and the notorious 'LLSDParseException:expected ' error. * Objects folder still exhibits strange behavior. --- .../Framework/Communications/Capabilities/Caps.cs | 55 ++++++++++++++++++---- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6e78452..dadafa3 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -197,16 +197,53 @@ namespace OpenSim.Region.Capabilities public string FetchInventoryRequest(string request, string path, string param) { - request = request.Replace("folders", ""); - request = request.Replace("\n", ""); - request = request.Replace("", ""); + string unmodifiedRequest = request.ToString(); + + + Hashtable hash = new Hashtable(); + try + { + + hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + } + catch (LLSD.LLSDParseException pe) + { + m_log.Error("[INVENTORY]: Fetch error: " + pe.Message); + m_log.Error("Request:" + request.ToString()); + m_log.Error("OriginalRequest:" + unmodifiedRequest.ToString()); + } + //LLSDArray llsdFolderRequest = LLSDHelpers. + ArrayList foldersrequested = (ArrayList)hash["folders"]; + + string response = ""; + + for (int i = 0; i < foldersrequested.Count; i++) + { + string inventoryitemstr = ""; + Hashtable inventoryhash = (Hashtable)foldersrequested[i]; + + LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); + LLSDHelpers.DeserialiseLLSDMap(inventoryhash, llsdRequest); + LLSDInventoryDescendents reply = FetchInventory(llsdRequest); + + inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); + inventoryitemstr = inventoryitemstr.Replace("folders", ""); + inventoryitemstr = inventoryitemstr.Replace("", ""); + response += inventoryitemstr; + } + if (response.Length == 0) + { + // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. + // Therefore, I'm concluding that the client only has so many threads available to do requests + // and when a thread stalls.. is stays stalled. + // Therefore we need to return something valid + response = "folders"; + } + else + { + response = "folders" + response + ""; + } - //Console.WriteLine("inventory request " + request); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); - LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); - LLSDInventoryDescendents reply = FetchInventory(llsdRequest); - string response = LLSDHelpers.SerialiseLLSDReply(reply); return response; } -- cgit v1.1 From 27876795f4b6053757423171aaa4920ac2555d25 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 4 Apr 2008 08:33:29 +0000 Subject: * Fixed up some documentation regarding the inventory descendants method XML. Cleaned up an error report. Noted at the top, why the two unused caps path variables must stay. --- .../Framework/Communications/Capabilities/Caps.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index dadafa3..4211c20 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -78,8 +78,11 @@ namespace OpenSim.Region.Capabilities private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; private static readonly string m_fetchInventoryPath = "0006/"; - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; - private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + + // The following two entries are in a module, however, there also here so that we don't re-assign + // the path to another cap by mistake. + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. + private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -195,6 +198,18 @@ namespace OpenSim.Region.Capabilities // FIXME: these all should probably go into the respective region // modules + // Request is like: + // + // folders + // + // + // fetch-folders1fetch-items1folder-id8e1e3a30-b9bf-11dc-95ff-0800200c9a66owner-id11111111-1111-0000-0000-000100bba000sort-order1 + // + // + // + // + // + // multiple fetch-folder maps are allowed within the larger folders map. public string FetchInventoryRequest(string request, string path, string param) { string unmodifiedRequest = request.ToString(); @@ -210,7 +225,6 @@ namespace OpenSim.Region.Capabilities { m_log.Error("[INVENTORY]: Fetch error: " + pe.Message); m_log.Error("Request:" + request.ToString()); - m_log.Error("OriginalRequest:" + unmodifiedRequest.ToString()); } //LLSDArray llsdFolderRequest = LLSDHelpers. ArrayList foldersrequested = (ArrayList)hash["folders"]; -- cgit v1.1 From f5ed6357505953a28dd281a2bd9a4e497df7af7b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 4 Apr 2008 17:43:29 +0000 Subject: * Make objects appear in 1.19.1.4 inventory again * You will probably need to clear your client's cache before this will take effect * The problem was that the underlying libsecondlife.AssetType was returning "primitive" rather than "object". This fix is in lieu of correcting/updating our libsecondlife.dll --- .../Framework/Communications/Capabilities/Caps.cs | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 4211c20..00de14d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -29,7 +29,9 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; + using libsecondlife; + using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; @@ -213,20 +215,20 @@ namespace OpenSim.Region.Capabilities public string FetchInventoryRequest(string request, string path, string param) { string unmodifiedRequest = request.ToString(); - + + //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); Hashtable hash = new Hashtable(); try { - hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); } catch (LLSD.LLSDParseException pe) { - m_log.Error("[INVENTORY]: Fetch error: " + pe.Message); - m_log.Error("Request:" + request.ToString()); + m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); + m_log.Error("Request: " + request.ToString()); } - //LLSDArray llsdFolderRequest = LLSDHelpers. + ArrayList foldersrequested = (ArrayList)hash["folders"]; string response = ""; @@ -258,6 +260,8 @@ namespace OpenSim.Region.Capabilities response = "folders" + response + ""; } + //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request {0}", response); + return response; } @@ -297,7 +301,16 @@ namespace OpenSim.Region.Capabilities llsdItem.item_id = invItem.inventoryID; llsdItem.name = invItem.inventoryName; llsdItem.parent_id = invItem.parentFolderID; - llsdItem.type = Enum.GetName(typeof(AssetType), invItem.assetType).ToLower(); + llsdItem.type = Enum.GetName(typeof(AssetType), invItem.assetType).ToLower(); + + // XXX Temporary fix for 'objects not appearing in inventory' problem. The asset type from libsecondlife is + // returning "primitive" when it should returning "object"! It looks like this is fixed in the latest libsecondlife, + // but our own libsl1550 doesn't have it either! + if ("primitive".Equals(llsdItem.type)) + { + llsdItem.type = "object"; + } + llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.invType).ToLower(); llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.creatorsID; -- cgit v1.1 From 57afbdbdbdfea90d5e27ea37ced2a72219cce4e9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 4 Apr 2008 19:09:56 +0000 Subject: From: Kurt Taylor Patch to remove commented NotImpemented calls from within implemented script functions --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index ed2fcf4..4d37e74 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -241,9 +241,7 @@ namespace OpenSim.Framework.Communications.Cache /// If the asset was not found this is still called with the asset UUID but with a null asset data reference public void GetAsset(LLUUID assetId, AssetRequestCallback callback, bool isTexture) { -#if DEBUG //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); -#endif AssetBase asset; -- cgit v1.1 From f43681510725f5b95fcb864a1f3e4b744fcaf992 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 7 Apr 2008 23:15:35 +0000 Subject: Refactor InventoryItemBase to do the following: * wrap fields as Properties * rename some fields/properties to more sensible names * set style to PropName to match more standard C# approach --- .../Communications/Cache/CachedUserInfo.cs | 14 ++--- .../Communications/Cache/LibraryRootFolder.cs | 60 +++++++++++----------- .../Framework/Communications/Capabilities/Caps.cs | 46 ++++++++--------- .../Communications/InventoryServiceBase.cs | 2 +- 4 files changed, 61 insertions(+), 61 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f2dd2bf..cb1eb5a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -171,21 +171,21 @@ namespace OpenSim.Framework.Communications.Cache { if ((userID == UserProfile.UUID) && (RootFolder != null)) { - if (itemInfo.parentFolderID == RootFolder.folderID) + if (itemInfo.Folder == RootFolder.folderID) { - if (!RootFolder.Items.ContainsKey(itemInfo.inventoryID)) + if (!RootFolder.Items.ContainsKey(itemInfo.ID)) { - RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + RootFolder.Items.Add(itemInfo.ID, itemInfo); } } else { - InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder); if (folder != null) { - if (!folder.Items.ContainsKey(itemInfo.inventoryID)) + if (!folder.Items.ContainsKey(itemInfo.ID)) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + folder.Items.Add(itemInfo.ID, itemInfo); } } } @@ -214,7 +214,7 @@ namespace OpenSim.Framework.Communications.Cache bool result = false; if ((userID == UserProfile.UUID) && (RootFolder != null)) { - result = RootFolder.DeleteItem(item.inventoryID); + result = RootFolder.DeleteItem(item.ID); if (result) { m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index b624b15..12a07eb 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -116,19 +116,19 @@ namespace OpenSim.Framework.Communications.Cache int assetType, int invType, LLUUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = inventoryID; - item.assetID = assetID; - item.inventoryDescription = description; - item.inventoryName = name; - item.assetType = assetType; - item.invType = invType; - item.parentFolderID = parentFolderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; + item.Owner = libOwner; + item.Creator = libOwner; + item.ID = inventoryID; + item.AssetID = assetID; + item.Description = description; + item.Name = name; + item.AssetType = assetType; + item.InvType = invType; + item.Folder = parentFolderID; + item.BasePermissions = 0x7FFFFFFF; + item.EveryOnePermissions = 0x7FFFFFFF; + item.CurrentPermissions = 0x7FFFFFFF; + item.NextPermissions = 0x7FFFFFFF; return item; } @@ -204,31 +204,31 @@ namespace OpenSim.Framework.Communications.Cache private void ReadItemFromConfig(IConfig config) { InventoryItemBase item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString())); - item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); - item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString())); - item.inventoryDescription = config.GetString("description", System.String.Empty); - item.inventoryName = config.GetString("name", System.String.Empty); - item.assetType = config.GetInt("assetType", 0); - item.invType = config.GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); + item.Owner = libOwner; + item.Creator = libOwner; + item.ID = new LLUUID(config.GetString("inventoryID", folderID.ToString())); + item.AssetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); + item.Folder = new LLUUID(config.GetString("folderID", folderID.ToString())); + item.Description = config.GetString("description", System.String.Empty); + item.Name = config.GetString("name", System.String.Empty); + item.AssetType = config.GetInt("assetType", 0); + item.InvType = config.GetInt("inventoryType", 0); + item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); + item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); + item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); + item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); - if (libraryFolders.ContainsKey(item.parentFolderID)) + if (libraryFolders.ContainsKey(item.Folder)) { - InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; + InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; - parentFolder.Items.Add(item.inventoryID, item); + parentFolder.Items.Add(item.ID, item); } else { m_log.WarnFormat( "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", - item.inventoryName, item.inventoryID, item.parentFolderID); + item.Name, item.ID, item.Folder); } } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 00de14d..315daab 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -294,14 +294,14 @@ namespace OpenSim.Region.Capabilities private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) { LLSDInventoryItem llsdItem = new LLSDInventoryItem(); - llsdItem.asset_id = invItem.assetID; + llsdItem.asset_id = invItem.AssetID; llsdItem.created_at = 1000; - llsdItem.desc = invItem.inventoryDescription; + llsdItem.desc = invItem.Description; llsdItem.flags = 0; - llsdItem.item_id = invItem.inventoryID; - llsdItem.name = invItem.inventoryName; - llsdItem.parent_id = invItem.parentFolderID; - llsdItem.type = Enum.GetName(typeof(AssetType), invItem.assetType).ToLower(); + llsdItem.item_id = invItem.ID; + llsdItem.name = invItem.Name; + llsdItem.parent_id = invItem.Folder; + llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); // XXX Temporary fix for 'objects not appearing in inventory' problem. The asset type from libsecondlife is // returning "primitive" when it should returning "object"! It looks like this is fixed in the latest libsecondlife, @@ -311,17 +311,17 @@ namespace OpenSim.Region.Capabilities llsdItem.type = "object"; } - llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.invType).ToLower(); + llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower(); llsdItem.permissions = new LLSDPermissions(); - llsdItem.permissions.creator_id = invItem.creatorsID; - llsdItem.permissions.base_mask = (int)invItem.inventoryCurrentPermissions; - llsdItem.permissions.everyone_mask = (int)invItem.inventoryEveryOnePermissions; + llsdItem.permissions.creator_id = invItem.Creator; + llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; + llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; llsdItem.permissions.group_id = LLUUID.Zero; llsdItem.permissions.group_mask = 0; llsdItem.permissions.is_owner_group = false; - llsdItem.permissions.next_owner_mask = (int)invItem.inventoryNextPermissions; + llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; llsdItem.permissions.owner_id = m_agentID; // FixMe - llsdItem.permissions.owner_mask = (int)invItem.inventoryCurrentPermissions; + llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; llsdItem.sale_info = new LLSDSaleInfo(); llsdItem.sale_info.sale_price = 10; llsdItem.sale_info.sale_type = "not"; @@ -587,17 +587,17 @@ namespace OpenSim.Region.Capabilities m_assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); - item.avatarID = m_agentID; - item.creatorsID = m_agentID; - item.inventoryID = inventoryItem; - item.assetID = asset.FullID; - item.inventoryDescription = assetDescription; - item.inventoryName = assetName; - item.assetType = assType; - item.invType = inType; - item.parentFolderID = parentFolder; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; + item.Owner = m_agentID; + item.Creator = m_agentID; + item.ID = inventoryItem; + item.AssetID = asset.FullID; + item.Description = assetDescription; + item.Name = assetName; + item.AssetType = assType; + item.InvType = inType; + item.Folder = parentFolder; + item.CurrentPermissions = 2147483647; + item.NextPermissions = 2147483647; if (AddNewInventoryItem != null) { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index feb0cca..f41bd27 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -218,7 +218,7 @@ namespace OpenSim.Framework.Communications { foreach (KeyValuePair plugin in m_plugins) { - plugin.Value.deleteInventoryItem(item.inventoryID); + plugin.Value.deleteInventoryItem(item.ID); } } -- cgit v1.1 From 5ee75998ce4d941efd937848d28f3a4dac6ba6cc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 7 Apr 2008 23:27:05 +0000 Subject: more refactoring, this time on InventoryFolderBase * wrap attributes in properties * clean up names a little bit * clean up name styles --- .../Communications/Cache/CachedUserInfo.cs | 26 +-- .../Communications/Cache/InventoryFolderImpl.cs | 24 +-- .../Communications/Cache/LibraryRootFolder.cs | 40 ++-- .../Cache/UserProfileCacheService.cs | 46 ++--- .../Communications/CommunicationsManager.cs | 2 +- .../Communications/InventoryServiceBase.cs | 216 ++++++++++----------- OpenSim/Framework/Communications/LoginService.cs | 10 +- 7 files changed, 182 insertions(+), 182 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index cb1eb5a..e39333b 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache /// private void AddPendingFolder(InventoryFolderImpl folder) { - LLUUID parentFolderId = folder.parentID; + LLUUID parentFolderId = folder.ParentID; if (pendingCategorizationFolders.ContainsKey(parentFolderId)) { @@ -83,17 +83,17 @@ namespace OpenSim.Framework.Communications.Cache /// private void ResolvePendingFolders(InventoryFolderImpl parent) { - if (pendingCategorizationFolders.ContainsKey(parent.folderID)) + if (pendingCategorizationFolders.ContainsKey(parent.ID)) { - foreach (InventoryFolderImpl folder in pendingCategorizationFolders[parent.folderID]) + foreach (InventoryFolderImpl folder in pendingCategorizationFolders[parent.ID]) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - if (!parent.SubFolders.ContainsKey(folder.folderID)) + if (!parent.SubFolders.ContainsKey(folder.ID)) { - parent.SubFolders.Add(folder.folderID, folder); + parent.SubFolders.Add(folder.ID, folder); } } } @@ -118,16 +118,16 @@ namespace OpenSim.Framework.Communications.Cache { if (RootFolder == null) { - if (folderInfo.parentID == LLUUID.Zero) + if (folderInfo.ParentID == LLUUID.Zero) { RootFolder = folderInfo; } } - else if (RootFolder.folderID == folderInfo.parentID) + else if (RootFolder.ID == folderInfo.ParentID) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.folderID)) + if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) { - RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); } else { @@ -136,12 +136,12 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); if (folder != null) { - if (!folder.SubFolders.ContainsKey(folderInfo.folderID)) + if (!folder.SubFolders.ContainsKey(folderInfo.ID)) { - folder.SubFolders.Add(folderInfo.folderID, folderInfo); + folder.SubFolders.Add(folderInfo.ID, folderInfo); } } else @@ -171,7 +171,7 @@ namespace OpenSim.Framework.Communications.Cache { if ((userID == UserProfile.UUID) && (RootFolder != null)) { - if (itemInfo.Folder == RootFolder.folderID) + if (itemInfo.Folder == RootFolder.ID) { if (!RootFolder.Items.ContainsKey(itemInfo.ID)) { diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 20edf51..37907a0 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -45,12 +45,12 @@ namespace OpenSim.Framework.Communications.Cache // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) { - agentID = folderbase.agentID; - folderID = folderbase.folderID; - name = folderbase.name; - parentID = folderbase.parentID; - type = folderbase.type; - version = folderbase.version; + AgentID = folderbase.AgentID; + ID = folderbase.ID; + Name = folderbase.Name; + ParentID = folderbase.ParentID; + Type = folderbase.Type; + Version = folderbase.Version; } public InventoryFolderImpl() @@ -63,12 +63,12 @@ namespace OpenSim.Framework.Communications.Cache if (!SubFolders.ContainsKey(folderID)) { InventoryFolderImpl subFold = new InventoryFolderImpl(); - subFold.name = folderName; - subFold.folderID = folderID; - subFold.type = (short) type; - subFold.parentID = this.folderID; - subFold.agentID = agentID; - SubFolders.Add(subFold.folderID, subFold); + subFold.Name = folderName; + subFold.ID = folderID; + subFold.Type = (short) type; + subFold.ParentID = this.ID; + subFold.AgentID = AgentID; + SubFolders.Add(subFold.ID, subFold); return subFold; } return null; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 12a07eb..cb82850 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -56,14 +56,14 @@ namespace OpenSim.Framework.Communications.Cache { m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); - agentID = libOwner; - folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); - name = "OpenSim Library"; - parentID = LLUUID.Zero; - type = (short) 8; - version = (ushort) 1; + AgentID = libOwner; + ID = new LLUUID("00000112-000f-0000-0000-000100bba000"); + Name = "OpenSim Library"; + ParentID = LLUUID.Zero; + Type = (short) 8; + Version = (ushort) 1; - libraryFolders.Add(folderID, this); + libraryFolders.Add(ID, this); LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); @@ -172,20 +172,20 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); - folderInfo.name = config.GetString("name", "unknown"); - folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); - folderInfo.type = (short)config.GetInt("type", 8); + folderInfo.ID = new LLUUID(config.GetString("folderID", ID.ToString())); + folderInfo.Name = config.GetString("name", "unknown"); + folderInfo.ParentID = new LLUUID(config.GetString("parentFolderID", ID.ToString())); + folderInfo.Type = (short)config.GetInt("type", 8); - folderInfo.agentID = libOwner; - folderInfo.version = 1; + folderInfo.AgentID = libOwner; + folderInfo.Version = 1; - if (libraryFolders.ContainsKey(folderInfo.parentID)) + if (libraryFolders.ContainsKey(folderInfo.ParentID)) { - InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; + InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; - libraryFolders.Add(folderInfo.folderID, folderInfo); - parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + libraryFolders.Add(folderInfo.ID, folderInfo); + parentFolder.SubFolders.Add(folderInfo.ID, folderInfo); // m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); } @@ -193,7 +193,7 @@ namespace OpenSim.Framework.Communications.Cache { m_log.WarnFormat( "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", - folderInfo.name, folderInfo.folderID, folderInfo.parentID); + folderInfo.Name, folderInfo.ID, folderInfo.ParentID); } } @@ -206,9 +206,9 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; item.Creator = libOwner; - item.ID = new LLUUID(config.GetString("inventoryID", folderID.ToString())); + item.ID = new LLUUID(config.GetString("inventoryID", ID.ToString())); item.AssetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); - item.Folder = new LLUUID(config.GetString("folderID", folderID.ToString())); + item.Folder = new LLUUID(config.GetString("folderID", ID.ToString())); item.Description = config.GetString("description", System.String.Empty); item.Name = config.GetString("name", System.String.Empty); item.AssetType = config.GetInt("assetType", 0); diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index c3f51da..6f11d60 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -105,7 +105,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.RootFolder != null) { - if (userProfile.RootFolder.folderID == parentID) + if (userProfile.RootFolder.ID == parentID) { InventoryFolderImpl createdFolder = userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); @@ -113,12 +113,12 @@ namespace OpenSim.Framework.Communications.Cache if (createdFolder != null) { InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.agentID = createdFolder.agentID; - createdBaseFolder.folderID = createdFolder.folderID; - createdBaseFolder.name = createdFolder.name; - createdBaseFolder.parentID = createdFolder.parentID; - createdBaseFolder.type = createdFolder.type; - createdBaseFolder.version = createdFolder.version; + createdBaseFolder.AgentID = createdFolder.AgentID; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } } @@ -156,12 +156,12 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.RootFolder != null) { InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.agentID = remoteClient.AgentId; - baseFolder.folderID = folderID; - baseFolder.name = name; - baseFolder.parentID = parentID; - baseFolder.type = (short) type; - baseFolder.version = userProfile.RootFolder.version; + baseFolder.AgentID = remoteClient.AgentId; + baseFolder.ID = folderID; + baseFolder.Name = name; + baseFolder.ParentID = parentID; + baseFolder.Type = (short) type; + baseFolder.Version = userProfile.RootFolder.Version; m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } } @@ -176,9 +176,9 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.RootFolder != null) { InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.agentID = remoteClient.AgentId; - baseFolder.folderID = folderID; - baseFolder.parentID = parentID; + baseFolder.AgentID = remoteClient.AgentId; + baseFolder.ID = folderID; + baseFolder.ParentID = parentID; m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } } @@ -199,10 +199,10 @@ namespace OpenSim.Framework.Communications.Cache // XXX We're not handling sortOrder yet! InventoryFolderImpl fold = null; - if (folderID == libraryRoot.folderID) + if (folderID == libraryRoot.ID) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), + libraryRoot.AgentID, libraryRoot.ID, libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, folderID, fold.RequestListOfItems(), + libraryRoot.AgentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -242,7 +242,7 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.RootFolder != null) { - if (userProfile.RootFolder.folderID == folderID) + if (userProfile.RootFolder.ID == folderID) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Found root folder {0} for client {1}", @@ -301,7 +301,7 @@ namespace OpenSim.Framework.Communications.Cache // if (fetchItems) // { InventoryFolderImpl fold = null; - if (folderID == libraryRoot.folderID) + if (folderID == libraryRoot.ID) { return libraryRoot.RequestListOfItems(); } @@ -316,7 +316,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.RootFolder != null) { - if (userProfile.RootFolder.folderID == folderID) + if (userProfile.RootFolder.ID == folderID) { return userProfile.RootFolder.RequestListOfItems(); } @@ -377,7 +377,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) { - if (ownerID == libraryRoot.agentID) + if (ownerID == libraryRoot.AgentID) { //Console.WriteLine("request info for library item"); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d96709d..6b5ef1b 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -240,7 +240,7 @@ namespace OpenSim.Framework.Communications public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfileCacheService.libraryRoot.agentID) + if (uuid == m_userProfileCacheService.libraryRoot.AgentID) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index f41bd27..4abfc5a 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -95,7 +95,7 @@ namespace OpenSim.Framework.Communications foreach (KeyValuePair plugin in m_plugins) { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); + IList folders = plugin.Value.getFolderHierarchy(rootFolder.ID); userFolders.AddRange(folders); } @@ -190,7 +190,7 @@ namespace OpenSim.Framework.Communications protected void AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.name, folder.folderID, folder.parentID); + "[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.Name, folder.ID, folder.ParentID); foreach (KeyValuePair plugin in m_plugins) { @@ -239,141 +239,141 @@ namespace OpenSim.Framework.Communications { InventoryFolderBase folder = new InventoryFolderBase(); - folder.parentID = LLUUID.Zero; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "My Inventory"; - folder.type = (short)AssetType.Folder; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = LLUUID.Zero; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "My Inventory"; + folder.Type = (short)AssetType.Folder; + folder.Version = 1; + Folders.Add(folder.ID, folder); - LLUUID rootFolder = folder.folderID; + LLUUID rootFolder = folder.ID; folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Animations"; - folder.type = (short)AssetType.Animation; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Animations"; + folder.Type = (short)AssetType.Animation; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Body Parts"; - folder.type = (short)AssetType.Bodypart; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Body Parts"; + folder.Type = (short)AssetType.Bodypart; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Calling Cards"; - folder.type = (short)AssetType.CallingCard; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Calling Cards"; + folder.Type = (short)AssetType.CallingCard; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Clothing"; - folder.type = (short)AssetType.Clothing; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Clothing"; + folder.Type = (short)AssetType.Clothing; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Gestures"; - folder.type = (short)AssetType.Gesture; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Gestures"; + folder.Type = (short)AssetType.Gesture; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Landmarks"; - folder.type = (short)AssetType.Landmark; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Landmarks"; + folder.Type = (short)AssetType.Landmark; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Lost And Found"; - folder.type = (short)AssetType.LostAndFoundFolder; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Lost And Found"; + folder.Type = (short)AssetType.LostAndFoundFolder; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Notecards"; - folder.type = (short)AssetType.Notecard; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Notecards"; + folder.Type = (short)AssetType.Notecard; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Objects"; - folder.type = (short)AssetType.Primitive; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Objects"; + folder.Type = (short)AssetType.Primitive; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Photo Album"; - folder.type = (short)AssetType.SnapshotFolder; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Photo Album"; + folder.Type = (short)AssetType.SnapshotFolder; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Scripts"; - folder.type = (short)AssetType.LSLText; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Scripts"; + folder.Type = (short)AssetType.LSLText; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Sounds"; - folder.type = (short)AssetType.Sound; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Sounds"; + folder.Type = (short)AssetType.Sound; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Textures"; - folder.type = (short)AssetType.Texture; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Textures"; + folder.Type = (short)AssetType.Texture; + folder.Version = 1; + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); - folder.parentID = rootFolder; - folder.agentID = user; - folder.folderID = LLUUID.Random(); - folder.name = "Trash"; - folder.type = (short)AssetType.TrashFolder; - folder.version = 1; - Folders.Add(folder.folderID, folder); + folder.ParentID = rootFolder; + folder.AgentID = user; + folder.ID = LLUUID.Random(); + folder.Name = "Trash"; + folder.Type = (short)AssetType.TrashFolder; + folder.Version = 1; + Folders.Add(folder.ID, folder); } } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 413a934..6f558a0 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -734,11 +734,11 @@ namespace OpenSim.Framework.UserManagement foreach (InventoryFolderBase folder in rootFolders.Values) { Hashtable TempHash = new Hashtable(); - TempHash["name"] = folder.name; - TempHash["parent_id"] = folder.parentID.ToString(); - TempHash["version"] = (Int32)folder.version; - TempHash["type_default"] = (Int32)folder.type; - TempHash["folder_id"] = folder.folderID.ToString(); + TempHash["name"] = folder.Name; + TempHash["parent_id"] = folder.ParentID.ToString(); + TempHash["version"] = (Int32)folder.Version; + TempHash["type_default"] = (Int32)folder.Type; + TempHash["folder_id"] = folder.ID.ToString(); folderHashes.Add(TempHash); } -- cgit v1.1 From 90422db35a9540a5eabfca0ede239d7efc36c83e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 8 Apr 2008 14:39:29 +0000 Subject: * Update code to use patched libsecondlife.dll which removes the problem where the AssetType enum was 'Primitive' rather than 'Object' * The libsecondlife patch was also applied to libsecondlife itself in r1714 * Many, many thanks to Dr Schofield (IBM) for his help on this :) --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 11 +---------- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 315daab..36bebe8 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -301,16 +301,7 @@ namespace OpenSim.Region.Capabilities llsdItem.item_id = invItem.ID; llsdItem.name = invItem.Name; llsdItem.parent_id = invItem.Folder; - llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); - - // XXX Temporary fix for 'objects not appearing in inventory' problem. The asset type from libsecondlife is - // returning "primitive" when it should returning "object"! It looks like this is fixed in the latest libsecondlife, - // but our own libsl1550 doesn't have it either! - if ("primitive".Equals(llsdItem.type)) - { - llsdItem.type = "object"; - } - + llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower(); llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.Creator; diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 4abfc5a..1250f53 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -326,7 +326,7 @@ namespace OpenSim.Framework.Communications folder.AgentID = user; folder.ID = LLUUID.Random(); folder.Name = "Objects"; - folder.Type = (short)AssetType.Primitive; + folder.Type = (short)AssetType.Object; folder.Version = 1; Folders.Add(folder.ID, folder); -- cgit v1.1 From 8eab365e213650a3937b92f9aa82a710a84d5903 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 8 Apr 2008 20:31:36 +0000 Subject: * Adjust some inventory lookup failure messages to reduce confusion as to what just went wrong --- .../Communications/Cache/UserProfileCacheService.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 6f11d60..b22c0af 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -280,8 +280,9 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find user profile for {0} for folder {1}", - remoteClient.Name, folderID); + m_log.ErrorFormat( + "[USER CACHE]: HandleFetchInventoryDescendents() could not find user profile {0}, {1}", + remoteClient.Name, remoteClient.AgentId); return; } @@ -337,9 +338,10 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORY CACHE]: " + - "Could not find user profile for {0} for folder {1}", - agentID.ToString(), folderID); + m_log.ErrorFormat( + "[USER CACHE]: HandleFetchInventoryDescendentsCAPS() Could not find user profile for {0}", + agentID); + return new List(); } -- cgit v1.1 From a6d27e09295cd0160d3439fbfa6598f08c431608 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 8 Apr 2008 23:26:31 +0000 Subject: further refactor and rename of InventoryFolderBase properties to reflect what they really are. --- .../Communications/Cache/InventoryFolderImpl.cs | 4 +-- .../Communications/Cache/LibraryRootFolder.cs | 4 +-- .../Cache/UserProfileCacheService.cs | 12 ++++----- .../Communications/CommunicationsManager.cs | 2 +- .../Communications/InventoryServiceBase.cs | 30 +++++++++++----------- 5 files changed, 26 insertions(+), 26 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 37907a0..091a6a3 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) { - AgentID = folderbase.AgentID; + Owner = folderbase.Owner; ID = folderbase.ID; Name = folderbase.Name; ParentID = folderbase.ParentID; @@ -67,7 +67,7 @@ namespace OpenSim.Framework.Communications.Cache subFold.ID = folderID; subFold.Type = (short) type; subFold.ParentID = this.ID; - subFold.AgentID = AgentID; + subFold.Owner = Owner; SubFolders.Add(subFold.ID, subFold); return subFold; } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index cb82850..03036d0 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Communications.Cache { m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); - AgentID = libOwner; + Owner = libOwner; ID = new LLUUID("00000112-000f-0000-0000-000100bba000"); Name = "OpenSim Library"; ParentID = LLUUID.Zero; @@ -177,7 +177,7 @@ namespace OpenSim.Framework.Communications.Cache folderInfo.ParentID = new LLUUID(config.GetString("parentFolderID", ID.ToString())); folderInfo.Type = (short)config.GetInt("type", 8); - folderInfo.AgentID = libOwner; + folderInfo.Owner = libOwner; folderInfo.Version = 1; if (libraryFolders.ContainsKey(folderInfo.ParentID)) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b22c0af..2dc2374 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -113,7 +113,7 @@ namespace OpenSim.Framework.Communications.Cache if (createdFolder != null) { InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.AgentID = createdFolder.AgentID; + createdBaseFolder.Owner = createdFolder.Owner; createdBaseFolder.ID = createdFolder.ID; createdBaseFolder.Name = createdFolder.Name; createdBaseFolder.ParentID = createdFolder.ParentID; @@ -156,7 +156,7 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.RootFolder != null) { InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.AgentID = remoteClient.AgentId; + baseFolder.Owner = remoteClient.AgentId; baseFolder.ID = folderID; baseFolder.Name = name; baseFolder.ParentID = parentID; @@ -176,7 +176,7 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.RootFolder != null) { InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.AgentID = remoteClient.AgentId; + baseFolder.Owner = remoteClient.AgentId; baseFolder.ID = folderID; baseFolder.ParentID = parentID; m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); @@ -202,7 +202,7 @@ namespace OpenSim.Framework.Communications.Cache if (folderID == libraryRoot.ID) { remoteClient.SendInventoryFolderDetails( - libraryRoot.AgentID, libraryRoot.ID, libraryRoot.RequestListOfItems(), + libraryRoot.Owner, libraryRoot.ID, libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - libraryRoot.AgentID, folderID, fold.RequestListOfItems(), + libraryRoot.Owner, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -379,7 +379,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) { - if (ownerID == libraryRoot.AgentID) + if (ownerID == libraryRoot.Owner) { //Console.WriteLine("request info for library item"); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6b5ef1b..95a0e05 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -240,7 +240,7 @@ namespace OpenSim.Framework.Communications public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfileCacheService.libraryRoot.AgentID) + if (uuid == m_userProfileCacheService.libraryRoot.Owner) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 1250f53..97d963d 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -240,7 +240,7 @@ namespace OpenSim.Framework.Communications InventoryFolderBase folder = new InventoryFolderBase(); folder.ParentID = LLUUID.Zero; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "My Inventory"; folder.Type = (short)AssetType.Folder; @@ -251,7 +251,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Animations"; folder.Type = (short)AssetType.Animation; @@ -260,7 +260,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Body Parts"; folder.Type = (short)AssetType.Bodypart; @@ -269,7 +269,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Calling Cards"; folder.Type = (short)AssetType.CallingCard; @@ -278,7 +278,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Clothing"; folder.Type = (short)AssetType.Clothing; @@ -287,7 +287,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Gestures"; folder.Type = (short)AssetType.Gesture; @@ -296,7 +296,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Landmarks"; folder.Type = (short)AssetType.Landmark; @@ -305,7 +305,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Lost And Found"; folder.Type = (short)AssetType.LostAndFoundFolder; @@ -314,7 +314,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Notecards"; folder.Type = (short)AssetType.Notecard; @@ -323,7 +323,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Objects"; folder.Type = (short)AssetType.Object; @@ -332,7 +332,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Photo Album"; folder.Type = (short)AssetType.SnapshotFolder; @@ -341,7 +341,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Scripts"; folder.Type = (short)AssetType.LSLText; @@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Sounds"; folder.Type = (short)AssetType.Sound; @@ -359,7 +359,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Textures"; folder.Type = (short)AssetType.Texture; @@ -368,7 +368,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; - folder.AgentID = user; + folder.Owner = user; folder.ID = LLUUID.Random(); folder.Name = "Trash"; folder.Type = (short)AssetType.TrashFolder; -- cgit v1.1 From c176caeb05c2264654b764e4d010561da60c24fc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 13:53:06 +0000 Subject: moved fields to properties for UserDataProfile, which was actually a little more work than I expected given the copious use of out params. --- .../Communications/Cache/CachedUserInfo.cs | 10 +-- .../Communications/CommunicationsManager.cs | 10 +-- OpenSim/Framework/Communications/LoginService.cs | 46 +++++++------- .../Framework/Communications/UserManagerBase.cs | 72 +++++++++++----------- 4 files changed, 69 insertions(+), 69 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index e39333b..75fe1aa 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -114,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.name, folderInfo.folderID, userID); - if (userID == UserProfile.UUID) + if (userID == UserProfile.Id) { if (RootFolder == null) { @@ -169,7 +169,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { if (itemInfo.Folder == RootFolder.ID) { @@ -194,7 +194,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { ItemReceive(userID, itemInfo); m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } @@ -212,7 +212,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { result = RootFolder.DeleteItem(item.ID); if (result) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 95a0e05..6b01d8f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -164,9 +164,9 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.UUID); + m_inventoryService.CreateNewUserInventory(userProf.Id); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); - return userProf.UUID; + return userProf.Id; } } @@ -249,9 +249,9 @@ namespace OpenSim.Framework.Communications UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) { - LLUUID profileId = profileData.UUID; - string firstname = profileData.username; - string lastname = profileData.surname; + LLUUID profileId = profileData.Id; + string firstname = profileData.FirstName; + string lastname = profileData.SurName; remote_client.SendNameReply(profileId, firstname, lastname); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 6f558a0..e5ad7a0 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -184,13 +184,13 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) { //TODO: The following statements can cause trouble: // If agentOnline could not turn from true back to false normally // because of some problem, for instance, the crashment of server or client, // the user cannot log in any longer. - userProfile.currentAgent.agentOnline = false; + userProfile.CurrentAgent.agentOnline = false; m_userManager.CommitAgent(ref userProfile); // Reject the login @@ -207,7 +207,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.UUID; + LLUUID agentID = userProfile.Id; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -217,16 +217,16 @@ namespace OpenSim.Framework.UserManagement InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; + userProfile.RootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint) (Util.RandomClass.Next()); - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -334,9 +334,9 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) { - userProfile.currentAgent = null; + userProfile.CurrentAgent = null; m_userManager.CommitAgent(ref userProfile); // Reject the login @@ -349,7 +349,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.UUID; + LLUUID agentID = userProfile.Id; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -359,16 +359,16 @@ namespace OpenSim.Framework.UserManagement InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; + userProfile.RootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -491,7 +491,7 @@ namespace OpenSim.Framework.UserManagement if (goodweblogin) { LLUUID webloginkey = LLUUID.Random(); - m_userManager.StoreWebLoginKey(user.UUID, webloginkey); + m_userManager.StoreWebLoginKey(user.Id, webloginkey); statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + @@ -639,7 +639,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); // Web Login method seems to also occasionally send the hashed password itself @@ -650,13 +650,13 @@ namespace OpenSim.Framework.UserManagement password = password.Remove(0, 3); //remove $1$ - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); // Testing... //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.passwordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); return passwordSuccess; } @@ -664,10 +664,10 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); // Match web login key unless it's the default weblogin key LLUUID.Zero - passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero); + passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != LLUUID.Zero); return passwordSuccess; } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 332583c..02be6bd 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.UserManagement if (profile != null) { - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.Id); return profile; } } @@ -113,7 +113,7 @@ namespace OpenSim.Framework.UserManagement if (null != profile) { - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.Id); return profile; } } @@ -298,7 +298,7 @@ namespace OpenSim.Framework.UserManagement public void clearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); - profile.currentAgent = null; + profile.CurrentAgent = null; setUserProfile(profile); } @@ -355,28 +355,28 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.UUID; + agent.UUID = profile.Id; // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; + agent.currentHandle = profile.HomeRegion; + agent.currentPos = profile.HomeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) { string startLoc = ((string)requestData["start"]).Trim(); - if (("last" == startLoc) && (profile.currentAgent != null)) + if (("last" == startLoc) && (profile.CurrentAgent != null)) { - if ((profile.currentAgent.currentPos.X > 0) - && (profile.currentAgent.currentPos.Y > 0) - && (profile.currentAgent.currentPos.Z > 0) + if ((profile.CurrentAgent.currentPos.X > 0) + && (profile.CurrentAgent.currentPos.Y > 0) + && (profile.CurrentAgent.currentPos.Z > 0) ) { // TODO: Right now, currentRegion has not been used in GridServer for requesting region. // TODO: It is only using currentHandle. - agent.currentRegion = profile.currentAgent.currentRegion; - agent.currentHandle = profile.currentAgent.currentHandle; - agent.currentPos = profile.currentAgent.currentPos; + agent.currentRegion = profile.CurrentAgent.currentRegion; + agent.currentHandle = profile.CurrentAgent.currentHandle; + agent.currentPos = profile.CurrentAgent.currentPos; } } @@ -406,7 +406,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = LLUUID.Zero; // Fill in later agent.currentRegion = LLUUID.Zero; // Fill in later - profile.currentAgent = agent; + profile.CurrentAgent = agent; } /// @@ -432,9 +432,9 @@ namespace OpenSim.Framework.UserManagement if (userProfile != null) { // This line needs to be in side the above if statement or the UserServer will crash on some logouts. - m_log.Info("[LOGOUT]: " + userProfile.username + " " + userProfile.surname + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); + m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); - userAgent = userProfile.currentAgent; + userAgent = userProfile.CurrentAgent; if (userAgent != null) { userAgent.agentOnline = false; @@ -447,7 +447,7 @@ namespace OpenSim.Framework.UserManagement userAgent.currentHandle = regionhandle; userAgent.currentPos = currentPos; - userProfile.currentAgent = userAgent; + userProfile.CurrentAgent = userAgent; CommitAgent(ref userProfile); } @@ -481,11 +481,11 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.UUID; + agent.UUID = profile.Id; // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; + agent.currentHandle = profile.HomeRegion; + agent.currentPos = profile.HomeLocation; // What time did the user login? agent.loginTime = Util.UnixTimeSinceEpoch(); @@ -495,7 +495,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = LLUUID.Zero; // Fill in later agent.currentRegion = LLUUID.Zero; // Fill in later - profile.currentAgent = agent; + profile.CurrentAgent = agent; } /// @@ -508,7 +508,7 @@ namespace OpenSim.Framework.UserManagement // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" // TODO: what is the logic should be? bool ret = false; - ret = AddUserAgent(profile.currentAgent); + ret = AddUserAgent(profile.CurrentAgent); ret = ret & setUserProfile(profile); return ret; } @@ -522,16 +522,16 @@ namespace OpenSim.Framework.UserManagement public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); - user.homeLocation = new LLVector3(128, 128, 100); - user.UUID = LLUUID.Random(); - user.username = firstName; - user.surname = lastName; - user.passwordHash = pass; - user.passwordSalt = String.Empty; - user.created = Util.UnixTimeSinceEpoch(); - user.homeLookAt = new LLVector3(100, 100, 100); - user.homeRegionX = regX; - user.homeRegionY = regY; + user.HomeLocation = new LLVector3(128, 128, 100); + user.Id = LLUUID.Random(); + user.FirstName = firstName; + user.SurName = lastName; + user.PasswordHash = pass; + user.PasswordSalt = String.Empty; + user.Created = Util.UnixTimeSinceEpoch(); + user.HomeLookAt = new LLVector3(100, 100, 100); + user.HomeRegionX = regX; + user.HomeRegionY = regY; foreach (KeyValuePair plugin in _plugins) { @@ -545,14 +545,14 @@ namespace OpenSim.Framework.UserManagement } } - return user.UUID; + return user.Id; } public bool UpdateUserProfileProperties(UserProfileData UserProfile) { - if (null == GetUserProfile(UserProfile.UUID)) + if (null == GetUserProfile(UserProfile.Id)) { - m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.UUID.ToString()); + m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.Id.ToString()); return false; } foreach (KeyValuePair plugin in _plugins) @@ -563,7 +563,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.UUID.ToString() + m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.Id.ToString() + " via " + plugin.Key + "(" + e.ToString() + ")"); return false; } -- cgit v1.1 From 25fea01b92a7682e10f57ce979217d31fee975ef Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:09:30 +0000 Subject: further renaming of properties for clarity --- .../Framework/Communications/Cache/CachedUserInfo.cs | 10 +++++----- .../Framework/Communications/CommunicationsManager.cs | 6 +++--- OpenSim/Framework/Communications/LoginService.cs | 10 +++++----- OpenSim/Framework/Communications/UserManagerBase.cs | 18 +++++++++--------- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 75fe1aa..6e07e7c 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -114,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.name, folderInfo.folderID, userID); - if (userID == UserProfile.Id) + if (userID == UserProfile.ID) { if (RootFolder == null) { @@ -169,7 +169,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.Id) && (RootFolder != null)) + if ((userID == UserProfile.ID) && (RootFolder != null)) { if (itemInfo.Folder == RootFolder.ID) { @@ -194,7 +194,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.Id) && (RootFolder != null)) + if ((userID == UserProfile.ID) && (RootFolder != null)) { ItemReceive(userID, itemInfo); m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.Id) && (RootFolder != null)) + if ((userID == UserProfile.ID) && (RootFolder != null)) { m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } @@ -212,7 +212,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.Id) && (RootFolder != null)) + if ((userID == UserProfile.ID) && (RootFolder != null)) { result = RootFolder.DeleteItem(item.ID); if (result) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6b01d8f..192c8e3 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -164,9 +164,9 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.Id); + m_inventoryService.CreateNewUserInventory(userProf.ID); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); - return userProf.Id; + return userProf.ID; } } @@ -249,7 +249,7 @@ namespace OpenSim.Framework.Communications UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) { - LLUUID profileId = profileData.Id; + LLUUID profileId = profileData.ID; string firstname = profileData.FirstName; string lastname = profileData.SurName; diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e5ad7a0..4f314bc 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -207,7 +207,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.Id; + LLUUID agentID = userProfile.ID; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -349,7 +349,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.Id; + LLUUID agentID = userProfile.ID; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -491,7 +491,7 @@ namespace OpenSim.Framework.UserManagement if (goodweblogin) { LLUUID webloginkey = LLUUID.Random(); - m_userManager.StoreWebLoginKey(user.Id, webloginkey); + m_userManager.StoreWebLoginKey(user.ID, webloginkey); statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + @@ -639,7 +639,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); // Web Login method seems to also occasionally send the hashed password itself @@ -664,7 +664,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); // Match web login key unless it's the default weblogin key LLUUID.Zero passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != LLUUID.Zero); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 02be6bd..91c284c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.UserManagement if (profile != null) { - profile.CurrentAgent = getUserAgent(profile.Id); + profile.CurrentAgent = getUserAgent(profile.ID); return profile; } } @@ -113,7 +113,7 @@ namespace OpenSim.Framework.UserManagement if (null != profile) { - profile.CurrentAgent = getUserAgent(profile.Id); + profile.CurrentAgent = getUserAgent(profile.ID); return profile; } } @@ -355,7 +355,7 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.Id; + agent.UUID = profile.ID; // Current position (from Home) agent.currentHandle = profile.HomeRegion; @@ -481,7 +481,7 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.Id; + agent.UUID = profile.ID; // Current position (from Home) agent.currentHandle = profile.HomeRegion; @@ -523,7 +523,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData user = new UserProfileData(); user.HomeLocation = new LLVector3(128, 128, 100); - user.Id = LLUUID.Random(); + user.ID = LLUUID.Random(); user.FirstName = firstName; user.SurName = lastName; user.PasswordHash = pass; @@ -545,14 +545,14 @@ namespace OpenSim.Framework.UserManagement } } - return user.Id; + return user.ID; } public bool UpdateUserProfileProperties(UserProfileData UserProfile) { - if (null == GetUserProfile(UserProfile.Id)) + if (null == GetUserProfile(UserProfile.ID)) { - m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.Id.ToString()); + m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString()); return false; } foreach (KeyValuePair plugin in _plugins) @@ -563,7 +563,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.Id.ToString() + m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() + " via " + plugin.Key + "(" + e.ToString() + ")"); return false; } -- cgit v1.1 From ef7dfae41c728d10cfe835cb256958c354449f1b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:37:17 +0000 Subject: changing UserAgentData to use properties. This caused more grief than expected, as monodevelop doesn't like to refactor properties of properties. --- OpenSim/Framework/Communications/LoginService.cs | 14 ++--- .../Framework/Communications/UserManagerBase.cs | 62 +++++++++++----------- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 4f314bc..afe7359 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -184,13 +184,13 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) { //TODO: The following statements can cause trouble: // If agentOnline could not turn from true back to false normally // because of some problem, for instance, the crashment of server or client, // the user cannot log in any longer. - userProfile.CurrentAgent.agentOnline = false; + userProfile.CurrentAgent.AgentOnline = false; m_userManager.CommitAgent(ref userProfile); // Reject the login @@ -225,8 +225,8 @@ namespace OpenSim.Framework.UserManagement logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -334,7 +334,7 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) { userProfile.CurrentAgent = null; m_userManager.CommitAgent(ref userProfile); @@ -367,8 +367,8 @@ namespace OpenSim.Framework.UserManagement logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 91c284c..0473701 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -342,7 +342,7 @@ namespace OpenSim.Framework.UserManagement UserAgentData agent = new UserAgentData(); // User connection - agent.agentOnline = true; + agent.AgentOnline = true; // Generate sessions RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); @@ -351,15 +351,15 @@ namespace OpenSim.Framework.UserManagement rand.GetBytes(randDataS); rand.GetBytes(randDataSS); - agent.secureSessionID = new LLUUID(randDataSS, 0); - agent.sessionID = new LLUUID(randDataS, 0); + agent.SecureSessionID = new LLUUID(randDataSS, 0); + agent.SessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.ID; + agent.ProfileID = profile.ID; // Current position (from Home) - agent.currentHandle = profile.HomeRegion; - agent.currentPos = profile.HomeLocation; + agent.CurrentHandle = profile.HomeRegion; + agent.CurrentPos = profile.HomeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) @@ -367,16 +367,16 @@ namespace OpenSim.Framework.UserManagement string startLoc = ((string)requestData["start"]).Trim(); if (("last" == startLoc) && (profile.CurrentAgent != null)) { - if ((profile.CurrentAgent.currentPos.X > 0) - && (profile.CurrentAgent.currentPos.Y > 0) - && (profile.CurrentAgent.currentPos.Z > 0) + if ((profile.CurrentAgent.CurrentPos.X > 0) + && (profile.CurrentAgent.CurrentPos.Y > 0) + && (profile.CurrentAgent.CurrentPos.Z > 0) ) { // TODO: Right now, currentRegion has not been used in GridServer for requesting region. // TODO: It is only using currentHandle. - agent.currentRegion = profile.CurrentAgent.currentRegion; - agent.currentHandle = profile.CurrentAgent.currentHandle; - agent.currentPos = profile.CurrentAgent.currentPos; + agent.CurrentRegion = profile.CurrentAgent.CurrentRegion; + agent.CurrentHandle = profile.CurrentAgent.CurrentHandle; + agent.CurrentPos = profile.CurrentAgent.CurrentPos; } } @@ -399,12 +399,12 @@ namespace OpenSim.Framework.UserManagement } // What time did the user login? - agent.loginTime = Util.UnixTimeSinceEpoch(); - agent.logoutTime = 0; + agent.LoginTime = Util.UnixTimeSinceEpoch(); + agent.LogoutTime = 0; // Current location - agent.regionID = LLUUID.Zero; // Fill in later - agent.currentRegion = LLUUID.Zero; // Fill in later + agent.RegionID = LLUUID.Zero; // Fill in later + agent.CurrentRegion = LLUUID.Zero; // Fill in later profile.CurrentAgent = agent; } @@ -437,16 +437,16 @@ namespace OpenSim.Framework.UserManagement userAgent = userProfile.CurrentAgent; if (userAgent != null) { - userAgent.agentOnline = false; - userAgent.logoutTime = Util.UnixTimeSinceEpoch(); + userAgent.AgentOnline = false; + userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); //userAgent.sessionID = LLUUID.Zero; if (regionid != LLUUID.Zero) { - userAgent.currentRegion = regionid; + userAgent.CurrentRegion = regionid; } - userAgent.currentHandle = regionhandle; - userAgent.currentPos = currentPos; + userAgent.CurrentHandle = regionhandle; + userAgent.CurrentPos = currentPos; userProfile.CurrentAgent = userAgent; CommitAgent(ref userProfile); @@ -468,7 +468,7 @@ namespace OpenSim.Framework.UserManagement UserAgentData agent = new UserAgentData(); // User connection - agent.agentOnline = true; + agent.AgentOnline = true; // Generate sessions RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); @@ -477,23 +477,23 @@ namespace OpenSim.Framework.UserManagement rand.GetBytes(randDataS); rand.GetBytes(randDataSS); - agent.secureSessionID = new LLUUID(randDataSS, 0); - agent.sessionID = new LLUUID(randDataS, 0); + agent.SecureSessionID = new LLUUID(randDataSS, 0); + agent.SessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.ID; + agent.ProfileID = profile.ID; // Current position (from Home) - agent.currentHandle = profile.HomeRegion; - agent.currentPos = profile.HomeLocation; + agent.CurrentHandle = profile.HomeRegion; + agent.CurrentPos = profile.HomeLocation; // What time did the user login? - agent.loginTime = Util.UnixTimeSinceEpoch(); - agent.logoutTime = 0; + agent.LoginTime = Util.UnixTimeSinceEpoch(); + agent.LogoutTime = 0; // Current location - agent.regionID = LLUUID.Zero; // Fill in later - agent.currentRegion = LLUUID.Zero; // Fill in later + agent.RegionID = LLUUID.Zero; // Fill in later + agent.CurrentRegion = LLUUID.Zero; // Fill in later profile.CurrentAgent = agent; } -- cgit v1.1 From 55ac1c6dce15d768cc7240b75f903076a131c39e Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 14:50:52 +0000 Subject: renaming of attributes in UserAgentData for readability --- .../Framework/Communications/UserManagerBase.cs | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0473701..c86992a 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -358,8 +358,8 @@ namespace OpenSim.Framework.UserManagement agent.ProfileID = profile.ID; // Current position (from Home) - agent.CurrentHandle = profile.HomeRegion; - agent.CurrentPos = profile.HomeLocation; + agent.Handle = profile.HomeRegion; + agent.Position = profile.HomeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) @@ -367,16 +367,16 @@ namespace OpenSim.Framework.UserManagement string startLoc = ((string)requestData["start"]).Trim(); if (("last" == startLoc) && (profile.CurrentAgent != null)) { - if ((profile.CurrentAgent.CurrentPos.X > 0) - && (profile.CurrentAgent.CurrentPos.Y > 0) - && (profile.CurrentAgent.CurrentPos.Z > 0) + if ((profile.CurrentAgent.Position.X > 0) + && (profile.CurrentAgent.Position.Y > 0) + && (profile.CurrentAgent.Position.Z > 0) ) { // TODO: Right now, currentRegion has not been used in GridServer for requesting region. // TODO: It is only using currentHandle. - agent.CurrentRegion = profile.CurrentAgent.CurrentRegion; - agent.CurrentHandle = profile.CurrentAgent.CurrentHandle; - agent.CurrentPos = profile.CurrentAgent.CurrentPos; + agent.Region = profile.CurrentAgent.Region; + agent.Handle = profile.CurrentAgent.Handle; + agent.Position = profile.CurrentAgent.Position; } } @@ -403,8 +403,8 @@ namespace OpenSim.Framework.UserManagement agent.LogoutTime = 0; // Current location - agent.RegionID = LLUUID.Zero; // Fill in later - agent.CurrentRegion = LLUUID.Zero; // Fill in later + agent.InitialRegion = LLUUID.Zero; // Fill in later + agent.Region = LLUUID.Zero; // Fill in later profile.CurrentAgent = agent; } @@ -442,11 +442,11 @@ namespace OpenSim.Framework.UserManagement //userAgent.sessionID = LLUUID.Zero; if (regionid != LLUUID.Zero) { - userAgent.CurrentRegion = regionid; + userAgent.Region = regionid; } - userAgent.CurrentHandle = regionhandle; - userAgent.CurrentPos = currentPos; + userAgent.Handle = regionhandle; + userAgent.Position = currentPos; userProfile.CurrentAgent = userAgent; CommitAgent(ref userProfile); @@ -484,16 +484,16 @@ namespace OpenSim.Framework.UserManagement agent.ProfileID = profile.ID; // Current position (from Home) - agent.CurrentHandle = profile.HomeRegion; - agent.CurrentPos = profile.HomeLocation; + agent.Handle = profile.HomeRegion; + agent.Position = profile.HomeLocation; // What time did the user login? agent.LoginTime = Util.UnixTimeSinceEpoch(); agent.LogoutTime = 0; // Current location - agent.RegionID = LLUUID.Zero; // Fill in later - agent.CurrentRegion = LLUUID.Zero; // Fill in later + agent.InitialRegion = LLUUID.Zero; // Fill in later + agent.Region = LLUUID.Zero; // Fill in later profile.CurrentAgent = agent; } -- cgit v1.1 From ded704ef1f3e78c3915278b145f7eef33d5b17d2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 10 Apr 2008 15:22:01 +0000 Subject: * Minor inventory message cleanup and documentation --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 97d963d..0d19932 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -141,9 +141,10 @@ namespace OpenSim.Framework.Communications if (null != existingRootFolder) { - m_log.ErrorFormat("[AGENT INVENTORY]: " + - "Did not create a new inventory for user {0} since they already have " - + "a root inventory folder with id {1}", user, existingRootFolder); + m_log.ErrorFormat( + "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " + + "a root inventory folder with id {1}", + user, existingRootFolder.ID); } else { -- cgit v1.1 From ba132f3a0bbbc2f749bec9c563e169d22c76f74b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 10 Apr 2008 15:28:52 +0000 Subject: * Minor: get CreateNewUserInventory() to return true on success --- OpenSim/Framework/Communications/IInventoryServices.cs | 5 +++-- OpenSim/Framework/Communications/InventoryServiceBase.cs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index eaa2350..966ab75 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -66,10 +66,11 @@ namespace OpenSim.Framework.Communications void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); /// - /// Create a new inventory for the given user + /// Create a new inventory for the given user. /// /// - void CreateNewUserInventory(LLUUID user); + /// true if the inventory was successfully created, false otherwise + bool CreateNewUserInventory(LLUUID user); bool HasInventoryForUser(LLUUID userID); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 0d19932..f9a47b1 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -135,7 +135,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public void CreateNewUserInventory(LLUUID user) + public bool CreateNewUserInventory(LLUUID user) { InventoryFolderBase existingRootFolder = RequestRootFolder(user); @@ -151,7 +151,11 @@ namespace OpenSim.Framework.Communications UsersInventory inven = new UsersInventory(); inven.CreateNewInventorySet(user); AddNewInventorySet(inven); + + return true; } + + return false; } public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, -- cgit v1.1 From 4bdb4a2646bc0894f15f2952912ee47c3922d909 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 10 Apr 2008 15:32:09 +0000 Subject: Thank you kindly, A_Biondi for a patch that: Handles the CreateItem cap request for all wearables, setting the proper value in inType and assType. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 36bebe8..d859227 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -567,6 +567,19 @@ namespace OpenSim.Region.Capabilities inType = 19; assType = 20; } + else if (inventoryType == "wearable") + { + inType = 18; + switch (assetType) + { + case "bodypart": + assType = 13; + break; + case "clothing": + assType = 5; + break; + } + } AssetBase asset; asset = new AssetBase(); -- cgit v1.1 From 5ad4c79a4e5e2d6c9ba26034e5b325007f0b6f7a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 10 Apr 2008 16:04:19 +0000 Subject: * Refactor GetUsersInventory() --- OpenSim/Framework/Communications/IInventoryServices.cs | 4 ++-- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 966ab75..ecc6c71 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -85,8 +85,8 @@ namespace OpenSim.Framework.Communications /// Returns a list of all the folders in a given user's inventory. /// /// - /// A flat list of the user's inventory folder tree. - /// Null if there is no inventory for this user + /// A flat list of the user's inventory folder tree, + /// null if there is no inventory for this user List GetInventorySkeleton(LLUUID userId); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index f9a47b1..e50e19e 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -141,7 +141,7 @@ namespace OpenSim.Framework.Communications if (null != existingRootFolder) { - m_log.ErrorFormat( + m_log.WarnFormat( "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " + "a root inventory folder with id {1}", user, existingRootFolder.ID); -- cgit v1.1 From b41abbd50e82103865c8c9540a4154fc689e37a9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 10 Apr 2008 17:44:19 +0000 Subject: * Minor: really just comment and subsequent indentation adjustment. Preparation for handling inventory problems where the inventory server receives a request and never responds, or is late in responding --- .../Cache/UserProfileCacheService.cs | 96 +++++++++++++--------- 1 file changed, 55 insertions(+), 41 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 2dc2374..d94ff6c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -293,64 +293,73 @@ namespace OpenSim.Framework.Communications.Cache folderID, remoteClient.Name); } + /// + /// Handle the caps inventory descendents fetch. + /// + /// Since the folder structure is sent to the client on login, I believe we only need to handle items. + /// + /// + /// + /// + /// + /// + /// + /// public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // XXX We're not handling sortOrder yet! - // with CAPS we are only return items in the folders at the moment - // need to find the format that sub folder details are sent in - // if (fetchItems) - // { - InventoryFolderImpl fold = null; - if (folderID == libraryRoot.ID) - { - return libraryRoot.RequestListOfItems(); - } - if ((fold = libraryRoot.HasSubFolder(folderID)) != null) - { - return fold.RequestListOfItems(); - } + InventoryFolderImpl fold = null; + if (folderID == libraryRoot.ID) + { + return libraryRoot.RequestListOfItems(); + } - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(agentID, out userProfile)) + if ((fold = libraryRoot.HasSubFolder(folderID)) != null) + { + return fold.RequestListOfItems(); + } + + CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(agentID, out userProfile)) + { + if (userProfile.RootFolder != null) { - if (userProfile.RootFolder != null) + if (userProfile.RootFolder.ID == folderID) { - if (userProfile.RootFolder.ID == folderID) - { - return userProfile.RootFolder.RequestListOfItems(); - } - else - { - if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) - { - return fold.RequestListOfItems(); - } - } + return userProfile.RootFolder.RequestListOfItems(); } else { - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID.ToString()); - - return new List(); ; + if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) + { + return fold.RequestListOfItems(); + } } } else { - m_log.ErrorFormat( - "[USER CACHE]: HandleFetchInventoryDescendentsCAPS() Could not find user profile for {0}", - agentID); - - return new List(); + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID.ToString()); + + return new List(); ; } + } + else + { + m_log.ErrorFormat( + "[USER CACHE]: HandleFetchInventoryDescendentsCAPS() Could not find user profile for {0}", + agentID); + + return new List(); + } + + // If we've reached this point then we couldn't find the folder, even though the client thinks + // it exists + m_log.ErrorFormat("[INVENTORY CACHE]: " + + "Could not find folder {0} for user {1}", + folderID, agentID.ToString()); - // If we've reached this point then we couldn't find the folder, even though the client thinks - // it exists - m_log.ErrorFormat("[INVENTORY CACHE]: " + - "Could not find folder {0} for user {1}", - folderID, agentID.ToString()); - // } return new List(); } @@ -400,6 +409,11 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Request the inventory data for the given user. + /// + /// + /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); -- cgit v1.1 From 9a7717743b7f7627bc80a69bb416838839062e72 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 16:13:33 +0000 Subject: refactor: eliminate method in UserProfileCacheService --- .../Cache/UserProfileCacheService.cs | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index d94ff6c..873070a 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -77,16 +77,25 @@ namespace OpenSim.Framework.Communications.Cache } } } - } + } - public void UpdateUserInventory(LLUUID userID) + /// + /// Request the inventory data for the given user. This will occur asynchronous if running on a grid + /// + /// + /// + public void RequestInventoryForUser(LLUUID userID) { CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) + { + m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + } + else { - RequestInventoryForUser(userID, userInfo); + m_log.ErrorFormat("[USER CACHE]: RequestInventoryForUser() - user profile for user {0} not found", userID); } - } + } public CachedUserInfo GetUserDetails(LLUUID userID) { @@ -408,15 +417,5 @@ namespace OpenSim.Framework.Communications.Cache } } } - - /// - /// Request the inventory data for the given user. - /// - /// - /// - private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) - { - m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); - } } } -- cgit v1.1 From 576db5b72a2fcd08598a435054f8455966b263fd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 16:30:58 +0000 Subject: * documenting and minor refactoring in UserProfileCacheService --- .../Cache/UserProfileCacheService.cs | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 873070a..7178d2c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -39,21 +39,26 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - // Fields - private readonly CommunicationsManager m_parent; + /// + /// The comms manager holds the reference to this service + /// + private readonly CommunicationsManager m_commsManager; + + /// + /// Each user has a cached profile. + /// private readonly Dictionary m_userProfiles = new Dictionary(); - public LibraryRootFolder libraryRoot = new LibraryRootFolder(); + public readonly LibraryRootFolder libraryRoot = new LibraryRootFolder(); // Methods - public UserProfileCacheService(CommunicationsManager parent) + public UserProfileCacheService(CommunicationsManager commsManager) { - m_parent = parent; + m_commsManager = commsManager; } /// - /// A new user has moved into a region in this instance - /// so get info from servers + /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// /// public void AddNewUser(LLUUID userID) @@ -63,8 +68,8 @@ namespace OpenSim.Framework.Communications.Cache { if (!m_userProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(m_parent); - userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager); + userInfo.UserProfile = m_commsManager.UserService.GetUserProfile(userID); if (userInfo.UserProfile != null) { @@ -73,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found", userID); + m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", userID); } } } @@ -89,7 +94,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } else { @@ -97,6 +102,11 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Get the details of the given user. + /// + /// + /// null if no user details are found public CachedUserInfo GetUserDetails(LLUUID userID) { if (m_userProfiles.ContainsKey(userID)) @@ -128,7 +138,7 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.ParentID = createdFolder.ParentID; createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } } else @@ -171,7 +181,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; baseFolder.Type = (short) type; baseFolder.Version = userProfile.RootFolder.Version; - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } } } @@ -188,7 +198,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Owner = remoteClient.AgentId; baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); + m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } } } -- cgit v1.1 From 205b95f2e8b1f94379068c01c46777d7188fc2e5 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 16:49:20 +0000 Subject: * minor documenting, cleanup, renaming in user profile cache service --- .../Communications/Cache/CachedUserInfo.cs | 28 ++++++++++++++++------ .../Cache/UserProfileCacheService.cs | 13 ++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6e07e7c..9ece581 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -32,16 +32,24 @@ using libsecondlife; namespace OpenSim.Framework.Communications.Cache { + /// + /// Stores user profile and inventory data received from backend services for a particular user. + /// public class CachedUserInfo { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private readonly CommunicationsManager m_parentCommsManager; + /// + /// The comms manager holds references to services (user, grid, inventory, etc.) + /// + private readonly CommunicationsManager m_commsManager; + private UserProfileData m_userProfile; + public UserProfileData UserProfile { get { return m_userProfile; } } + // FIXME: These need to be hidden behind accessors public InventoryFolderImpl RootFolder = null; - public UserProfileData UserProfile = null; /// /// Stores received folders for which we have not yet received the parents. @@ -49,9 +57,15 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); - public CachedUserInfo(CommunicationsManager commsManager) + /// + /// Constructor + /// + /// + /// + public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile) { - m_parentCommsManager = commsManager; + m_commsManager = commsManager; + m_userProfile = userProfile; } /// @@ -197,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache if ((userID == UserProfile.ID) && (RootFolder != null)) { ItemReceive(userID, itemInfo); - m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } @@ -205,7 +219,7 @@ namespace OpenSim.Framework.Communications.Cache { if ((userID == UserProfile.ID) && (RootFolder != null)) { - m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } @@ -217,7 +231,7 @@ namespace OpenSim.Framework.Communications.Cache result = RootFolder.DeleteItem(item.ID); if (result) { - m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); + m_commsManager.InventoryService.DeleteInventoryItem(userID, item); } } return result; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 7178d2c..586c24e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -35,12 +35,15 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { + /// + /// Holds user profile information and retrieves it from backend services. + /// public class UserProfileCacheService { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// - /// The comms manager holds the reference to this service + /// The comms manager holds references to services (user, grid, inventory, etc.) /// private readonly CommunicationsManager m_commsManager; @@ -68,12 +71,12 @@ namespace OpenSim.Framework.Communications.Cache { if (!m_userProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager); - userInfo.UserProfile = m_commsManager.UserService.GetUserProfile(userID); + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile); if (userInfo.UserProfile != null) { - // The inventory will be populated when the user actually enters the scene + // The inventory for the user will be populated when they actually enter the scene m_userProfiles.Add(userID, userInfo); } else @@ -85,7 +88,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Request the inventory data for the given user. This will occur asynchronous if running on a grid + /// Request the inventory data for the given user. This will occur asynchronously if running on a grid /// /// /// -- cgit v1.1 From e26d4fc08556252c09e46bfa6aa2b59119f702dc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 17:02:20 +0000 Subject: * minor: replace test of CachedUserInfo.RootFolder != null with something more readable, and make RootFolder get only --- .../Framework/Communications/Cache/CachedUserInfo.cs | 16 +++++++++++----- .../Communications/Cache/UserProfileCacheService.cs | 18 +++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9ece581..1208605 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -49,7 +49,8 @@ namespace OpenSim.Framework.Communications.Cache public UserProfileData UserProfile { get { return m_userProfile; } } // FIXME: These need to be hidden behind accessors - public InventoryFolderImpl RootFolder = null; + private InventoryFolderImpl m_rootFolder; + public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } /// /// Stores received folders for which we have not yet received the parents. @@ -67,6 +68,11 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager = commsManager; m_userProfile = userProfile; } + + /// + /// Has this user info object yet received its inventory information from the invetnroy service? + /// + public bool HasInventory { get { return RootFolder != null; } } /// /// Store a folder pending categorization when its parent is received. @@ -134,7 +140,7 @@ namespace OpenSim.Framework.Communications.Cache { if (folderInfo.ParentID == LLUUID.Zero) { - RootFolder = folderInfo; + m_rootFolder = folderInfo; } } else if (RootFolder.ID == folderInfo.ParentID) @@ -208,7 +214,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { ItemReceive(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); @@ -217,7 +223,7 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } @@ -226,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { result = RootFolder.DeleteItem(item.ID); if (result) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 586c24e..b924d5c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == parentID) { @@ -175,7 +175,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = remoteClient.AgentId; @@ -195,7 +195,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = remoteClient.AgentId; @@ -248,21 +248,21 @@ namespace OpenSim.Framework.Communications.Cache // inventory failure. // // This is a crude way of dealing with that by retrying the lookup. - if (userProfile.RootFolder == null) + if (!userProfile.HasInventory) { int attempts = 5; while (attempts-- > 0) { Thread.Sleep(3000); - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { break; } } } - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == folderID) { @@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(agentID, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == folderID) { @@ -393,7 +393,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); if (subFolder != null) @@ -420,7 +420,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); if (item != null) -- cgit v1.1 From a5176c2e2c4d2791ec15a22db4309bb15bc3ae98 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 18:13:10 +0000 Subject: * Change inventory async response deliver to deliver all items and folders at once, rather than each individual * This is required in order to work towards eliminating some inventory race conditions and to better deal with situations where a grid inventory server is slow or not responding. --- .../Communications/Cache/CachedUserInfo.cs | 109 ++++++++++++++------- .../Cache/UserProfileCacheService.cs | 16 ++- .../Framework/Communications/IInventoryServices.cs | 19 +++- .../Communications/InventoryServiceBase.cs | 5 +- 4 files changed, 106 insertions(+), 43 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 1208605..cf701cb 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -118,64 +118,82 @@ namespace OpenSim.Framework.Communications.Cache } } } - + /// - /// Callback invoked when a folder is received from an async request to the inventory service. + /// Callback invoked when the inventory is received from an async request to the inventory service /// /// - /// - public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) + /// + public void InventoryReceive(LLUUID userID, ICollection folders, ICollection items) { // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed try + { + foreach (InventoryFolderImpl folder in folders) + { + FolderReceive(userID, folder); + } + + foreach (InventoryItemBase item in items) + { + ItemReceive(userID, item); + } + } + catch (Exception e) { + m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e); + } + } + + /// + /// Callback invoked when a folder is received from an async request to the inventory service. + /// + /// + /// + private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) + { // m_log.DebugFormat( // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.name, folderInfo.folderID, userID); - - if (userID == UserProfile.ID) + + if (userID == UserProfile.ID) + { + if (RootFolder == null) { - if (RootFolder == null) + if (folderInfo.ParentID == LLUUID.Zero) { - if (folderInfo.ParentID == LLUUID.Zero) - { - m_rootFolder = folderInfo; - } + m_rootFolder = folderInfo; } - else if (RootFolder.ID == folderInfo.ParentID) + } + else if (RootFolder.ID == folderInfo.ParentID) + { + if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) - { - RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); - } - else - { - AddPendingFolder(folderInfo); - } + RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); } else { - InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); - if (folder != null) - { - if (!folder.SubFolders.ContainsKey(folderInfo.ID)) - { - folder.SubFolders.Add(folderInfo.ID, folderInfo); - } - } - else + AddPendingFolder(folderInfo); + } + } + else + { + InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); + if (folder != null) + { + if (!folder.SubFolders.ContainsKey(folderInfo.ID)) { - AddPendingFolder(folderInfo); + folder.SubFolders.Add(folderInfo.ID, folderInfo); } } - - ResolvePendingFolders(folderInfo); + else + { + AddPendingFolder(folderInfo); + } } - } - catch (Exception e) - { - m_log.ErrorFormat("[INVENTORY CACHE] {0}", e); + + ResolvePendingFolders(folderInfo); } } @@ -187,7 +205,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) + private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { if ((userID == UserProfile.ID) && (RootFolder != null)) { @@ -212,6 +230,11 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Add an item to the user's inventory + /// + /// + /// public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { if ((userID == UserProfile.ID) && HasInventory) @@ -221,6 +244,11 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Update an item in the user's inventory + /// + /// + /// public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { if ((userID == UserProfile.ID) && HasInventory) @@ -229,6 +257,12 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Delete an item from the user's inventory + /// + /// + /// + /// public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; @@ -240,6 +274,7 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager.InventoryService.DeleteInventoryItem(userID, item); } } + return result; } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b924d5c..6b09e01 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); } else { @@ -118,6 +118,14 @@ namespace OpenSim.Framework.Communications.Cache return null; } + /// + /// Handle an inventory folder creation request from the client. + /// + /// + /// + /// + /// + /// public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) { @@ -189,6 +197,12 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Handle an inventory folder move request from the client. + /// + /// + /// + /// public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) { CachedUserInfo userProfile; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index ecc6c71..40e7ffd 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -26,21 +26,34 @@ */ using System.Collections.Generic; + using libsecondlife; + using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications { - public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); + /// + /// Callback used when a user's inventory is received from the inventory service + /// + public delegate void InventoryReceiptCallback(LLUUID userId, ICollection folders, ICollection items); + + //public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); - public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); + //public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); /// /// Defines all the operations one can perform on a user's inventory. /// public interface IInventoryServices { - void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + /// + /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the + /// inventory has been received + /// + /// + /// + void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); /// /// Add a new folder to the given user's inventory diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index e50e19e..aedf4b3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -158,8 +158,9 @@ namespace OpenSim.Framework.Communications return false; } - public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, - InventoryItemInfo itemCallBack); + // See IInventoryServices + public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); -- cgit v1.1 From 649f304e764784d08f8a79729f70f66972c52c56 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 18:19:21 +0000 Subject: * Minor inventory code cleanup following on from last patch --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/IInventoryServices.cs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index cf701cb..d97cf01 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -200,7 +200,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Callback invoked when an item is received from an async request to the inventory service. /// - /// FIXME: We're assuming here that items are always received after all the folders have been + /// We're assuming here that items are always received after all the folders have been /// received. /// /// diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 40e7ffd..5e7f855 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -37,10 +37,6 @@ namespace OpenSim.Framework.Communications /// Callback used when a user's inventory is received from the inventory service /// public delegate void InventoryReceiptCallback(LLUUID userId, ICollection folders, ICollection items); - - //public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); - - //public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); /// /// Defines all the operations one can perform on a user's inventory. -- cgit v1.1 From 7ac7f79f88f51504680a24f1621115c595492f62 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 18:46:54 +0000 Subject: * Eliminate a class of errors where an inventory request could be made before the region had completely received the inventory for the user. * A much larger race condition where the inventory request could be made before the region gets any data at all will also be fixed in the near future. * This change also fixes a regression from two patches ago where items stopped appearing in standalone inventory --- .../Communications/Cache/CachedUserInfo.cs | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d97cf01..686f8d2 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -47,10 +47,18 @@ namespace OpenSim.Framework.Communications.Cache private UserProfileData m_userProfile; public UserProfileData UserProfile { get { return m_userProfile; } } + + + private bool m_hasInventory; + + /// + /// Has this user info object yet received its inventory information from the invetnroy service? + /// + public bool HasInventory { get { return m_hasInventory; } } // FIXME: These need to be hidden behind accessors private InventoryFolderImpl m_rootFolder; - public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } + public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } /// /// Stores received folders for which we have not yet received the parents. @@ -68,11 +76,6 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager = commsManager; m_userProfile = userProfile; } - - /// - /// Has this user info object yet received its inventory information from the invetnroy service? - /// - public bool HasInventory { get { return RootFolder != null; } } /// /// Store a folder pending categorization when its parent is received. @@ -142,8 +145,10 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e); - } + m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); + } + + m_hasInventory = true; } /// @@ -153,9 +158,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", -// folderInfo.name, folderInfo.folderID, userID); + m_log.DebugFormat( + "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", + folderInfo.Name, folderInfo.ID, userID); if (userID == UserProfile.ID) { @@ -207,6 +212,10 @@ namespace OpenSim.Framework.Communications.Cache /// private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { + m_log.DebugFormat( + "[INVENTORY CACHE]: Received item {0} {1} for user {2}", + itemInfo.Name, itemInfo.ID, userID); + if ((userID == UserProfile.ID) && (RootFolder != null)) { if (itemInfo.Folder == RootFolder.ID) -- cgit v1.1 From 7bfd7e6f087c6e4382a1dab19af2ed471c6f1279 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 18:58:09 +0000 Subject: * Remove the worst excesses of my inventory debugging code --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 686f8d2..ec5717e 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -158,9 +158,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { - m_log.DebugFormat( - "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", - folderInfo.Name, folderInfo.ID, userID); +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", +// folderInfo.Name, folderInfo.ID, userID); if (userID == UserProfile.ID) { @@ -212,9 +212,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - m_log.DebugFormat( - "[INVENTORY CACHE]: Received item {0} {1} for user {2}", - itemInfo.Name, itemInfo.ID, userID); +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Received item {0} {1} for user {2}", +// itemInfo.Name, itemInfo.ID, userID); if ((userID == UserProfile.ID) && (RootFolder != null)) { -- cgit v1.1 From 451a5bbf30bf0ff02c7318b7b6f9f708309165ac Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 13 Apr 2008 22:09:07 +0000 Subject: * Put in crude poll waiting for 60 seconds for delayed user inventory delivery from the inventory service * This will reduce failures where the inventory server is simply slow * Still need to properly inform the user if the inventory service has failed altogether --- .../Cache/UserProfileCacheService.cs | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 6b09e01..7995841 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -355,11 +355,36 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { return fold.RequestListOfItems(); - } + } CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(agentID, out userProfile)) - { + { + // XXX: When a client crosses into a scene, their entire inventory is fetched + // asynchronously. If the client makes a request before the inventory is received, we need + // to give the inventory a chance to come in. + // + // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad + // in CAPS as doing this with the udp request, since here it won't hold up other packets. + // In fact, here we'll be generous and try for longer. + if (!userProfile.HasInventory) + { + int attempts = 0; + while (attempts++ < 20) + { + m_log.DebugFormat( + "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", + attempts, folderID, agentID); + + Thread.Sleep(3000); + + if (userProfile.HasInventory) + { + break; + } + } + } + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == folderID) -- cgit v1.1 From eacba916ec0022b35979403d285b1a4e991ed1f7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 13 Apr 2008 23:38:51 +0000 Subject: * Reverse mantis #912 since it was causing inventory to disappear from the root folder on 1.19.1.4 non-cache clear relog. * The folder version numbers probably do need to be non-zero, but there is a further subtlety of the protocol to understand first --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d859227..050657d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -272,7 +272,16 @@ namespace OpenSim.Region.Capabilities contents.agent___id = m_agentID; contents.owner___id = invFetch.owner_id; contents.folder___id = invFetch.folder_id; - contents.version = 1; //FixMe + + // In http://opensimulator.org/mantis/view.php?id=912 we tried changing this to 1 instead. + // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins + // without clearing client cache, objects in the root folder disappear until the cache is cleared, + // at which point they reappear. + // + // Seeing the version to something other than 0 may be the right thing to do, but there is + // a greater subtlety of the second life protocol that needs to be understood first. + contents.version = 0; + contents.descendents = 0; reply.folders.Array.Add(contents); List itemList = null; -- cgit v1.1 From 665c5d89f89f408c21f2ce13d6638be4105c91a4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 13 Apr 2008 23:48:46 +0000 Subject: * Correct comment from previous patch - I'm not reversing mantis #912 at all, which was in an entirely different location --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 050657d..f164208 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -273,7 +273,7 @@ namespace OpenSim.Region.Capabilities contents.owner___id = invFetch.owner_id; contents.folder___id = invFetch.folder_id; - // In http://opensimulator.org/mantis/view.php?id=912 we tried changing this to 1 instead. + // The version number being sent back was originally 1. // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins // without clearing client cache, objects in the root folder disappear until the cache is cleared, // at which point they reappear. -- cgit v1.1 From e21886eea0a4d2782a74bb1f974b2e1056fea055 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 14 Apr 2008 17:13:38 +0000 Subject: * Fixed a few warnings. * Added license info to a few files it was missing from. * Fleshed out the landbuy interfaces * If you add '-helperuri http://127.0.0.1:9000/' to your list of parameters you tell the client to use when you start it up you can transfer ownership of parcels now in standalone. Structured gridmode requires a lot more work, see the documentation in the example money module. The example money module is not secure especially in standalone mode. --- OpenSim/Framework/Communications/XMPP/Stanza.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/Stanza.cs b/OpenSim/Framework/Communications/XMPP/Stanza.cs index 4c57114..ed6ef06 100644 --- a/OpenSim/Framework/Communications/XMPP/Stanza.cs +++ b/OpenSim/Framework/Communications/XMPP/Stanza.cs @@ -11,9 +11,9 @@ namespace OpenSim.Framework.Communications.XMPP public string localName = String.Empty; public JId to; public JId from; - string id; - string lang; - string nodeName; + public string id; + public string lang; + public string nodeName; public Stanza(XmlNode node, Object defaults, bool hasID) { -- cgit v1.1 From b7ae8701ce6881991fbacf28cdbb0d09f220f6ec Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 14 Apr 2008 18:43:23 +0000 Subject: * Working towards notifying the client if the inventory service has failed, rather than simply returning 0 items. * This is very early support which would only be triggered in a rather unlikely case (if the user server correctly received an inventory skeleton, but later on failed to return the whole inventory in a timely manner. Also, this only applies to the 1.19.1.4 client onwards * Code cleanup and support for other failure cases (failure of inventory caching on region crossing, failure to actually add a folder/item, etc, should follow. --- .../Cache/UserProfileCacheService.cs | 6 ++-- .../Framework/Communications/Capabilities/Caps.cs | 35 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 7995841..f746e8b 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -340,7 +340,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - /// + /// null if the inventory look up failed public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { @@ -403,7 +403,7 @@ namespace OpenSim.Framework.Communications.Cache { m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID.ToString()); - return new List(); ; + return null; } } else @@ -412,7 +412,7 @@ namespace OpenSim.Framework.Communications.Cache "[USER CACHE]: HandleFetchInventoryDescendentsCAPS() Could not find user profile for {0}", agentID); - return new List(); + return null; } // If we've reached this point then we couldn't find the folder, even though the client thinks diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index f164208..46f50ad 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -56,6 +56,13 @@ namespace OpenSim.Region.Capabilities public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); + + /// + /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that + /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want + /// to just pass the whole Scene into CAPS. + /// + public delegate IClientAPI GetClientDelegate(LLUUID agentID); public class Caps { @@ -99,8 +106,8 @@ namespace OpenSim.Region.Capabilities public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; - // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; + public GetClientDelegate GetClient = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) @@ -240,7 +247,7 @@ namespace OpenSim.Region.Capabilities LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); LLSDHelpers.DeserialiseLLSDMap(inventoryhash, llsdRequest); - LLSDInventoryDescendents reply = FetchInventory(llsdRequest); + LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); inventoryitemstr = inventoryitemstr.Replace("folders", ""); @@ -265,7 +272,7 @@ namespace OpenSim.Region.Capabilities return response; } - private LLSDInventoryDescendents FetchInventory(LLSDFetchInventoryDescendents invFetch) + private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) { LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); @@ -289,6 +296,7 @@ namespace OpenSim.Region.Capabilities { itemList = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order); } + if (itemList != null) { foreach (InventoryItemBase invItem in itemList) @@ -296,6 +304,27 @@ namespace OpenSim.Region.Capabilities contents.items.Array.Add(ConvertInventoryItem(invItem)); } } + else + { + IClientAPI client = GetClient(m_agentID); + + // We're going to both notify the client of inventory service failure and send back a 'no folder contents' response. + // If we don't send back the response, + // the client becomes unhappy (see Teravus' comment in FetchInventoryRequest()) + if (client != null) + { + client.SendAgentAlertMessage( + "AGIN0001E: The inventory service has either failed or is not responding. Your inventory will not function properly for the rest of this session. Please clear your cache and relog.", + true); + } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", + m_agentID); + } + } + contents.descendents = contents.items.Array.Count; return reply; } -- cgit v1.1 From 6f8ff326307ae1522e2f3163596b0bf1cdd2157f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 15 Apr 2008 14:24:15 +0000 Subject: From: Dr Scofield ansgar and i have been working on an asterisk voice module that will allow us to couple opensim with an asterisk VoIP gateway. the patch below consists of * AsteriskVoiceModule region module: alternative to the plain-vanilla VoiceModule, will make XmlRpc calls out to an asterisk-opensim frontend * asterisk-opensim.py frontend, living in share/python/asterisk, takes XmlRpc calls from the AsteriskVoiceModule * account_update: to update/create a new SIP account (on ProvisionVoiceAccountRequest) * region_update: to update/create a new "region" conference call (on ParcelVoiceInfo) * a asterisk-opensim test client, living in share/python/asterisk, to exercise astersik-opensim.py this still does not give us voice in OpenSim, but it's another step on this path... --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 46f50ad..a65a3f1 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -201,6 +201,7 @@ namespace OpenSim.Region.Capabilities { //Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); + //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); return result; } -- cgit v1.1 From 39165f3de4e4a207e4461a8d94acaff611dd9873 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 15 Apr 2008 18:10:42 +0000 Subject: * Send a meaningful response to both the user server console and the client if a login fails because the inventory service has failed. --- OpenSim/Framework/Communications/LoginResponse.cs | 13 +++++++ OpenSim/Framework/Communications/LoginService.cs | 41 ++++++++++++++++------- 2 files changed, 41 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 763274a..53ec796 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -238,6 +238,19 @@ namespace OpenSim.Framework.UserManagement "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"); } + + /// + /// Response to indicate that login failed because the agent's inventory was not available. + /// + /// + public XmlRpcResponse CreateLoginInventoryFailedResponse() + { + return GenerateFailureResponse( + "key", + "The agent inventory service is not responding. Please notify the grid operator if this is a grid sim," + + " or the sim operator if this is a standalone sim.", + "false"); + } public XmlRpcResponse CreateAlreadyLoggedInResponse() { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index afe7359..f8ac75e 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -84,6 +84,7 @@ namespace OpenSim.Framework.UserManagement /// /// /// + /// This will be thrown if there is a problem with the inventory service protected abstract InventoryData GetInventorySkeleton(LLUUID userID); /// @@ -208,9 +209,20 @@ namespace OpenSim.Framework.UserManagement try { LLUUID agentID = userProfile.ID; - - // Inventory Library Section - InventoryData inventData = GetInventorySkeleton(agentID); + InventoryData inventData = null; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (System.Net.WebException e) + { + m_log.ErrorFormat( + "[LOGIN]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", agentID, e.GetType(), e.Message); + + return logResponse.CreateLoginInventoryFailedResponse(); + } + ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -218,7 +230,20 @@ namespace OpenSim.Framework.UserManagement ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); userProfile.RootInventoryFolderID = inventData.RootFolderID; + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + // Circuit Code uint circode = (uint) (Util.RandomClass.Next()); @@ -227,17 +252,7 @@ namespace OpenSim.Framework.UserManagement logResponse.AgentID = agentID.ToString(); logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - logResponse.InventoryLibRoot = InventoryLibRoot; - - logResponse.InventoryLibraryOwner = GetLibraryOwner(); logResponse.CircuitCode = (Int32) circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten -- cgit v1.1 From 379ac9c92ac2cdaf9ad4cc1e66de243a42ae7c42 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 15 Apr 2008 22:41:34 +0000 Subject: * Make it easier to follow logins on the user server by changing and tidying up log messages --- OpenSim/Framework/Communications/LoginService.cs | 40 +++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f8ac75e..d610c51 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -121,25 +121,28 @@ namespace OpenSim.Framework.UserManagement lastname = (string) requestData["last"]; m_log.InfoFormat( - "[LOGIN]: Received login request message from user {0} {1}", + "[LOGIN BEGIN]: Received login request message from user {0} {1}", firstname, lastname); - if( requestData.Contains("version")) + string clientVersion = "Unknown"; + + if (requestData.Contains("version")) { - string clientversion = (string)requestData["version"]; - m_log.Info("[LOGIN]: Client version: " + clientversion); + clientVersion = (string)requestData["version"]; } if (requestData.Contains("start")) { startLocationRequest = (string)requestData["start"]; - m_log.Info("[LOGIN]: Client requested start location: " + (string)requestData["start"]); } + + m_log.DebugFormat( + "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - m_log.Info("[LOGIN]: Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN END]: Could not find a profile for " + firstname + " " + lastname); return logResponse.CreateLoginFailedResponse(); } @@ -159,7 +162,7 @@ namespace OpenSim.Framework.UserManagement catch (System.Exception e) { m_log.InfoFormat( - "[LOGIN]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", requestData["web_login_key"], firstname, lastname, e); return logResponse.CreateFailedResponse(); @@ -171,14 +174,14 @@ namespace OpenSim.Framework.UserManagement else { m_log.Info( - "[LOGIN]: login_to_simulator login message did not contain all the required data"); + "[LOGIN END]: login_to_simulator login message did not contain all the required data"); return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { - m_log.InfoFormat("[LOGIN]: User {0} {1} failed authentication", firstname, lastname); + m_log.InfoFormat("[LOGIN END]: User {0} {1} failed authentication", firstname, lastname); return logResponse.CreateLoginFailedResponse(); } @@ -197,7 +200,7 @@ namespace OpenSim.Framework.UserManagement // Reject the login m_log.InfoFormat( - "[LOGIN]: Notifying user {0} {1} that they are already logged in", + "[LOGIN END]: Notifying user {0} {1} that they are already logged in", firstname, lastname); return logResponse.CreateAlreadyLoggedInResponse(); @@ -218,8 +221,9 @@ namespace OpenSim.Framework.UserManagement catch (System.Net.WebException e) { m_log.ErrorFormat( - "[LOGIN]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", agentID, e.GetType(), e.Message); - + "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", + agentID, e.GetType(), e.Message); + return logResponse.CreateLoginInventoryFailedResponse(); } @@ -269,7 +273,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - m_log.Info("[LOGIN]: " + e.ToString()); + m_log.Info("[LOGIN END]: " + e.ToString()); return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } @@ -279,19 +283,19 @@ namespace OpenSim.Framework.UserManagement if (StatsManager.UserStats != null) StatsManager.UserStats.AddSuccessfulLogin(); - m_log.InfoFormat( - "[LOGIN]: Authentication of user {0} {1} successful. Sending response to client.", + m_log.DebugFormat( + "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", firstname, lastname); return logResponse.ToXmlRpcResponse(); } catch (Exception e) { - m_log.Info("[LOGIN]: Login failed, " + e.ToString()); + m_log.Info("[LOGIN END]: Login failed, " + e.ToString()); } } - m_log.Info("[LOGIN]: Login failed. Sending back blank XMLRPC response"); + m_log.Info("[LOGIN END]: Login failed. Sending back blank XMLRPC response"); return response; } finally @@ -654,7 +658,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); + //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); // Web Login method seems to also occasionally send the hashed password itself -- cgit v1.1 From e777f88028322c9a7042ba20669b00fd9fbd573c Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 15 Apr 2008 23:10:12 +0000 Subject: * A tweak of the caps system so that new caps have random paths instead of a fixed path * This allows caps requests to be routed to regions where the agent is currently a root agent instead of the region that they logged into as it did previously. * This fixes a wide variety of bugs related to 'can't do X once i've crossed a border'. * The first seed cap request fails, the second one works. (this generates an error message on the console) * Experimental. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ec5717e..9f202ff 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -251,6 +251,11 @@ namespace OpenSim.Framework.Communications.Cache ItemReceive(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } + else + { + m_log.Error("[UNABLE TO UPLOAD]: "); + } + } /// @@ -264,6 +269,10 @@ namespace OpenSim.Framework.Communications.Cache { m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } + else + { + m_log.Error("[UNABLE TO UPDATE]: "); + } } /// @@ -283,6 +292,10 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager.InventoryService.DeleteInventoryItem(userID, item); } } + else + { + m_log.Error("[UNABLE TO DELETE]: "); + } return result; } -- cgit v1.1 From fe3265f4913d4d40be6e4bd2473cbcb3c6f01feb Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 17 Apr 2008 12:16:19 +0000 Subject: Update svn properties. Add copyright info to some source files. --- OpenSim/Framework/Communications/XMPP/Stanza.cs | 28 +++++++++++++++++++++- .../Framework/Communications/XMPP/XMPPParser.cs | 28 +++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/Stanza.cs b/OpenSim/Framework/Communications/XMPP/Stanza.cs index ed6ef06..5675a47 100644 --- a/OpenSim/Framework/Communications/XMPP/Stanza.cs +++ b/OpenSim/Framework/Communications/XMPP/Stanza.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections.Generic; using System.Text; @@ -7,7 +34,6 @@ namespace OpenSim.Framework.Communications.XMPP { public class Stanza { - public string localName = String.Empty; public JId to; public JId from; diff --git a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs index 0539afb..e41df26 100644 --- a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs +++ b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs @@ -1,10 +1,36 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections.Generic; using System.Text; using System.Xml; using OpenSim.Framework; - namespace OpenSim.Framework.Communications.XMPP { public class XMPPParser -- cgit v1.1 From dd4deebbcbe07cccf8ce700c29c9884f1f414c85 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 17 Apr 2008 19:42:54 +0000 Subject: * Re-Fixed caps * This fixes chi11ken's/OpenViewer's libsl cap issue. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 13 ------------- OpenSim/Framework/Communications/Capabilities/Caps.cs | 9 ++++++++- .../Framework/Communications/Capabilities/CapsHandlers.cs | 2 ++ 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9f202ff..ec5717e 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -251,11 +251,6 @@ namespace OpenSim.Framework.Communications.Cache ItemReceive(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } - else - { - m_log.Error("[UNABLE TO UPLOAD]: "); - } - } /// @@ -269,10 +264,6 @@ namespace OpenSim.Framework.Communications.Cache { m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } - else - { - m_log.Error("[UNABLE TO UPDATE]: "); - } } /// @@ -292,10 +283,6 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager.InventoryService.DeleteInventoryItem(userID, item); } } - else - { - m_log.Error("[UNABLE TO DELETE]: "); - } return result; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a65a3f1..2eff9c2 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -100,6 +100,7 @@ namespace OpenSim.Region.Capabilities private int m_eventQueueCount = 1; private Queue m_capsEventQueue = new Queue(); private bool m_dumpAssetsToFile; + private string m_regionName; // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls @@ -110,7 +111,7 @@ namespace OpenSim.Region.Capabilities public GetClientDelegate GetClient = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, - LLUUID agent, bool dumpAssetsToFile) + LLUUID agent, bool dumpAssetsToFile, string regionName) { m_assetCache = assetCache; m_capsObjectPath = capsPath; @@ -120,6 +121,7 @@ namespace OpenSim.Region.Capabilities m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort); + m_regionName = regionName; } /// @@ -199,6 +201,7 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { + m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); //Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); @@ -225,6 +228,7 @@ namespace OpenSim.Region.Capabilities string unmodifiedRequest = request.ToString(); //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); + m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); Hashtable hash = new Hashtable(); try @@ -366,6 +370,7 @@ namespace OpenSim.Region.Capabilities /// public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) { + m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); return mapResponse; @@ -472,6 +477,7 @@ namespace OpenSim.Region.Capabilities { try { + m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName); //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); @@ -523,6 +529,7 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { + m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index 3518e20..6992bd1 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -68,6 +68,8 @@ namespace OpenSim.Region.Capabilities /// handler to be removed public void Remove(string capsName) { + // This line must be here, or caps will break! + m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); m_capsHandlers.Remove(capsName); } -- cgit v1.1 From d3cd2b0ae498b67718af05bd1b6186c68ad4234f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 20 Apr 2008 18:19:34 +0000 Subject: * On grid mode, if the inventory service is responding but returning an empty response to a whole agent inventory request, then post an inventory login failure message. IMO, this is better than allowing the agent to login with an apparantly blank inventory. --- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d610c51..ce8aa23 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -84,7 +84,7 @@ namespace OpenSim.Framework.UserManagement /// /// /// - /// This will be thrown if there is a problem with the inventory service + /// This will be thrown if there is a problem with the inventory service protected abstract InventoryData GetInventorySkeleton(LLUUID userID); /// @@ -218,7 +218,7 @@ namespace OpenSim.Framework.UserManagement { inventData = GetInventorySkeleton(agentID); } - catch (System.Net.WebException e) + catch (Exception e) { m_log.ErrorFormat( "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", -- cgit v1.1 From e755727a0ff4af37f5cbd074800a15144707b4a7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 20 Apr 2008 18:45:03 +0000 Subject: * Change lazy user inventory creation on first login to synchronous rather than async. * Add more error checking so that we don't proceed if there has been a problem with inventory retrieval --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index aedf4b3..d4e7539 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Communications InventoryFolderBase rootFolder = RequestRootFolder(userId); - // Agent is completely new and has no inventory structure yet. + // Agent has no inventory structure yet. if (null == rootFolder) { return null; -- cgit v1.1 From 8b177bf4a832d25b2b1324a1d2a5e6d3681c8030 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 20 Apr 2008 19:39:24 +0000 Subject: * Tweak inventory login failure message to point to the region owner as first point of call rather than the grid owner --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 3 ++- OpenSim/Framework/Communications/LoginResponse.cs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f746e8b..a9e2780 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -40,7 +40,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class UserProfileCacheService { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// The comms manager holds references to services (user, grid, inventory, etc.) diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 53ec796..9636d16 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -247,8 +247,7 @@ namespace OpenSim.Framework.UserManagement { return GenerateFailureResponse( "key", - "The agent inventory service is not responding. Please notify the grid operator if this is a grid sim," - + " or the sim operator if this is a standalone sim.", + "The agent inventory service is not responding. Please notify your region operator.", "false"); } -- cgit v1.1 From 3d3eec436a42ced82b51ac11d03c2d98cc3d729a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 20 Apr 2008 20:36:06 +0000 Subject: * Remove user profile from cache when they log out from a region. * A much more significant fix is required to clean up the cache when a user moves out of a region, but really better handling of delayed inventory cache updates needs to be written first, and possibly better affinity to cut down agent inventory requests when the move is between two regions hosted on the same server. --- .../Cache/UserProfileCacheService.cs | 25 +++++++++++++++++++++- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index a9e2780..9813756 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -86,7 +86,30 @@ namespace OpenSim.Framework.Communications.Cache } } } - } + } + + /// + /// Remove this user's profile cache. + /// + /// + /// true if the user was successfully removed, false otherwise + public bool RemoveUser(LLUUID userID) + { + lock (m_userProfiles) + { + if (m_userProfiles.ContainsKey(userID)) + { + m_userProfiles.Remove(userID); + return true; + } + else + { + m_log.WarnFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userID); + } + } + + return false; + } /// /// Request the inventory data for the given user. This will occur asynchronously if running on a grid diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 9636d16..1b88d10 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -247,7 +247,7 @@ namespace OpenSim.Framework.UserManagement { return GenerateFailureResponse( "key", - "The agent inventory service is not responding. Please notify your region operator.", + "The agent inventory service is not responding. Please notify your login region operator.", "false"); } -- cgit v1.1 From fef3b3689492dea63693c964bcdbec9f5137eb5e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 21 Apr 2008 07:09:17 +0000 Subject: * Optimised using statements and namespace references across entire project (this took a while to run). --- OpenSim/Framework/Communications/CAPSService.cs | 3 ++- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++++----- OpenSim/Framework/Communications/Cache/AssetServer.cs | 5 +++-- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 10 +++++----- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 7 ++++--- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 5 +++-- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 13 +++++++------ OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 4 ++-- .../Communications/Cache/UserProfileCacheService.cs | 10 ++++------ OpenSim/Framework/Communications/Capabilities/Caps.cs | 9 ++++----- .../Framework/Communications/Capabilities/CapsHandlers.cs | 6 ------ .../Communications/Capabilities/LLSDAssetUploadComplete.cs | 2 +- .../Communications/Capabilities/LLSDAssetUploadRequest.cs | 9 +++++---- .../Communications/Capabilities/LLSDAssetUploadResponse.cs | 6 ++++-- .../Communications/Capabilities/LLSDInventoryItem.cs | 3 --- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 1 - .../Communications/Capabilities/LLSDVoiceAccountResponse.cs | 2 -- OpenSim/Framework/Communications/CommunicationsManager.cs | 4 +++- OpenSim/Framework/Communications/IInventoryServices.cs | 2 -- OpenSim/Framework/Communications/InventoryServiceBase.cs | 6 +++--- .../Framework/Communications/Limit/IRequestLimitStrategy.cs | 2 -- OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs | 2 -- .../Framework/Communications/Limit/RepeatLimitStrategy.cs | 1 - OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 5 +++-- OpenSim/Framework/Communications/LoginService.cs | 11 ++++++----- OpenSim/Framework/Communications/RestClient/RestClient.cs | 5 +++-- OpenSim/Framework/Communications/UserManagerBase.cs | 6 +++--- OpenSim/Framework/Communications/XMPP/Stanza.cs | 2 -- OpenSim/Framework/Communications/XMPP/XMPPParser.cs | 6 ------ 30 files changed, 71 insertions(+), 88 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index 133ba0d..caf96ff 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications @@ -47,7 +48,7 @@ namespace OpenSim.Framework.Communications public string CapsRequest(string request, string path, string param) { System.Console.WriteLine("new caps request " + request + " from path " + path); - return System.String.Empty; + return String.Empty; } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4d37e74..c81ea35 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -27,11 +27,11 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Threading; using libsecondlife; using libsecondlife.Packets; - -using OpenSim.Framework.Console; +using log4net; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications.Cache @@ -52,8 +52,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class AssetCache : IAssetReceiver { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The cache of assets. This does not include textures. @@ -170,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetCacheThread.Name = "AssetCacheThread"; m_assetCacheThread.IsBackground = true; m_assetCacheThread.Start(); - OpenSim.Framework.ThreadTracker.Add(m_assetCacheThread); + ThreadTracker.Add(m_assetCacheThread); } /// diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 3ce28c2..891fa6d 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -25,16 +25,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System.IO; +using System.Reflection; using Db4objects.Db4o; using Db4objects.Db4o.Query; using libsecondlife; -using OpenSim.Framework.Console; +using log4net; namespace OpenSim.Framework.Communications.Cache { public class LocalAssetServer : AssetServerBase { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IObjectContainer db; diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 261b697..1a7f872 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -26,18 +26,18 @@ */ using System; -using System.Collections.Generic; +using System.Reflection; using System.Threading; using libsecondlife; -using OpenSim.Framework.Console; +using log4net; using OpenSim.Framework.AssetLoader.Filesystem; namespace OpenSim.Framework.Communications.Cache { public abstract class AssetServerBase : IAssetServer { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IAssetReceiver m_receiver; protected BlockingQueue m_assetRequests; @@ -100,7 +100,7 @@ namespace OpenSim.Framework.Communications.Cache m_localAssetServerThread.Name = "LocalAssetServerThread"; m_localAssetServerThread.IsBackground = true; m_localAssetServerThread.Start(); - OpenSim.Framework.ThreadTracker.Add(m_localAssetServerThread); + ThreadTracker.Add(m_localAssetServerThread); } private void RunRequests() diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ec5717e..a245af1 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -27,8 +27,9 @@ using System; using System.Collections.Generic; - +using System.Reflection; using libsecondlife; +using log4net; namespace OpenSim.Framework.Communications.Cache { @@ -37,8 +38,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class CachedUserInfo { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The comms manager holds references to services (user, grid, inventory, etc.) diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 3e703d2..d5b7fea 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -27,15 +27,16 @@ using System; using System.IO; +using System.Reflection; using System.Xml.Serialization; -using OpenSim.Framework.Console; +using log4net; using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications.Cache { public class GridAssetClient : AssetServerBase { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string _assetServerUrl; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 03036d0..a39738d 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -28,10 +28,11 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Xml; using libsecondlife; +using log4net; using Nini.Config; -using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache { @@ -41,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache /// public class LibraryRootFolder : InventoryFolderImpl { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); @@ -153,13 +154,13 @@ namespace OpenSim.Framework.Communications.Cache { string foldersPath = Path.Combine( - Util.inventoryDir(), config.GetString("foldersFile", System.String.Empty)); + Util.inventoryDir(), config.GetString("foldersFile", String.Empty)); LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); string itemsPath = Path.Combine( - Util.inventoryDir(), config.GetString("itemsFile", System.String.Empty)); + Util.inventoryDir(), config.GetString("itemsFile", String.Empty)); LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); } @@ -209,8 +210,8 @@ namespace OpenSim.Framework.Communications.Cache item.ID = new LLUUID(config.GetString("inventoryID", ID.ToString())); item.AssetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); item.Folder = new LLUUID(config.GetString("folderID", ID.ToString())); - item.Description = config.GetString("description", System.String.Empty); - item.Name = config.GetString("name", System.String.Empty); + item.Description = config.GetString("description", String.Empty); + item.Name = config.GetString("name", String.Empty); item.AssetType = config.GetInt("assetType", 0); item.InvType = config.GetInt("inventoryType", 0); item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 4f1a304..1afec70 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -27,13 +27,13 @@ using System; using System.Reflection; -using OpenSim.Framework.Console; +using log4net; namespace OpenSim.Framework.Communications.Cache { public class SQLAssetServer : AssetServerBase { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public SQLAssetServer(string pluginName) { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 9813756..bf8ff40 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -25,13 +25,11 @@ * 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 OpenSim.Framework.Console; +using log4net; namespace OpenSim.Framework.Communications.Cache { @@ -40,8 +38,8 @@ namespace OpenSim.Framework.Communications.Cache /// public class UserProfileCacheService { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The comms manager holds references to services (user, grid, inventory, etc.) diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 2eff9c2..c07744c 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -29,12 +29,11 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; - +using System.Reflection; using libsecondlife; - +using log4net; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities @@ -66,8 +65,8 @@ namespace OpenSim.Region.Capabilities public class Caps { - private static readonly log4net.ILog m_log = - log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_httpListenerHostName; private uint m_httpListenPort; diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index 6992bd1..3e3ae16 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -25,14 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections; using System.Collections.Generic; -using System.IO; -using libsecondlife; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 876b8d3..1393523 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; using System; +using libsecondlife; namespace OpenSim.Region.Capabilities { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index fb64c75..e71a73e 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using libsecondlife; namespace OpenSim.Region.Capabilities @@ -32,11 +33,11 @@ namespace OpenSim.Region.Capabilities [LLSDMap] public class LLSDAssetUploadRequest { - public string asset_type = System.String.Empty; - public string description = System.String.Empty; + public string asset_type = String.Empty; + public string description = String.Empty; public LLUUID folder_id = LLUUID.Zero; - public string inventory_type = System.String.Empty; - public string name = System.String.Empty; + public string inventory_type = String.Empty; + public string name = String.Empty; public LLSDAssetUploadRequest() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index fb721f0..bb293ba 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -25,13 +25,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; + namespace OpenSim.Region.Capabilities { [LLSDMap] public class LLSDAssetUploadResponse { - public string uploader = System.String.Empty; - public string state = System.String.Empty; + public string uploader = String.Empty; + public string state = String.Empty; public LLSDAssetUploadResponse() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 36a2cbf..d402579 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -25,9 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; namespace OpenSim.Region.Capabilities diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index 4fb0544..4439346 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -27,7 +27,6 @@ */ using System.Collections; -using libsecondlife; namespace OpenSim.Region.Capabilities { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 8a18213..941e70e 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -26,8 +26,6 @@ * */ -using libsecondlife; - namespace OpenSim.Region.Capabilities { [LLSDMap] diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 192c8e3..ee0d164 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -27,7 +27,9 @@ using System; using System.Collections.Generic; +using System.Reflection; using libsecondlife; +using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -36,7 +38,7 @@ namespace OpenSim.Framework.Communications { public class CommunicationsManager { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IUserService m_userService; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 5e7f855..90bda01 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -26,9 +26,7 @@ */ using System.Collections.Generic; - using libsecondlife; - using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index d4e7539..f614e7d 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -29,14 +29,14 @@ using System; using System.Collections.Generic; using System.Reflection; using libsecondlife; -using OpenSim.Framework.Console; +using log4net; namespace OpenSim.Framework.Communications { public abstract class InventoryServiceBase : IInventoryServices { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_plugins = new Dictionary(); diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs index ded9ffc..6ec21d9 100644 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; - namespace OpenSim.Framework.Communications.Limit { /// diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 43b77a7..72d0586 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; - namespace OpenSim.Framework.Communications.Limit { /// diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index 85ff2bd..dfa05fa 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections.Generic; namespace OpenSim.Framework.Communications.Limit diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs index b2b4f14..34b01ff 100644 --- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs @@ -104,7 +104,7 @@ namespace OpenSim.Framework.Communications.Limit { if (!IsMonitoringRequests(id)) { - requests.Add(id, new Request(System.DateTime.Now)); + requests.Add(id, new Request(DateTime.Now)); } } diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 1b88d10..a379253 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -28,10 +28,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; using libsecondlife; using libsecondlife.StructuredData; +using log4net; using Nwc.XmlRpc; -using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement { @@ -41,7 +42,7 @@ namespace OpenSim.Framework.UserManagement /// public class LoginResponse { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Hashtable loginFlagsHash; private Hashtable globalTexturesHash; diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index ce8aa23..d656559 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -29,21 +29,22 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Text.RegularExpressions; using System.Threading; +using System.Web; using libsecondlife; using libsecondlife.StructuredData; +using log4net; using Nwc.XmlRpc; - using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.UserManagement { public abstract class LoginService { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; @@ -159,7 +160,7 @@ namespace OpenSim.Framework.UserManagement { webloginkey = new LLUUID((string)requestData["web_login_key"]); } - catch (System.Exception e) + catch (Exception e) { m_log.InfoFormat( "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", @@ -514,7 +515,7 @@ namespace OpenSim.Framework.UserManagement statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + - System.Web.HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + lastname + "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); //m_log.Info("[WEB]: R:" + redirectURL); diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 1178fed..5463134 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -29,10 +29,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Reflection; using System.Text; using System.Threading; using System.Web; -using OpenSim.Framework.Console; +using log4net; namespace OpenSim.Framework.Communications { @@ -55,7 +56,7 @@ namespace OpenSim.Framework.Communications /// public class RestClient { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string realuri; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index c86992a..0f7dc44 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -32,8 +32,8 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using libsecondlife.StructuredData; +using log4net; using Nwc.XmlRpc; -using OpenSim.Framework.Console; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.UserManagement @@ -43,8 +43,8 @@ namespace OpenSim.Framework.UserManagement /// public abstract class UserManagerBase : IUserService { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; private Dictionary _plugins = new Dictionary(); diff --git a/OpenSim/Framework/Communications/XMPP/Stanza.cs b/OpenSim/Framework/Communications/XMPP/Stanza.cs index 5675a47..3930bac 100644 --- a/OpenSim/Framework/Communications/XMPP/Stanza.cs +++ b/OpenSim/Framework/Communications/XMPP/Stanza.cs @@ -26,8 +26,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; using System.Xml; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs index e41df26..26a78b2 100644 --- a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs +++ b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs @@ -25,12 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using OpenSim.Framework; - namespace OpenSim.Framework.Communications.XMPP { public class XMPPParser -- cgit v1.1 From bf1580fba45df7624180b07599c8170074500c99 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 21 Apr 2008 12:42:56 +0000 Subject: From: Dr Scofield the attached patch set is centered around RemoteAdminPlugin and focuses mainly on making it more robust (i.e. more parameter checking and better error reporting) but also we've re-implemented the LoadTerrain stuff that got disabled during the terrain code reworking: * missing PostInitialize() calls on region modules that were loaded for regions created via RemoteAdmin's CreateRegion XmlRpc call * re-implements RemoteAdmin's LoadTerrain XmlRpc call (probably lost during the TerrainModule rework) * adds lots more parameter checking and error reporting to RemoteAdmin * adds a read-only property to RegionApplicationBase so that we can access the CommsManager * adds Exceptions to TerrainModule so that we get better error case feedback (and can report more meaningful errors in turn) * adds a CheckForTerrainUpdate() call to TerrainModule.LoadFromFile() to make terrain changes effective * adds TryGetCurrentScene(LLUUID) to SceneManager so that we can retrieve Scenes not only by name but also by LLUUID cheers, dr scofield --- OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index 3e3ae16..f101131 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -44,6 +44,10 @@ namespace OpenSim.Region.Capabilities private uint m_httpListenerPort; /// + /// CapsHandlers is a cap handler container but also takes + /// care of adding and removing cap handlers to and from the + /// supplied BaseHttpServer. + /// /// base HTTP server /// host name of the HTTP /// server -- cgit v1.1 From 269a2e4b887b9841309d4472508b19324a91d80d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 17:24:13 +0000 Subject: * Allow folder renaming to complete after an agent inventory has been received by a region from the inventory service * This replaces the old behaviour of failing straight away, which could cause lost updates if the inventory service was slow in responding * This is the first baby step to making all inventory requests behave this way, to reduce inventory lossage --- .../Communications/Cache/CachedUserInfo.cs | 62 +++++++++++++++++++--- .../Cache/UserProfileCacheService.cs | 36 +++++++++++++ 2 files changed, 90 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index a245af1..3d7ada3 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -45,25 +45,31 @@ namespace OpenSim.Framework.Communications.Cache /// The comms manager holds references to services (user, grid, inventory, etc.) /// private readonly CommunicationsManager m_commsManager; - - private UserProfileData m_userProfile; + public UserProfileData UserProfile { get { return m_userProfile; } } + private UserProfileData m_userProfile; - + /// + /// Has we received the user's inventory from the inventory service? + /// private bool m_hasInventory; /// + /// Inventory requests waiting for receipt of this user's inventory from the inventory service. + /// + private readonly IList m_pendingRequests = new List(); + + /// /// Has this user info object yet received its inventory information from the invetnroy service? /// public bool HasInventory { get { return m_hasInventory; } } - // FIXME: These need to be hidden behind accessors private InventoryFolderImpl m_rootFolder; public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } /// - /// Stores received folders for which we have not yet received the parents. - /// + /// FIXME: This could be contained within a local variable - it doesn't need to be a field + /// private IDictionary> pendingCategorizationFolders = new Dictionary>(); @@ -79,6 +85,27 @@ namespace OpenSim.Framework.Communications.Cache } /// + /// This allows a request to be added to be processed once we receive a user's inventory + /// from the inventory service. If we already have the inventory, the request + /// is executed immediately instead. + /// + /// + public void AddRequest(IInventoryRequest request) + { + lock (m_pendingRequests) + { + if (m_hasInventory) + { + request.Execute(); + } + else + { + m_pendingRequests.Add(request); + } + } + } + + /// /// Store a folder pending categorization when its parent is received. /// /// @@ -148,8 +175,19 @@ namespace OpenSim.Framework.Communications.Cache { m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); } - - m_hasInventory = true; + + // Deal with pending requests + lock (m_pendingRequests) + { + // We're going to change inventory status within the lock to avoid a race condition + // where requests are processed after the AddRequest() method has been called. + m_hasInventory = true; + + foreach (IInventoryRequest request in m_pendingRequests) + { + request.Execute(); + } + } } /// @@ -288,4 +326,12 @@ namespace OpenSim.Framework.Communications.Cache return result; } } + + /// + /// Should be implemented by callers which require a callback when the user's inventory is received + /// + public interface IInventoryRequest + { + void Execute(); + } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index bf8ff40..cbf2ded 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -201,6 +201,9 @@ namespace OpenSim.Framework.Communications.Cache public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID) { +// m_log.DebugFormat( +// "[AGENT INVENTORY] Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -216,6 +219,10 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Version = userProfile.RootFolder.Version; m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } + else + { + userProfile.AddRequest(new UpdateFolderRequest(this, remoteClient, folderID, type, name, parentID)); + } } } @@ -492,4 +499,33 @@ namespace OpenSim.Framework.Communications.Cache } } } + + /// + /// Used to create an update folder request if we haven't yet received the user's inventory + /// + internal class UpdateFolderRequest : IInventoryRequest + { + private UserProfileCacheService m_userProfileCacheService; + private IClientAPI m_client; + private LLUUID m_folderID; + private ushort m_type; + private string m_name; + private LLUUID m_parentID; + + internal UpdateFolderRequest( + UserProfileCacheService cacheService, IClientAPI client, LLUUID folderID, ushort type, string name, LLUUID parentID) + { + m_userProfileCacheService = cacheService; + m_client = client; + m_folderID = folderID; + m_type = type; + m_name = name; + m_parentID = parentID; + } + + public void Execute() + { + m_userProfileCacheService.HandleUpdateInventoryFolder(m_client, m_folderID, m_type, m_name, m_parentID); + } + } } -- cgit v1.1 From 68c6b6ece3f1f20a81806b08ffd5c73296324d6c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 18:58:09 +0000 Subject: * Replace previous specific inventory callback code with generic alternative --- .../Communications/Cache/CachedUserInfo.cs | 23 +++++++++++ .../Cache/UserProfileCacheService.cs | 47 ++++++++-------------- 2 files changed, 40 insertions(+), 30 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3d7ada3..9a7ce42 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -332,6 +332,29 @@ namespace OpenSim.Framework.Communications.Cache /// public interface IInventoryRequest { + /// + /// This is the method executed once we have received the user's inventory by which the request can be fulfilled. + /// void Execute(); } + + /// + /// Generic inventory request + /// + public class InventoryRequest : IInventoryRequest + { + private Delegate m_delegat; + private Object[] m_args; + + internal InventoryRequest(Delegate delegat, Object[] args) + { + m_delegat = delegat; + m_args = args; + } + + public void Execute() + { + m_delegat.DynamicInvoke(m_args); + } + } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index cbf2ded..eb85ec8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -25,14 +25,19 @@ * 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 log4net; namespace OpenSim.Framework.Communications.Cache { + internal delegate void UpdateInventoryFolderDelegate( + IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); + /// /// Holds user profile information and retrieves it from backend services. /// @@ -221,7 +226,10 @@ namespace OpenSim.Framework.Communications.Cache } else { - userProfile.AddRequest(new UpdateFolderRequest(this, remoteClient, folderID, type, name, parentID)); + userProfile.AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "HandleUpdateInventoryFolder"), + new object[] { remoteClient, folderID, type, name, parentID })); } } } @@ -234,6 +242,10 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) { + m_log.DebugFormat( + "[AGENT INVENTORY] Moving inventory folder {0} into folder {1} for {2} {3}", + parentID, remoteClient.Name, remoteClient.AgentId); + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -246,6 +258,10 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } +// else +// { +// userProfile.AddRequest(new MoveFolderRequest(remoteClient, folderID, parentID)); +// } } } @@ -499,33 +515,4 @@ namespace OpenSim.Framework.Communications.Cache } } } - - /// - /// Used to create an update folder request if we haven't yet received the user's inventory - /// - internal class UpdateFolderRequest : IInventoryRequest - { - private UserProfileCacheService m_userProfileCacheService; - private IClientAPI m_client; - private LLUUID m_folderID; - private ushort m_type; - private string m_name; - private LLUUID m_parentID; - - internal UpdateFolderRequest( - UserProfileCacheService cacheService, IClientAPI client, LLUUID folderID, ushort type, string name, LLUUID parentID) - { - m_userProfileCacheService = cacheService; - m_client = client; - m_folderID = folderID; - m_type = type; - m_name = name; - m_parentID = parentID; - } - - public void Execute() - { - m_userProfileCacheService.HandleUpdateInventoryFolder(m_client, m_folderID, m_type, m_name, m_parentID); - } - } } -- cgit v1.1 From fc6e23371fe5439d138f4358038fd4ebc7db87dc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 20:24:48 +0000 Subject: * Extend functionality to better handle delayed inventory service transfers to create folder, move folder and purge folder. * Old 1.18 get folder functionality requires a little more consideration --- .../Cache/UserProfileCacheService.cs | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index eb85ec8..f9835f6 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -35,6 +35,10 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { + internal delegate void CreateInventoryFolderDelegate( + IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); + internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); + internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); internal delegate void UpdateInventoryFolderDelegate( IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); @@ -188,6 +192,13 @@ namespace OpenSim.Framework.Communications.Cache } } } + else + { + userProfile.AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "HandleCreateInventoryFolder"), + new object[] { remoteClient, folderID, folderType, folderName, parentID })); + } } } @@ -207,7 +218,7 @@ namespace OpenSim.Framework.Communications.Cache LLUUID parentID) { // m_log.DebugFormat( -// "[AGENT INVENTORY] Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); +// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); CachedUserInfo userProfile; @@ -242,9 +253,9 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) { - m_log.DebugFormat( - "[AGENT INVENTORY] Moving inventory folder {0} into folder {1} for {2} {3}", - parentID, remoteClient.Name, remoteClient.AgentId); +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", +// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); CachedUserInfo userProfile; @@ -258,10 +269,13 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } -// else -// { -// userProfile.AddRequest(new MoveFolderRequest(remoteClient, folderID, parentID)); -// } + else + { + userProfile.AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(MoveInventoryFolderDelegate), this, "HandleMoveInventoryFolder"), + new object[] { remoteClient, folderID, parentID })); + } } } @@ -471,7 +485,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) { -// m_log.InfoFormat("[INVENTORYCACHE]: Purging folder {0} for {1} uuid {2}", +// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", // folderID, remoteClient.Name, remoteClient.AgentId); CachedUserInfo userProfile; @@ -489,6 +503,13 @@ namespace OpenSim.Framework.Communications.Cache } } } + else + { + userProfile.AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(PurgeInventoryDescendentsDelegate), this, "HandlePurgeInventoryDescendents"), + new object[] { remoteClient, folderID })); + } } } -- cgit v1.1 From 8d8b4a314f1b7baa657885f490ab6aef9cecfc3b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 20:47:54 +0000 Subject: * Add DeleteAllContents() method to InventoryFolderImpl - not yet used but will be soon * Add locking to InventoryFolderImpl class - need more though. --- .../Communications/Cache/InventoryFolderImpl.cs | 148 +++++++++++++++------ 1 file changed, 109 insertions(+), 39 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 091a6a3..daf9ab5 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -57,99 +57,169 @@ namespace OpenSim.Framework.Communications.Cache { } - // Methods public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { - if (!SubFolders.ContainsKey(folderID)) + lock (SubFolders) { - InventoryFolderImpl subFold = new InventoryFolderImpl(); - subFold.Name = folderName; - subFold.ID = folderID; - subFold.Type = (short) type; - subFold.ParentID = this.ID; - subFold.Owner = Owner; - SubFolders.Add(subFold.ID, subFold); - return subFold; + if (!SubFolders.ContainsKey(folderID)) + { + InventoryFolderImpl subFold = new InventoryFolderImpl(); + subFold.Name = folderName; + subFold.ID = folderID; + subFold.Type = (short) type; + subFold.ParentID = this.ID; + subFold.Owner = Owner; + SubFolders.Add(subFold.ID, subFold); + return subFold; + } } + return null; } + + /// + /// Delete all the folders and items in this folder. + /// + /// TODO: This method is not used yet, but will be shortly + /// + public void DeleteAllContents() + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + folder.DeleteAllContents(); + } + + SubFolders.Clear(); + Items.Clear(); + } + /// + /// Does this folder contain the given item? + /// + /// + /// public InventoryItemBase HasItem(LLUUID itemID) { InventoryItemBase base2 = null; - if (Items.ContainsKey(itemID)) + + lock (Items) { - return Items[itemID]; + if (Items.ContainsKey(itemID)) + { + return Items[itemID]; + } } - foreach (InventoryFolderImpl folder in SubFolders.Values) + + lock (SubFolders) { - base2 = folder.HasItem(itemID); - if (base2 != null) + foreach (InventoryFolderImpl folder in SubFolders.Values) { - break; + base2 = folder.HasItem(itemID); + if (base2 != null) + { + break; + } } } + return base2; } + /// + /// Delete an item from the folder. + /// + /// + /// public bool DeleteItem(LLUUID itemID) { bool found = false; - if (Items.ContainsKey(itemID)) + + lock (Items) { - Items.Remove(itemID); - return true; + if (Items.ContainsKey(itemID)) + { + Items.Remove(itemID); + return true; + } } - foreach (InventoryFolderImpl folder in SubFolders.Values) + + lock (SubFolders) { - found = folder.DeleteItem(itemID); - if (found == true) + foreach (InventoryFolderImpl folder in SubFolders.Values) { - break; + found = folder.DeleteItem(itemID); + if (found == true) + { + break; + } } } return found; } - + /// + /// Does this folder contain the given subfolder? + /// + /// public InventoryFolderImpl HasSubFolder(LLUUID folderID) - { + { InventoryFolderImpl returnFolder = null; - if (SubFolders.ContainsKey(folderID)) - { - returnFolder = SubFolders[folderID]; - } - else + + lock (SubFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + if (SubFolders.ContainsKey(folderID)) { - returnFolder = folder.HasSubFolder(folderID); - if (returnFolder != null) + returnFolder = SubFolders[folderID]; + } + else + { + foreach (InventoryFolderImpl folder in SubFolders.Values) { - break; + returnFolder = folder.HasSubFolder(folderID); + if (returnFolder != null) + { + break; + } } } } + return returnFolder; } + /// + /// Return the list of items in this folder + /// public List RequestListOfItems() { List itemList = new List(); - foreach (InventoryItemBase item in Items.Values) + + lock (Items) { - itemList.Add(item); + foreach (InventoryItemBase item in Items.Values) + { + itemList.Add(item); + } } + return itemList; } + /// + /// Return the list of folders in this folder + /// public List RequestListOfFolders() - { + { List folderList = new List(); - foreach (InventoryFolderBase folder in SubFolders.Values) + + lock (SubFolders) { - folderList.Add(folder); + foreach (InventoryFolderBase folder in SubFolders.Values) + { + folderList.Add(folder); + } } + return folderList; } } -- cgit v1.1 From cd29f90418b8690cffc2df8fae52fa976090e574 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 22 Apr 2008 20:59:08 +0000 Subject: * Add folders and items locking in external manipulations of InventoryFolderImpl carried out by CachedUserInfo * These will do temporarily pending refactoring --- .../Communications/Cache/CachedUserInfo.cs | 55 ++++++++++++++-------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9a7ce42..f1268d5 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -142,10 +142,13 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - if (!parent.SubFolders.ContainsKey(folder.ID)) + lock (parent.SubFolders) { - parent.SubFolders.Add(folder.ID, folder); - } + if (!parent.SubFolders.ContainsKey(folder.ID)) + { + parent.SubFolders.Add(folder.ID, folder); + } + } } } } @@ -212,28 +215,34 @@ namespace OpenSim.Framework.Communications.Cache } else if (RootFolder.ID == folderInfo.ParentID) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) + lock (RootFolder.SubFolders) { - RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); + if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) + { + RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); + } + else + { + AddPendingFolder(folderInfo); + } } - else - { - AddPendingFolder(folderInfo); - } } else { InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); - if (folder != null) + lock (folder.SubFolders) { - if (!folder.SubFolders.ContainsKey(folderInfo.ID)) + if (folder != null) { - folder.SubFolders.Add(folderInfo.ID, folderInfo); + if (!folder.SubFolders.ContainsKey(folderInfo.ID)) + { + folder.SubFolders.Add(folderInfo.ID, folderInfo); + } + } + else + { + AddPendingFolder(folderInfo); } - } - else - { - AddPendingFolder(folderInfo); } } @@ -259,9 +268,12 @@ namespace OpenSim.Framework.Communications.Cache { if (itemInfo.Folder == RootFolder.ID) { - if (!RootFolder.Items.ContainsKey(itemInfo.ID)) + lock (RootFolder.Items) { - RootFolder.Items.Add(itemInfo.ID, itemInfo); + if (!RootFolder.Items.ContainsKey(itemInfo.ID)) + { + RootFolder.Items.Add(itemInfo.ID, itemInfo); + } } } else @@ -269,9 +281,12 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder); if (folder != null) { - if (!folder.Items.ContainsKey(itemInfo.ID)) + lock (folder.Items) { - folder.Items.Add(itemInfo.ID, itemInfo); + if (!folder.Items.ContainsKey(itemInfo.ID)) + { + folder.Items.Add(itemInfo.ID, itemInfo); + } } } } -- cgit v1.1 From 41f9bbc26dbdca23cc7cf93a7d650b3779ac0b37 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Apr 2008 11:14:19 +0000 Subject: * Fix mantis #842 - folders which are created but left named "New Folder" in places other than directly under "My Inventory" should now be stored --- .../Communications/Cache/UserProfileCacheService.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f9835f6..e3f6815 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -160,6 +160,9 @@ namespace OpenSim.Framework.Communications.Cache public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -188,7 +191,17 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID); if (folder != null) { - folder.CreateNewSubFolder(folderID, folderName, folderType); + InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); + + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.Owner = createdFolder.Owner; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; + + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } } } -- cgit v1.1 From 2b886ab9f0cf3e343ff6c1b3f191ae32f7acbb52 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 23 Apr 2008 12:00:23 +0000 Subject: * Fix for mantis #1025 - Region always reports that location is unavailable. Thanks Lulurun. --- OpenSim/Framework/Communications/LoginService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d656559..37c0bd8 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -248,7 +248,7 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); - + // Circuit Code uint circode = (uint) (Util.RandomClass.Next()); @@ -266,7 +266,8 @@ namespace OpenSim.Framework.UserManagement //logResponse.SimAddress = "127.0.0.1"; //overwritten //logResponse.SimPort = 0; //overwritten logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; try { -- cgit v1.1 From 4db839c3b84bed8a775074beb1ae0b526bc05e81 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Apr 2008 17:04:15 +0000 Subject: * Implement proper emptying of trashcan on standalone * On standalone, folders (and their items) should now be persistently deleted on trash emptying, as well as immediate child items * An implementation for grid mode will follow. --- .../Communications/Cache/InventoryFolderImpl.cs | 8 ++-- .../Cache/UserProfileCacheService.cs | 29 +++++++++++--- .../Framework/Communications/IInventoryServices.cs | 12 ++++++ .../Communications/InventoryServiceBase.cs | 45 +++++++++++++++++++++- 4 files changed, 83 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index daf9ab5..7812499 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -79,14 +79,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Delete all the folders and items in this folder. - /// - /// TODO: This method is not used yet, but will be shortly /// - public void DeleteAllContents() + public void Purge() { foreach (InventoryFolderImpl folder in SubFolders.Values) { - folder.DeleteAllContents(); + folder.Purge(); } SubFolders.Clear(); @@ -206,7 +204,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return the list of folders in this folder + /// Return the list of immediate child folders in this folder. /// public List RequestListOfFolders() { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index e3f6815..61ec483 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -496,6 +496,11 @@ namespace OpenSim.Framework.Communications.Cache return new List(); } + /// + /// This should delete all the items and folders in the given directory. + /// + /// + /// public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) { // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", @@ -506,14 +511,28 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.HasInventory) { - InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); - if (subFolder != null) - { - List items = subFolder.RequestListOfItems(); + InventoryFolderImpl purgedFolder = userProfile.RootFolder.HasSubFolder(folderID); + if (purgedFolder != null) + { + // XXX Nasty - have to create a new object to hold details we already have + InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); + purgedBaseFolder.Owner = purgedFolder.Owner; + purgedBaseFolder.ID = purgedFolder.ID; + purgedBaseFolder.Name = purgedFolder.Name; + purgedBaseFolder.ParentID = purgedFolder.ParentID; + purgedBaseFolder.Type = purgedFolder.Type; + purgedBaseFolder.Version = purgedFolder.Version; + + m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder); + + // XXX Remains temporarily so that we still delete items in the grid case. + List items = purgedFolder.RequestListOfItems(); foreach (InventoryItemBase item in items) { userProfile.DeleteItem(remoteClient.AgentId, item); - } + } + + purgedFolder.Purge(); } } else diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 90bda01..5690f89 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -56,9 +56,21 @@ namespace OpenSim.Framework.Communications /// void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + /// + /// Move an inventory folder to a new location + /// + /// + /// A folder containing the details of the new location void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); /// + /// Purge an inventory folder of all its items and subfolders. + /// + /// + /// + void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder); + + /// /// Add a new item to the given user's inventory /// /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index f614e7d..769c530 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications { if (!String.IsNullOrEmpty(FileName)) { - m_log.Info("[AGENTINVENTORY]: Inventory storage: Attempting to load " + FileName); + m_log.Info("[AGENT INVENTORY]: Inventory storage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -161,9 +161,19 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); + // See IInventoryServices public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + + // See IInventoryServices public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); + + // See IInventoryServices + public abstract void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder); + + // See IInventoryServices public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + + // See IInventoryServices public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); #endregion @@ -228,6 +238,36 @@ namespace OpenSim.Framework.Communications } } + /// + /// Purge a folder of all items items and subfolders. + /// + /// FIXME: Really nasty in a sense, because we have to query the database to get information we may + /// already know... Needs heavy refactoring. + /// + /// + protected void PurgeFolder(InventoryFolderBase folder) + { + List subFolders = RequestSubFolders(folder.ID); + + foreach (InventoryFolderBase subFolder in subFolders) + { +// m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); + + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.deleteInventoryFolder(subFolder.ID); + } + } + + // XXX Temporarily don't delete the items since UserProfileCacheService is still doing this +// List items = RequestFolderItems(folder.ID); +// +// foreach (InventoryItemBase item : items) +// { +// DeleteItem(item); +// } + } + private void AddNewInventorySet(UsersInventory inventory) { foreach (InventoryFolderBase folder in inventory.Folders.Values) @@ -236,6 +276,9 @@ namespace OpenSim.Framework.Communications } } + /// + /// Used to create a new user inventory. + /// private class UsersInventory { public Dictionary Folders = new Dictionary(); -- cgit v1.1 From a1cc0e436ff9081f3c0a76de861ed0673cd36142 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 19:13:06 +0000 Subject: changes to allow asset_source to be specified in the opensim.ini this will work for sqlite and nhibernate, but will be ignored for mysql and mssql (reverting to their ini files) until someone writes that bit. --- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 1afec70..334c5bd 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -35,9 +35,9 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public SQLAssetServer(string pluginName) + public SQLAssetServer(string pluginName, string connect) { - AddPlugin(pluginName); + AddPlugin(pluginName, connect); } public SQLAssetServer(IAssetProvider assetProvider) @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider = assetProvider; } - public void AddPlugin(string FileName) + public void AddPlugin(string FileName, string connect) { m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); @@ -61,7 +61,7 @@ namespace OpenSim.Framework.Communications.Cache IAssetProvider plug = (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProvider = plug; - m_assetProvider.Initialise(); + m_assetProvider.Initialise(connect); m_log.Info("[AssetStorage]: " + "Added " + m_assetProvider.Name + " " + -- cgit v1.1 From 3dd98a112f4308532d768943690b13c403dff68b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 20:48:23 +0000 Subject: allow for Inventory database source to be specified in main configs. This works with sqlite and nhibernate backends, and stays with default seperate ini files for mysql and mssql until someone writes those. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 769c530..5cbfcf9 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -46,7 +46,7 @@ namespace OpenSim.Framework.Communications /// 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) + public void AddPlugin(string FileName, string connect) { if (!String.IsNullOrEmpty(FileName)) { @@ -63,7 +63,7 @@ namespace OpenSim.Framework.Communications { IInventoryData plug = (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(); + plug.Initialise(connect); m_plugins.Add(plug.getName(), plug); m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface"); } -- cgit v1.1 From 40176c12f94044527e82972cbb72cce8caa5ce2b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Apr 2008 22:13:57 +0000 Subject: * Implement full grid mode Trash empty * Now, emptying the trash should remove folders and the items they contain as well as items which were not in a subfolder. * This will only work once both the region and grid servers have reached this revision. * You may also need to clear your cache before this will work * Refactoring to follow. --- .../Communications/Cache/UserProfileCacheService.cs | 9 +-------- OpenSim/Framework/Communications/InventoryServiceBase.cs | 13 ++++++------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 61ec483..1e3dbb6 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -523,14 +523,7 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder); - - // XXX Remains temporarily so that we still delete items in the grid case. - List items = purgedFolder.RequestListOfItems(); - foreach (InventoryItemBase item in items) - { - userProfile.DeleteItem(remoteClient.AgentId, item); - } + m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder); purgedFolder.Purge(); } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 5cbfcf9..0528b91 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -259,13 +259,12 @@ namespace OpenSim.Framework.Communications } } - // XXX Temporarily don't delete the items since UserProfileCacheService is still doing this -// List items = RequestFolderItems(folder.ID); -// -// foreach (InventoryItemBase item : items) -// { -// DeleteItem(item); -// } + List items = RequestFolderItems(folder.ID); + + foreach (InventoryItemBase item in items) + { + DeleteItem(item); + } } private void AddNewInventorySet(UsersInventory inventory) -- cgit v1.1 From accd89b3f1c7729e6bb34b52e8095baf9c1f440a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 26 Apr 2008 20:31:01 +0000 Subject: * First draft implementation of copying prim inventory items back to agent inventory * Now, if you own an item in a prim, you should be able to successfully drag it back into your inventory * Temporarily, users which are not owners of the item cannot copy it, even if 'everyone can copy' is set * This is pending fixes/implementation of upstream permission implementation --- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 7812499..33d820d 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Does this folder contain the given item? + /// Does this folder or any of its subfolders contain the given item? /// /// /// -- cgit v1.1 From 911e63765c7cea748b5ae2227f5c1d6ff131d329 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 27 Apr 2008 20:10:28 +0000 Subject: * Single Attachments now work from inventory. You can attach from inventory and detach from inventory. * Detaching from right clicking in world, detaches to your inventory. * If you go up to a prim and attach it from in world, it appears in your inventory. * Attachment placement is saved when you detach them. * Choosing wear remembers your last attachment point from inventory. * Wrote a method to update an inventory item's asset and sends the updated inventory item to the Client * Wrote a recursive method to find the folder of a known existing inventory item. * Removed a block on physics object position on creation. This might crash a region or two, let us know via Mantis if your region crashes because of a physics out of bounds error. * Drop doesn't work. The menu item doesn't even come up. Don't know why :P. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f1268d5..9749366 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -272,8 +272,13 @@ namespace OpenSim.Framework.Communications.Cache { if (!RootFolder.Items.ContainsKey(itemInfo.ID)) { + RootFolder.Items.Add(itemInfo.ID, itemInfo); } + else + { + RootFolder.Items[itemInfo.ID] = itemInfo; + } } } else @@ -287,6 +292,10 @@ namespace OpenSim.Framework.Communications.Cache { folder.Items.Add(itemInfo.ID, itemInfo); } + else + { + folder.Items[itemInfo.ID] = itemInfo; + } } } } -- cgit v1.1 From dd96158afe23814c8b10a6b95f66b67a4eee310a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 30 Apr 2008 15:03:37 +0000 Subject: move IUserService into the OpenSim.Framework.Communications assembly because all the other I***Service interfaces are there. --- OpenSim/Framework/Communications/IUserService.cs | 112 +++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 OpenSim/Framework/Communications/IUserService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs new file mode 100644 index 0000000..2b6e0d5 --- /dev/null +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework +{ + public interface IUserService + { + /// + /// Loads a user profile by name + /// + /// First name + /// Last name + /// A user profile. Returns null if no profile is found + UserProfileData GetUserProfile(string firstName, string lastName); + + //UserProfileData GetUserProfile(string name); + + /// + /// Loads a user profile from a database by UUID + /// + /// The target UUID + /// A user profile. Returns null if no user profile is found. + UserProfileData GetUserProfile(LLUUID userId); + + void clearUserAgent(LLUUID avatarID); + List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); + + UserProfileData SetupMasterUser(string firstName, string lastName); + UserProfileData SetupMasterUser(string firstName, string lastName, string password); + UserProfileData SetupMasterUser(LLUUID userId); + + /// + /// + /// + /// + LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + + + /// + /// Adds a new friend to the database for XUser + /// + /// The agent that who's friends list is being added to + /// The agent that being added to the friends list of the friends list owner + /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects + void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms); + + /// + /// Delete friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The Ex-friend agent + void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend); + + /// + /// Update permissions for friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The agent that is getting or loosing permissions + /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects + void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); + + /// + /// Updates a user profile + /// + /// Profile to update + /// + bool UpdateUserProfileProperties(UserProfileData UserProfile); + + /// + /// Logs off a user on the user server + /// + /// UUID of the user + /// UUID of the Region + /// final position x + /// final position y + /// final position z + void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz); + + /// + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// + /// The agent that we're retreiving the friends Data. + List GetUserFriendList(LLUUID friendlistowner); + } +} \ No newline at end of file -- cgit v1.1 From a9cc76e0efba7496909d613c75b81de6a9c5d979 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 30 Apr 2008 16:08:24 +0000 Subject: * Long awaited patch from A_Biondi Mantis 923. Kept alive by Melanie. Thanks A_Biondi and Melanie! * This builds but might not work. JustinCC will examine.. it may work out of the box. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/IInventoryServices.cs | 7 +++++++ OpenSim/Framework/Communications/InventoryServiceBase.cs | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9749366..847909a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -325,7 +325,7 @@ namespace OpenSim.Framework.Communications.Cache { if ((userID == UserProfile.ID) && HasInventory) { - m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + m_commsManager.InventoryService.UpdateInventoryItem(userID, itemInfo); } } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 5690f89..c82c946 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -78,6 +78,13 @@ namespace OpenSim.Framework.Communications void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); /// + /// Update an item in the given user's inventory + /// + /// + /// + void UpdateInventoryItem(LLUUID userID, InventoryItemBase item); + + /// /// Delete an item from the given user's inventory /// /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 0528b91..dab6a16 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -172,6 +172,9 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + + // See IInventoryServices + public abstract void UpdateInventoryItem(LLUUID userID, InventoryItemBase item); // See IInventoryServices public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); @@ -230,6 +233,14 @@ namespace OpenSim.Framework.Communications } } + protected void UpdateItem(InventoryItemBase item) + { + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.updateInventoryItem(item); + } + } + protected void DeleteItem(InventoryItemBase item) { foreach (KeyValuePair plugin in m_plugins) -- cgit v1.1 From 9817363b9340cb4f918f4e1ca0690f112691113c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 19:08:48 +0000 Subject: * Completely inconsequential inventory odds and ends (actual impact - only one log message changed) --- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 7 +++++++ OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 33d820d..5f532e0 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -26,12 +26,17 @@ */ using System.Collections.Generic; +//using System.Reflection; + using libsecondlife; +//using log4net; namespace OpenSim.Framework.Communications.Cache { public class InventoryFolderImpl : InventoryFolderBase { + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // Fields public Dictionary Items = new Dictionary(); public Dictionary SubFolders = new Dictionary(); @@ -200,6 +205,8 @@ namespace OpenSim.Framework.Communications.Cache } } + //m_log.DebugFormat("[INVENTORY FOLDER IMPL]: Found {0} items", itemList.Count); + return itemList; } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 1e3dbb6..ec06a23 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -47,8 +47,7 @@ namespace OpenSim.Framework.Communications.Cache /// public class UserProfileCacheService { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The comms manager holds references to services (user, grid, inventory, etc.) @@ -416,6 +415,8 @@ namespace OpenSim.Framework.Communications.Cache public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + //m_log.DebugFormat("[INVENTORY CACHE]: Fetching folders/items from {0} for agent {1}", folderID, agentID); + // XXX We're not handling sortOrder yet! InventoryFolderImpl fold = null; -- cgit v1.1 From 3984a7fda1c37d5aaec7f6c7d12ce2804a0c750e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 19:55:45 +0000 Subject: * Resolve mantis 1068, 1095 * The resolution takes the form of not crashing the session if the folder the user is attempting to add already exists (e.g. there is one already with the same UUID). * Printing out warnings instead --- .../Communications/Cache/InventoryFolderImpl.cs | 7 ++++ .../Cache/UserProfileCacheService.cs | 41 ++++++++++++++++------ 2 files changed, 38 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 5f532e0..f55f323 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -62,6 +62,13 @@ namespace OpenSim.Framework.Communications.Cache { } + /// + /// Create a new subfolder. This exists only in the cache. + /// + /// + /// + /// + /// The newly created subfolder. Returns null if the folder already exists public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { lock (SubFolders) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index ec06a23..4627f75 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -184,6 +184,12 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Version = createdFolder.Version; m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists", + folderName, folderID, remoteClient.Name, remoteClient.AgentId); + } } else { @@ -191,16 +197,31 @@ namespace OpenSim.Framework.Communications.Cache if (folder != null) { InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); - - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + + if (createdFolder != null) + { + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.Owner = createdFolder.Owner; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; + + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists", + folderName, folderID, remoteClient.Name, remoteClient.AgentId); + } + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2} for user {3} {4}", + parentID, folderName, folderID, remoteClient.Name, remoteClient.AgentId); } } } -- cgit v1.1 From 3508298ddf5df94574c37c04fd59c3df579e42a2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Apr 2008 20:04:06 +0000 Subject: * Refactor: Rename InventoryFolderImpl.HasSubFolder() to GetDescendentFolder() --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ++-- .../Framework/Communications/Cache/InventoryFolderImpl.cs | 8 ++++---- .../Communications/Cache/UserProfileCacheService.cs | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 847909a..7902240 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -229,7 +229,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); + InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); lock (folder.SubFolders) { if (folder != null) @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.Folder); + InventoryFolderImpl folder = RootFolder.GetDescendentFolder(itemInfo.Folder); if (folder != null) { lock (folder.Items) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index f55f323..4dcf755 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -168,10 +168,10 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Does this folder contain the given subfolder? + /// Returns the folder requested if it exists as a descendent of this folder /// - /// - public InventoryFolderImpl HasSubFolder(LLUUID folderID) + /// The requested folder if it exists, null if it does not. + public InventoryFolderImpl GetDescendentFolder(LLUUID folderID) { InventoryFolderImpl returnFolder = null; @@ -185,7 +185,7 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in SubFolders.Values) { - returnFolder = folder.HasSubFolder(folderID); + returnFolder = folder.GetDescendentFolder(folderID); if (returnFolder != null) { break; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 4627f75..049b4a1 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -193,7 +193,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = userProfile.RootFolder.HasSubFolder(parentID); + InventoryFolderImpl folder = userProfile.RootFolder.GetDescendentFolder(parentID); if (folder != null) { InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); @@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Cache return; } - if ((fold = libraryRoot.HasSubFolder(folderID)) != null) + if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( libraryRoot.Owner, folderID, fold.RequestListOfItems(), @@ -385,7 +385,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) + if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Found folder {0} for client {1}", @@ -446,7 +446,7 @@ namespace OpenSim.Framework.Communications.Cache return libraryRoot.RequestListOfItems(); } - if ((fold = libraryRoot.HasSubFolder(folderID)) != null) + if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) { return fold.RequestListOfItems(); } @@ -487,7 +487,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) + if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) { return fold.RequestListOfItems(); } @@ -533,7 +533,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.HasInventory) { - InventoryFolderImpl purgedFolder = userProfile.RootFolder.HasSubFolder(folderID); + InventoryFolderImpl purgedFolder = userProfile.RootFolder.GetDescendentFolder(folderID); if (purgedFolder != null) { // XXX Nasty - have to create a new object to hold details we already have -- cgit v1.1 From 25a49ac4de056f43d6c5803fcd34804fcea96ae2 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 30 Apr 2008 23:11:07 +0000 Subject: * Spring cleaned a bunch of '//TODO: unused' marked functions. --- .../Communications/RestClient/RestClient.cs | 54 ---------------------- 1 file changed, 54 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 5463134..6877690 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -196,17 +196,6 @@ namespace OpenSim.Framework.Communications return s.Substring(s.Length - 1, 1) == "/"; } -// TODO: unused -// /// -// /// return a slash or blank. A slash will be returned if the string does not contain one -// /// -// /// stromg to be examined -// /// slash '/' if not already present -// private string slash(string s) -// { -// return isSlashed(s) ? String.Empty : "/"; -// } - /// /// Build a Uri based on the initial Url, path elements and parameters /// @@ -280,49 +269,6 @@ namespace OpenSim.Framework.Communications } } -// TODO: unused -// /// -// /// Async method, invoked when the initial response if received from the server -// /// -// /// -// private void ResponseIsReadyDelegate(IAsyncResult ar) -// { -// try -// { -// // grab response -// WebRequest wr = (WebRequest) ar.AsyncState; -// _response = (HttpWebResponse) wr.EndGetResponse(ar); - -// // get response stream, and setup async reading -// Stream s = _response.GetResponseStream(); -// IAsyncResult asynchronousResult = -// s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - -// // TODO! Implement timeout, without killing the server -// // wait until completed, or we timed out -// // ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); -// } -// catch (Exception e) -// { -// _allDone.Set(); -// _asyncException = e; -// } -// } - -// TODO: unused -// // Abort the request if the timer fires. -// private static void TimeoutCallback(object state, bool timedOut) -// { -// if (timedOut) -// { -// HttpWebRequest request = state as HttpWebRequest; -// if (request != null) -// { -// request.Abort(); -// } -// } -// } - #endregion Async communications with server /// -- cgit v1.1 From 4692e92312ceacf414629eb78f6d0725a2eb2ca5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 14:45:56 +0000 Subject: * Assorted spring cleanings. --- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 2 +- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 4dcf755..f6accf6 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -26,9 +26,9 @@ */ using System.Collections.Generic; +using libsecondlife; //using System.Reflection; -using libsecondlife; //using log4net; namespace OpenSim.Framework.Communications.Cache diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 049b4a1..392d796 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Threading; - using libsecondlife; using log4net; -- cgit v1.1 From a1c8aa4050b7f7a94e02dd40d8cd456f258b4e2b Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 15:36:39 +0000 Subject: * Cleaned namespaces of entire solution. OpenSim directories now correspond with namespaces. --- .../Framework/Communications/Capabilities/Caps.cs | 11 +- .../Communications/Capabilities/CapsHandlers.cs | 4 +- .../Framework/Communications/Capabilities/LLSD.cs | 4 +- .../Communications/Capabilities/LLSDArray.cs | 4 +- .../Capabilities/LLSDAssetUploadComplete.cs | 4 +- .../Capabilities/LLSDAssetUploadRequest.cs | 4 +- .../Capabilities/LLSDAssetUploadResponse.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 4 +- .../Communications/Capabilities/LLSDEmpty.cs | 4 +- .../Communications/Capabilities/LLSDHelpers.cs | 4 +- .../Capabilities/LLSDInventoryItem.cs | 13 +- .../Communications/Capabilities/LLSDItemUpdate.cs | 4 +- .../Communications/Capabilities/LLSDMapLayer.cs | 4 +- .../Capabilities/LLSDMapLayerResponse.cs | 4 +- .../Communications/Capabilities/LLSDMapRequest.cs | 4 +- .../Communications/Capabilities/LLSDMethod.cs | 4 +- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 4 +- .../LLSDTaskInventoryUploadComplete.cs | 4 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 4 +- .../Communications/Capabilities/LLSDTest.cs | 4 +- .../Communications/Capabilities/LLSDType.cs | 4 +- .../Capabilities/LLSDVoiceAccountResponse.cs | 2 +- .../Framework/Communications/GenericAsyncResult.cs | 156 +++++++++ OpenSim/Framework/Communications/IUserService.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 30 +- OpenSim/Framework/Communications/RestClient.cs | 368 +++++++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 10 +- 29 files changed, 593 insertions(+), 79 deletions(-) create mode 100644 OpenSim/Framework/Communications/GenericAsyncResult.cs create mode 100644 OpenSim/Framework/Communications/RestClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index c07744c..b6ee04d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -32,11 +32,10 @@ using System.IO; using System.Reflection; using libsecondlife; using log4net; -using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { public delegate void UpLoadedAsset( string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, @@ -54,8 +53,8 @@ namespace OpenSim.Region.Capabilities bool isScriptRunning, byte[] data); public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder); - + bool fetchFolders, bool fetchItems, int sortOrder); + /// /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want @@ -397,7 +396,7 @@ namespace OpenSim.Region.Capabilities /// public string RequestTexture(string request, string path, string param) { - Console.WriteLine("texture request " + request); + System.Console.WriteLine("texture request " + request); // Needs implementing (added to remove compiler warning) return String.Empty; } @@ -961,4 +960,4 @@ namespace OpenSim.Region.Capabilities } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index f101131..e76a5c5 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -29,7 +29,7 @@ using System.Collections; using System.Collections.Generic; using OpenSim.Framework.Servers; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { /// /// CapsHandlers is a cap handler container but also takes @@ -141,4 +141,4 @@ namespace OpenSim.Region.Capabilities } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index b3e841c..13361c7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -34,7 +34,7 @@ using System.Text; using System.Xml; using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { /// /// Borrowed from (a older version of ) libsl for now, as their new llsd code doesn't work we our decoding code. @@ -676,4 +676,4 @@ namespace OpenSim.Region.Capabilities } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index a5cdd73..3579cc2 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -27,7 +27,7 @@ using System.Collections; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("ARRAY")] public class LLSDArray @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 1393523..6c4db4b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -28,7 +28,7 @@ using System; using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDAssetUploadComplete @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index e71a73e..289cc93 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -28,7 +28,7 @@ using System; using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDAssetUploadRequest @@ -43,4 +43,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index bb293ba..63b3351 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDAssetUploadResponse diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index c1b15b4..5ff21b8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDCapEvent @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 5a44e26..4abdb59 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDEmpty @@ -34,4 +34,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index a39f5aa..409d2e0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -31,7 +31,7 @@ using System.IO; using System.Reflection; using System.Xml; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { public class LLSDHelpers { @@ -160,4 +160,4 @@ namespace OpenSim.Region.Capabilities return obj; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index d402579..31896c2 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -27,7 +27,7 @@ using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDInventoryItem @@ -68,15 +68,6 @@ namespace OpenSim.Region.Capabilities public string sale_type; } - /* [LLSDMap] - public class LLSDFolderItem - { - public LLUUID folder_id; - public LLUUID parent_id; - public int type; - public string name; - }*/ - [LLSDMap] public class LLSDInventoryDescendents { @@ -103,4 +94,4 @@ namespace OpenSim.Region.Capabilities public LLUUID owner___id; // and of course we can't have field names with "-" in public int version; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 6211c4f..2c4b68f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -27,7 +27,7 @@ using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDItemUpdate @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 0cf82a8..50f5241 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -27,7 +27,7 @@ using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDMapLayer @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 205a645..7dabbec 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDMapLayerResponse @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 748c5ea..317e35d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDMapRequest @@ -36,4 +36,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index deb9223..55d62ac 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { public delegate TResponse LLSDMethod(TRequest request); -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index 4439346..fb5eaa8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -28,7 +28,7 @@ using System.Collections; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDParcelVoiceInfoResponse diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 545643a..5e8a08f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -30,7 +30,7 @@ using System.IO; using System.Text; using OpenSim.Framework.Servers; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { public class LLSDStreamhandler : BaseStreamHandler where TRequest : new() @@ -65,4 +65,4 @@ namespace OpenSim.Region.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 22e45f4..ee9ff1b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -27,7 +27,7 @@ using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDTaskInventoryUploadComplete @@ -47,4 +47,4 @@ namespace OpenSim.Region.Capabilities /// public string state; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index ed7e824..df32d1a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -27,7 +27,7 @@ using libsecondlife; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDTaskScriptUpdate @@ -47,4 +47,4 @@ namespace OpenSim.Region.Capabilities /// public int is_script_running; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index d050176..91db060 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDTest @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index bdc8e79..181a465 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [AttributeUsage(AttributeTargets.Class)] public class LLSDType : Attribute @@ -52,4 +52,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 941e70e..67064b0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -26,7 +26,7 @@ * */ -namespace OpenSim.Region.Capabilities +namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDVoiceAccountResponse diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs new file mode 100644 index 0000000..ed41614 --- /dev/null +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -0,0 +1,156 @@ +using System; +using System.Threading; + +namespace OpenSim.Framework.Communications +{ + internal class SimpleAsyncResult : IAsyncResult + { + private readonly AsyncCallback m_callback; + + /// + /// Is process completed? + /// + /// Should really be boolean, but VolatileRead has no boolean method + private byte m_completed; + + /// + /// Did process complete synchroneously? + /// + /// I have a hard time imagining a scenario where this is the case, again, same issue about + /// booleans and VolatileRead as m_completed + /// + private byte m_completedSynchronously; + + private readonly object m_asyncState; + private ManualResetEvent m_waitHandle; + private Exception m_exception; + + internal SimpleAsyncResult(AsyncCallback cb, object state) + { + m_callback = cb; + m_asyncState = state; + m_completed = 0; + m_completedSynchronously = 1; + } + + #region IAsyncResult Members + + public object AsyncState + { + get { return m_asyncState; } + } + + public WaitHandle AsyncWaitHandle + { + get + { + if (m_waitHandle == null) + { + bool done = IsCompleted; + ManualResetEvent mre = new ManualResetEvent(done); + if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) + { + mre.Close(); + } + else + { + if (!done && IsCompleted) + { + m_waitHandle.Set(); + } + } + } + return m_waitHandle; + } + } + + + public bool CompletedSynchronously + { + get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } + } + + + public bool IsCompleted + { + get { return Thread.VolatileRead(ref m_completed) == 1; } + } + + #endregion + + #region class Methods + + internal void SetAsCompleted(bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + + SignalCompletion(); + } + + internal void HandleException(Exception e, bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + m_exception = e; + + SignalCompletion(); + } + + private void SignalCompletion() + { + if (m_waitHandle != null) m_waitHandle.Set(); + + if (m_callback != null) m_callback(this); + } + + public void EndInvoke() + { + // This method assumes that only 1 thread calls EndInvoke + if (!IsCompleted) + { + // If the operation isn't done, wait for it + AsyncWaitHandle.WaitOne(); + AsyncWaitHandle.Close(); + m_waitHandle = null; // Allow early GC + } + + // Operation is done: if an exception occured, throw it + if (m_exception != null) throw m_exception; + } + + #endregion + } + + internal class AsyncResult : SimpleAsyncResult + { + private T m_result = default(T); + + public AsyncResult(AsyncCallback asyncCallback, Object state) : + base(asyncCallback, state) + { + } + + public void SetAsCompleted(T result, bool completedSynchronously) + { + // Save the asynchronous operation's result + m_result = result; + + // Tell the base class that the operation completed + // sucessfully (no exception) + base.SetAsCompleted(completedSynchronously); + } + + public new T EndInvoke() + { + base.EndInvoke(); + return m_result; + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 2b6e0d5..7c243c6 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -28,7 +28,7 @@ using System.Collections.Generic; using libsecondlife; -namespace OpenSim.Framework +namespace OpenSim.Framework.Communications { public interface IUserService { diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index a379253..f7989ab 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -34,7 +34,7 @@ using libsecondlife.StructuredData; using log4net; using Nwc.XmlRpc; -namespace OpenSim.Framework.UserManagement +namespace OpenSim.Framework.Communications { /// /// A temp class to handle login response. @@ -777,4 +777,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 37c0bd8..db4e2ec 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -40,7 +40,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; -namespace OpenSim.Framework.UserManagement +namespace OpenSim.Framework.Communications { public abstract class LoginService { @@ -122,8 +122,8 @@ namespace OpenSim.Framework.UserManagement lastname = (string) requestData["last"]; m_log.InfoFormat( - "[LOGIN BEGIN]: Received login request message from user {0} {1}", - firstname, lastname); + "[LOGIN BEGIN]: Received login request message from user {0} {1}", + firstname, lastname); string clientVersion = "Unknown"; @@ -138,7 +138,7 @@ namespace OpenSim.Framework.UserManagement } m_log.DebugFormat( - "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); + "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); userProfile = GetTheUser(firstname, lastname); if (userProfile == null) @@ -163,8 +163,8 @@ namespace OpenSim.Framework.UserManagement catch (Exception e) { m_log.InfoFormat( - "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", - requestData["web_login_key"], firstname, lastname, e); + "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); return logResponse.CreateFailedResponse(); } @@ -201,8 +201,8 @@ namespace OpenSim.Framework.UserManagement // Reject the login m_log.InfoFormat( - "[LOGIN END]: Notifying user {0} {1} that they are already logged in", - firstname, lastname); + "[LOGIN END]: Notifying user {0} {1} that they are already logged in", + firstname, lastname); return logResponse.CreateAlreadyLoggedInResponse(); } @@ -286,8 +286,8 @@ namespace OpenSim.Framework.UserManagement StatsManager.UserStats.AddSuccessfulLogin(); m_log.DebugFormat( - "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); + "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); return logResponse.ToXmlRpcResponse(); } @@ -516,9 +516,9 @@ namespace OpenSim.Framework.UserManagement statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + - HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + - lastname + - "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + lastname + + "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); //m_log.Info("[WEB]: R:" + redirectURL); returnactions["int_response_code"] = statuscode; returnactions["str_redirect_location"] = redirectURL; @@ -677,7 +677,7 @@ namespace OpenSim.Framework.UserManagement //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); return passwordSuccess; } @@ -792,4 +792,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs new file mode 100644 index 0000000..91284e8 --- /dev/null +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -0,0 +1,368 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Web; +using log4net; + +namespace OpenSim.Framework.Communications +{ + /// + /// Implementation of a generic REST client + /// + /// + /// This class is a generic implementation of a REST (Representational State Transfer) web service. This + /// class is designed to execute both synchroneously and asynchroneously. + /// + /// Internally the implementation works as a two stage asynchroneous web-client. + /// When the request is initiated, RestClient will query asynchroneously for for a web-response, + /// sleeping until the initial response is returned by the server. Once the initial response is retrieved + /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response + /// object into a memorystream as a sequence of asynchroneous reads. + /// + /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing + /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be + /// invoked by the caller in either synchroneous mode or asynchroneous mode. + /// + public class RestClient + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string realuri; + + #region member variables + + /// + /// The base Uri of the web-service e.g. http://www.google.com + /// + private string _url; + + /// + /// Path elements of the query + /// + private List _pathElements = new List(); + + /// + /// Parameter elements of the query, e.g. min=34 + /// + private Dictionary _parameterElements = new Dictionary(); + + /// + /// Request method. E.g. GET, POST, PUT or DELETE + /// + private string _method; + + /// + /// Temporary buffer used to store bytes temporarily as they come in from the server + /// + private byte[] _readbuf; + + /// + /// MemoryStream representing the resultiong resource + /// + private Stream _resource; + + /// + /// WebRequest object, held as a member variable + /// + private HttpWebRequest _request; + + /// + /// WebResponse object, held as a member variable, so we can close it + /// + private HttpWebResponse _response; + + /// + /// This flag will help block the main synchroneous method, in case we run in synchroneous mode + /// + public static ManualResetEvent _allDone = new ManualResetEvent(false); + + /// + /// Default time out period + /// + private const int DefaultTimeout = 10*1000; // 10 seconds timeout + + /// + /// Default Buffer size of a block requested from the web-server + /// + private const int BufferSize = 4096; // Read blocks of 4 KB. + + + /// + /// if an exception occours during async processing, we need to save it, so it can be + /// rethrown on the primary thread; + /// + private Exception _asyncException; + + #endregion member variables + + #region constructors + + /// + /// Instantiate a new RestClient + /// + /// Web-service to query, e.g. http://osgrid.org:8003 + public RestClient(string url) + { + _url = url; + _readbuf = new byte[BufferSize]; + _resource = new MemoryStream(); + _request = null; + _response = null; + _lock = new object(); + } + + private object _lock; + + #endregion constructors + + /// + /// Add a path element to the query, e.g. assets + /// + /// path entry + public void AddResourcePath(string element) + { + if (isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length - 1)); + else + _pathElements.Add(element); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + /// Value of the parameter, e.g. 42 + public void AddQueryParameter(string name, string value) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + public void AddQueryParameter(string name) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), null); + } + + /// + /// Web-Request method, e.g. GET, PUT, POST, DELETE + /// + public string RequestMethod + { + get { return _method; } + set { _method = value; } + } + + /// + /// True if string contains a trailing slash '/' + /// + /// string to be examined + /// true if slash is present + private bool isSlashed(string s) + { + return s.Substring(s.Length - 1, 1) == "/"; + } + + /// + /// Build a Uri based on the initial Url, path elements and parameters + /// + /// fully constructed Uri + private Uri buildUri() + { + StringBuilder sb = new StringBuilder(); + sb.Append(_url); + + foreach (string e in _pathElements) + { + sb.Append("/"); + sb.Append(e); + } + + bool firstElement = true; + foreach (KeyValuePair kv in _parameterElements) + { + if (firstElement) + { + sb.Append("?"); + firstElement = false; + } + else + sb.Append("&"); + + sb.Append(kv.Key); + if (kv.Value != null && kv.Value.Length != 0) + { + sb.Append("="); + sb.Append(kv.Value); + } + } + realuri = sb.ToString(); + //m_log.InfoFormat("[REST CLIENT]: RestURL: {0}", realuri); + return new Uri(sb.ToString()); + } + + #region Async communications with server + + /// + /// Async method, invoked when a block of data has been received from the service + /// + /// + private void StreamIsReadyDelegate(IAsyncResult ar) + { + try + { + Stream s = (Stream) ar.AsyncState; + int read = s.EndRead(ar); + + if (read > 0) + { + _resource.Write(_readbuf, 0, read); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + } + else + { + s.Close(); + _allDone.Set(); + } + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + #endregion Async communications with server + + /// + /// Perform synchroneous request + /// + public Stream Request() + { + lock (_lock) + { + _request = (HttpWebRequest) WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "application/xml"; + _request.Timeout = 200000; + _asyncException = null; + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + _response = (HttpWebResponse) _request.GetResponse(); + Stream src = _response.GetResponseStream(); + int length = src.Read(_readbuf, 0, BufferSize); + while (length > 0) + { + _resource.Write(_readbuf, 0, length); + length = src.Read(_readbuf, 0, BufferSize); + } + + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + +// _allDone.WaitOne(); + if (_response != null) + _response.Close(); + if (_asyncException != null) + throw _asyncException; + + if (_resource != null) + { + _resource.Flush(); + _resource.Seek(0, SeekOrigin.Begin); + } + + return _resource; + } + } + + public Stream Request(Stream src) + { + _request = (HttpWebRequest) WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "application/xml"; + _request.Timeout = 900000; + _request.Method = RequestMethod; + _asyncException = null; + _request.ContentLength = src.Length; + + m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); + m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); + src.Seek(0, SeekOrigin.Begin); + m_log.Info("[REST]: Seek is ok"); + Stream dst = _request.GetRequestStream(); + m_log.Info("[REST]: GetRequestStream is ok"); + + byte[] buf = new byte[1024]; + int length = src.Read(buf, 0, 1024); + m_log.Info("[REST]: First Read is ok"); + while (length > 0) + { + dst.Write(buf, 0, length); + length = src.Read(buf, 0, 1024); + } + + _response = (HttpWebResponse) _request.GetResponse(); + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + + return null; + } + + #region Async Invocation + + public IAsyncResult BeginRequest(AsyncCallback callback, object state) + { + /// + /// In case, we are invoked asynchroneously this object will keep track of the state + /// + AsyncResult ar = new AsyncResult(callback, state); + ThreadPool.QueueUserWorkItem(RequestHelper, ar); + return ar; + } + + public Stream EndRequest(IAsyncResult asyncResult) + { + AsyncResult ar = (AsyncResult) asyncResult; + + // Wait for operation to complete, then return result or + // throw exception + return ar.EndInvoke(); + } + + private void RequestHelper(Object asyncResult) + { + // We know that it's really an AsyncResult object + AsyncResult ar = (AsyncResult) asyncResult; + try + { + // Perform the operation; if sucessful set the result + Stream s = Request(); + ar.SetAsCompleted(s, false); + } + catch (Exception e) + { + // If operation fails, set the exception + ar.HandleException(e, false); + } + } + + #endregion Async Invocation + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0f7dc44..e4d8ca2 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -36,7 +36,7 @@ using log4net; using Nwc.XmlRpc; using OpenSim.Framework.Statistics; -namespace OpenSim.Framework.UserManagement +namespace OpenSim.Framework.Communications { /// /// Base class for user management (create, read, etc) @@ -245,7 +245,7 @@ namespace OpenSim.Framework.UserManagement { try { - plugin.Value.RemoveUserFriend(friendlistowner, friend); + plugin.Value.RemoveUserFriend(friendlistowner, friend); } catch (Exception e) { @@ -370,7 +370,7 @@ namespace OpenSim.Framework.UserManagement if ((profile.CurrentAgent.Position.X > 0) && (profile.CurrentAgent.Position.Y > 0) && (profile.CurrentAgent.Position.Z > 0) - ) + ) { // TODO: Right now, currentRegion has not been used in GridServer for requesting region. // TODO: It is only using currentHandle. @@ -564,7 +564,7 @@ namespace OpenSim.Framework.UserManagement catch (Exception e) { m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() - + " via " + plugin.Key + "(" + e.ToString() + ")"); + + " via " + plugin.Key + "(" + e.ToString() + ")"); return false; } } @@ -596,4 +596,4 @@ namespace OpenSim.Framework.UserManagement return false; } } -} +} \ No newline at end of file -- cgit v1.1 From 5da028f6ef904857c52f56db6cb91494a1064a12 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 15:46:46 +0000 Subject: * Removing duplicate files that somehow got undeleted from TortoiseSVN. Fixed. --- .../RestClient/GenericAsyncResult.cs | 183 ---------- .../Communications/RestClient/RestClient.cs | 395 --------------------- 2 files changed, 578 deletions(-) delete mode 100644 OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs delete mode 100644 OpenSim/Framework/Communications/RestClient/RestClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs deleted file mode 100644 index 728e25b..0000000 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Threading; - -namespace OpenSim.Framework.Communications -{ - internal class SimpleAsyncResult : IAsyncResult - { - private readonly AsyncCallback m_callback; - - /// - /// Is process completed? - /// - /// Should really be boolean, but VolatileRead has no boolean method - private byte m_completed; - - /// - /// Did process complete synchroneously? - /// - /// I have a hard time imagining a scenario where this is the case, again, same issue about - /// booleans and VolatileRead as m_completed - /// - private byte m_completedSynchronously; - - private readonly object m_asyncState; - private ManualResetEvent m_waitHandle; - private Exception m_exception; - - internal SimpleAsyncResult(AsyncCallback cb, object state) - { - m_callback = cb; - m_asyncState = state; - m_completed = 0; - m_completedSynchronously = 1; - } - - #region IAsyncResult Members - - public object AsyncState - { - get { return m_asyncState; } - } - - public WaitHandle AsyncWaitHandle - { - get - { - if (m_waitHandle == null) - { - bool done = IsCompleted; - ManualResetEvent mre = new ManualResetEvent(done); - if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) - { - mre.Close(); - } - else - { - if (!done && IsCompleted) - { - m_waitHandle.Set(); - } - } - } - return m_waitHandle; - } - } - - - public bool CompletedSynchronously - { - get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } - } - - - public bool IsCompleted - { - get { return Thread.VolatileRead(ref m_completed) == 1; } - } - - #endregion - - #region class Methods - - internal void SetAsCompleted(bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - - SignalCompletion(); - } - - internal void HandleException(Exception e, bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - m_exception = e; - - SignalCompletion(); - } - - private void SignalCompletion() - { - if (m_waitHandle != null) m_waitHandle.Set(); - - if (m_callback != null) m_callback(this); - } - - public void EndInvoke() - { - // This method assumes that only 1 thread calls EndInvoke - if (!IsCompleted) - { - // If the operation isn't done, wait for it - AsyncWaitHandle.WaitOne(); - AsyncWaitHandle.Close(); - m_waitHandle = null; // Allow early GC - } - - // Operation is done: if an exception occured, throw it - if (m_exception != null) throw m_exception; - } - - #endregion - } - - internal class AsyncResult : SimpleAsyncResult - { - private T m_result = default(T); - - public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) - { - } - - public void SetAsCompleted(T result, bool completedSynchronously) - { - // Save the asynchronous operation's result - m_result = result; - - // Tell the base class that the operation completed - // sucessfully (no exception) - base.SetAsCompleted(completedSynchronously); - } - - public new T EndInvoke() - { - base.EndInvoke(); - return m_result; - } - } -} diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs deleted file mode 100644 index 6877690..0000000 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Web; -using log4net; - -namespace OpenSim.Framework.Communications -{ - /// - /// Implementation of a generic REST client - /// - /// - /// This class is a generic implementation of a REST (Representational State Transfer) web service. This - /// class is designed to execute both synchroneously and asynchroneously. - /// - /// Internally the implementation works as a two stage asynchroneous web-client. - /// When the request is initiated, RestClient will query asynchroneously for for a web-response, - /// sleeping until the initial response is returned by the server. Once the initial response is retrieved - /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response - /// object into a memorystream as a sequence of asynchroneous reads. - /// - /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing - /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be - /// invoked by the caller in either synchroneous mode or asynchroneous mode. - /// - public class RestClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string realuri; - - #region member variables - - /// - /// The base Uri of the web-service e.g. http://www.google.com - /// - private string _url; - - /// - /// Path elements of the query - /// - private List _pathElements = new List(); - - /// - /// Parameter elements of the query, e.g. min=34 - /// - private Dictionary _parameterElements = new Dictionary(); - - /// - /// Request method. E.g. GET, POST, PUT or DELETE - /// - private string _method; - - /// - /// Temporary buffer used to store bytes temporarily as they come in from the server - /// - private byte[] _readbuf; - - /// - /// MemoryStream representing the resultiong resource - /// - private Stream _resource; - - /// - /// WebRequest object, held as a member variable - /// - private HttpWebRequest _request; - - /// - /// WebResponse object, held as a member variable, so we can close it - /// - private HttpWebResponse _response; - - /// - /// This flag will help block the main synchroneous method, in case we run in synchroneous mode - /// - public static ManualResetEvent _allDone = new ManualResetEvent(false); - - /// - /// Default time out period - /// - private const int DefaultTimeout = 10*1000; // 10 seconds timeout - - /// - /// Default Buffer size of a block requested from the web-server - /// - private const int BufferSize = 4096; // Read blocks of 4 KB. - - - /// - /// if an exception occours during async processing, we need to save it, so it can be - /// rethrown on the primary thread; - /// - private Exception _asyncException; - - #endregion member variables - - #region constructors - - /// - /// Instantiate a new RestClient - /// - /// Web-service to query, e.g. http://osgrid.org:8003 - public RestClient(string url) - { - _url = url; - _readbuf = new byte[BufferSize]; - _resource = new MemoryStream(); - _request = null; - _response = null; - _lock = new object(); - } - - private object _lock; - - #endregion constructors - - /// - /// Add a path element to the query, e.g. assets - /// - /// path entry - public void AddResourcePath(string element) - { - if (isSlashed(element)) - _pathElements.Add(element.Substring(0, element.Length - 1)); - else - _pathElements.Add(element); - } - - /// - /// Add a query parameter to the Url - /// - /// Name of the parameter, e.g. min - /// Value of the parameter, e.g. 42 - public void AddQueryParameter(string name, string value) - { - _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); - } - - /// - /// Add a query parameter to the Url - /// - /// Name of the parameter, e.g. min - public void AddQueryParameter(string name) - { - _parameterElements.Add(HttpUtility.UrlEncode(name), null); - } - - /// - /// Web-Request method, e.g. GET, PUT, POST, DELETE - /// - public string RequestMethod - { - get { return _method; } - set { _method = value; } - } - - /// - /// True if string contains a trailing slash '/' - /// - /// string to be examined - /// true if slash is present - private bool isSlashed(string s) - { - return s.Substring(s.Length - 1, 1) == "/"; - } - - /// - /// Build a Uri based on the initial Url, path elements and parameters - /// - /// fully constructed Uri - private Uri buildUri() - { - StringBuilder sb = new StringBuilder(); - sb.Append(_url); - - foreach (string e in _pathElements) - { - sb.Append("/"); - sb.Append(e); - } - - bool firstElement = true; - foreach (KeyValuePair kv in _parameterElements) - { - if (firstElement) - { - sb.Append("?"); - firstElement = false; - } - else - sb.Append("&"); - - sb.Append(kv.Key); - if (kv.Value != null && kv.Value.Length != 0) - { - sb.Append("="); - sb.Append(kv.Value); - } - } - realuri = sb.ToString(); - //m_log.InfoFormat("[REST CLIENT]: RestURL: {0}", realuri); - return new Uri(sb.ToString()); - } - - #region Async communications with server - - /// - /// Async method, invoked when a block of data has been received from the service - /// - /// - private void StreamIsReadyDelegate(IAsyncResult ar) - { - try - { - Stream s = (Stream) ar.AsyncState; - int read = s.EndRead(ar); - - if (read > 0) - { - _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = - s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - } - else - { - s.Close(); - _allDone.Set(); - } - } - catch (Exception e) - { - _allDone.Set(); - _asyncException = e; - } - } - - #endregion Async communications with server - - /// - /// Perform synchroneous request - /// - public Stream Request() - { - lock (_lock) - { - _request = (HttpWebRequest) WebRequest.Create(buildUri()); - _request.KeepAlive = false; - _request.ContentType = "application/xml"; - _request.Timeout = 200000; - _asyncException = null; - -// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse) _request.GetResponse(); - Stream src = _response.GetResponseStream(); - int length = src.Read(_readbuf, 0, BufferSize); - while (length > 0) - { - _resource.Write(_readbuf, 0, length); - length = src.Read(_readbuf, 0, BufferSize); - } - - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - -// _allDone.WaitOne(); - if (_response != null) - _response.Close(); - if (_asyncException != null) - throw _asyncException; - - if (_resource != null) - { - _resource.Flush(); - _resource.Seek(0, SeekOrigin.Begin); - } - - return _resource; - } - } - - public Stream Request(Stream src) - { - _request = (HttpWebRequest) WebRequest.Create(buildUri()); - _request.KeepAlive = false; - _request.ContentType = "application/xml"; - _request.Timeout = 900000; - _request.Method = RequestMethod; - _asyncException = null; - _request.ContentLength = src.Length; - - m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); - m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); - src.Seek(0, SeekOrigin.Begin); - m_log.Info("[REST]: Seek is ok"); - Stream dst = _request.GetRequestStream(); - m_log.Info("[REST]: GetRequestStream is ok"); - - byte[] buf = new byte[1024]; - int length = src.Read(buf, 0, 1024); - m_log.Info("[REST]: First Read is ok"); - while (length > 0) - { - dst.Write(buf, 0, length); - length = src.Read(buf, 0, 1024); - } - - _response = (HttpWebResponse) _request.GetResponse(); - -// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - - return null; - } - - #region Async Invocation - - public IAsyncResult BeginRequest(AsyncCallback callback, object state) - { - /// - /// In case, we are invoked asynchroneously this object will keep track of the state - /// - AsyncResult ar = new AsyncResult(callback, state); - ThreadPool.QueueUserWorkItem(RequestHelper, ar); - return ar; - } - - public Stream EndRequest(IAsyncResult asyncResult) - { - AsyncResult ar = (AsyncResult) asyncResult; - - // Wait for operation to complete, then return result or - // throw exception - return ar.EndInvoke(); - } - - private void RequestHelper(Object asyncResult) - { - // We know that it's really an AsyncResult object - AsyncResult ar = (AsyncResult) asyncResult; - try - { - // Perform the operation; if sucessful set the result - Stream s = Request(); - ar.SetAsCompleted(s, false); - } - catch (Exception e) - { - // If operation fails, set the exception - ar.HandleException(e, false); - } - } - - #endregion Async Invocation - } -} -- cgit v1.1 From 01f31fd933bbaec246d2fef5756b7d83be7980e0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 16:23:53 +0000 Subject: * Breaking all the code, breaking all the code..! * Made a bunch more members static, removed some dead code, general cleaning. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 8 ++++---- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 2 +- OpenSim/Framework/Communications/RestClient.cs | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c81ea35..69e0437 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -542,7 +542,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - private int CalculateNumPackets(byte[] data) + private static int CalculateNumPackets(byte[] data) { const uint m_maxPacketSize = 600; int numPackets = 1; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index a39738d..b3852c0 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -241,7 +241,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - private void LoadFromFile(string path, string fileDescription, ConfigAction action) + private static void LoadFromFile(string path, string fileDescription, ConfigAction action) { if (File.Exists(path)) { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index b6ee04d..8061e28 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -378,7 +378,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - protected LLSDMapLayer GetLLSDMapLayerResponse() + protected static LLSDMapLayer GetLLSDMapLayerResponse() { LLSDMapLayer mapLayer = new LLSDMapLayer(); mapLayer.Right = 5000; @@ -758,7 +758,7 @@ namespace OpenSim.Framework.Communications.Capabilities // bw.Close(); // fs.Close(); //} - private void SaveAssetToFile(string filename, byte[] data) + private static void SaveAssetToFile(string filename, byte[] data) { string assetPath = "UserAssets"; if (!Directory.Exists(assetPath)) @@ -840,7 +840,7 @@ namespace OpenSim.Framework.Communications.Capabilities // bw.Close(); // fs.Close(); //} - private void SaveAssetToFile(string filename, byte[] data) + private static void SaveAssetToFile(string filename, byte[] data) { string assetPath = "UserAssets"; if (!Directory.Exists(assetPath)) @@ -945,7 +945,7 @@ namespace OpenSim.Framework.Communications.Capabilities // bw.Close(); // fs.Close(); //} - private void SaveAssetToFile(string filename, byte[] data) + private static void SaveAssetToFile(string filename, byte[] data) { string assetPath = "UserAssets"; if (!Directory.Exists(assetPath)) diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index f7989ab..b6f1f69 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -496,7 +496,7 @@ namespace OpenSim.Framework.Communications return llsdBack; } - private LLSDArray WrapLLSDMap(LLSDMap wrapMe) + private static LLSDArray WrapLLSDMap(LLSDMap wrapMe) { LLSDArray array = new LLSDArray(); array.Add(wrapMe); diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index db4e2ec..fa78a30 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -728,7 +728,7 @@ namespace OpenSim.Framework.Communications return m_welcomeMessage; } - private LoginResponse.BuddyList ConvertFriendListItem(List LFL) + private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) { LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); foreach (FriendListItem fl in LFL) diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 91284e8..b0b7b1e 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -164,7 +164,7 @@ namespace OpenSim.Framework.Communications /// /// string to be examined /// true if slash is present - private bool isSlashed(string s) + private static bool isSlashed(string s) { return s.Substring(s.Length - 1, 1) == "/"; } @@ -196,7 +196,7 @@ namespace OpenSim.Framework.Communications sb.Append("&"); sb.Append(kv.Key); - if (kv.Value != null && kv.Value.Length != 0) + if (!string.IsNullOrEmpty(kv.Value)) { sb.Append("="); sb.Append(kv.Value); -- cgit v1.1 From 70f7672dad3534f215396a578fc13f5628e45310 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 May 2008 18:36:43 +0000 Subject: added in IUserService functions. These don't do anything yet, but the set all compiles together fine, and it provides people an idea of where we are heading. --- OpenSim/Framework/Communications/IUserService.cs | 12 ++++++++++ .../Framework/Communications/UserManagerBase.cs | 28 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 7c243c6..f8d5541 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -108,5 +108,17 @@ namespace OpenSim.Framework.Communications /// /// The agent that we're retreiving the friends Data. List GetUserFriendList(LLUUID friendlistowner); + + /// + /// Get's the User Appearance + UserAppearance GetUserAppearance(LLUUID user); + + void UpdateUserAppearance(LLUUID user, UserAppearance appearance); + + void AddAttachment(LLUUID user, LLUUID attach); + + void RemoveAttachment(LLUUID user, LLUUID attach); + + List GetAttachments(LLUUID user); } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index e4d8ca2..dbbc58f 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -595,5 +595,33 @@ namespace OpenSim.Framework.Communications } return false; } + + /// Appearance + /// TODO: stubs for now to get us to a compiling state gently + public UserAppearance GetUserAppearance(LLUUID user) + { + return new UserAppearance(); + } + + public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) + { + return; + } + + public void AddAttachment(LLUUID user, LLUUID item) + { + return; + } + + public void RemoveAttachment(LLUUID user, LLUUID item) + { + return; + } + + public List GetAttachments(LLUUID user) + { + return new List(); + } + } } \ No newline at end of file -- cgit v1.1 From cc5351ec1b39fa1bcc75379bf74000e5690c137d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 May 2008 20:33:43 +0000 Subject: remove the db4o asset server --- .../Framework/Communications/Cache/AssetServer.cs | 145 --------------------- 1 file changed, 145 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/AssetServer.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs deleted file mode 100644 index 891fa6d..0000000 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -using System.IO; -using System.Reflection; -using Db4objects.Db4o; -using Db4objects.Db4o.Query; -using libsecondlife; -using log4net; - -namespace OpenSim.Framework.Communications.Cache -{ - public class LocalAssetServer : AssetServerBase - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private IObjectContainer db; - - public LocalAssetServer() - { - bool yapfile; - yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); - - db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - m_log.Info("[ASSETS]: Db4 Asset database creation"); - - if (!yapfile) - { - SetUpAssetDatabase(); - } - } - - public void CreateAndCommitAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - db.Commit(); - } - - public override void Close() - { - base.Close(); - - if (db != null) - { - m_log.Info("[ASSETSERVER]: Closing local asset server database"); - db.Close(); - } - } - - protected override AssetBase GetAsset(AssetRequest req) - { - byte[] idata = null; - bool found = false; - AssetStorage foundAsset = null; - IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); - if (result.Count > 0) - { - foundAsset = (AssetStorage) result.Next(); - found = true; - } - - AssetBase asset = new AssetBase(); - if (found) - { - asset.FullID = foundAsset.UUID; - asset.Type = foundAsset.Type; - asset.InvType = foundAsset.Type; - asset.Name = foundAsset.Name; - idata = foundAsset.Data; - asset.Data = idata; - - return asset; - } - else - { - return null; - } - } - - protected override void StoreAsset(AssetBase asset) - { - AssetStorage store = new AssetStorage(); - store.Data = asset.Data; - store.Name = asset.Name; - store.UUID = asset.FullID; - db.Set(store); - - CommitAssets(); - } - - protected override void CommitAssets() - { - db.Commit(); - } - - protected virtual void SetUpAssetDatabase() - { - m_log.Info("[LOCAL ASSET SERVER]: Setting up asset database"); - - base.LoadDefaultAssets(); - } - } - - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; - - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } - } -} -- cgit v1.1 From e41232bac56eb095ba9690aa47259642db94ae50 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 May 2008 20:36:43 +0000 Subject: create pass through of UserManagerBase to plugin calls --- .../Framework/Communications/UserManagerBase.cs | 59 ++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index dbbc58f..0a877f6 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -600,28 +600,79 @@ namespace OpenSim.Framework.Communications /// TODO: stubs for now to get us to a compiling state gently public UserAppearance GetUserAppearance(LLUUID user) { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetUserAppearance(user); + } + catch (Exception e) + { + m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + } + } return new UserAppearance(); } public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) { - return; + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.UpdateUserAppearance(user, appearance); + } + catch (Exception e) + { + m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + } + } } public void AddAttachment(LLUUID user, LLUUID item) { - return; + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.AddAttachment(user, item); + } + catch (Exception e) + { + m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + } + } } public void RemoveAttachment(LLUUID user, LLUUID item) { - return; + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.RemoveAttachment(user, item); + } + catch (Exception e) + { + m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + } + } } public List GetAttachments(LLUUID user) { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAttachments(user); + } + catch (Exception e) + { + m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + } + } return new List(); } - } } \ No newline at end of file -- cgit v1.1 From 1de6cffa28348975a2492ce1e8a85c365df4dfaf Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 20:47:33 +0000 Subject: * Refactor: Remove the unused userID parameter that was being passed into almost every inventory method * This allows lots of redundant inventory methods with only slightly different names to be eliminated. --- .../Communications/Cache/CachedUserInfo.cs | 81 ++++++++++------------ .../Cache/UserProfileCacheService.cs | 13 ++-- .../Framework/Communications/IInventoryServices.cs | 32 ++++----- .../Communications/InventoryServiceBase.cs | 79 +++++++++++---------- 4 files changed, 104 insertions(+), 101 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 7902240..adf01b9 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -166,12 +166,12 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in folders) { - FolderReceive(userID, folder); + FolderReceive(folder); } foreach (InventoryItemBase item in items) { - ItemReceive(userID, item); + ItemReceive(item); } } catch (Exception e) @@ -198,56 +198,53 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) + private void FolderReceive(InventoryFolderImpl folderInfo) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.Name, folderInfo.ID, userID); - - if (userID == UserProfile.ID) + + if (RootFolder == null) { - if (RootFolder == null) + if (folderInfo.ParentID == LLUUID.Zero) { - if (folderInfo.ParentID == LLUUID.Zero) - { - m_rootFolder = folderInfo; - } + m_rootFolder = folderInfo; } - else if (RootFolder.ID == folderInfo.ParentID) + } + else if (RootFolder.ID == folderInfo.ParentID) + { + lock (RootFolder.SubFolders) { - lock (RootFolder.SubFolders) + if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) - { - RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); - } - else - { - AddPendingFolder(folderInfo); - } + RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); } + else + { + AddPendingFolder(folderInfo); + } } - else + } + else + { + InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); + lock (folder.SubFolders) { - InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); - lock (folder.SubFolders) + if (folder != null) { - if (folder != null) + if (!folder.SubFolders.ContainsKey(folderInfo.ID)) { - if (!folder.SubFolders.ContainsKey(folderInfo.ID)) - { - folder.SubFolders.Add(folderInfo.ID, folderInfo); - } - } - else - { - AddPendingFolder(folderInfo); + folder.SubFolders.Add(folderInfo.ID, folderInfo); } } + else + { + AddPendingFolder(folderInfo); + } } - - ResolvePendingFolders(folderInfo); } + + ResolvePendingFolders(folderInfo); } /// @@ -256,15 +253,14 @@ namespace OpenSim.Framework.Communications.Cache /// We're assuming here that items are always received after all the folders have been /// received. /// - /// /// - private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) + private void ItemReceive(InventoryItemBase itemInfo) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); - if ((userID == UserProfile.ID) && (RootFolder != null)) + if (RootFolder != null) { if (itemInfo.Folder == RootFolder.ID) { @@ -305,14 +301,13 @@ namespace OpenSim.Framework.Communications.Cache /// /// Add an item to the user's inventory /// - /// /// public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && HasInventory) + if (HasInventory) { - ItemReceive(userID, itemInfo); - m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + ItemReceive(itemInfo); + m_commsManager.InventoryService.AddItem(itemInfo); } } @@ -325,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache { if ((userID == UserProfile.ID) && HasInventory) { - m_commsManager.InventoryService.UpdateInventoryItem(userID, itemInfo); + m_commsManager.InventoryService.UpdateItem(itemInfo); } } @@ -343,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache result = RootFolder.DeleteItem(item.ID); if (result) { - m_commsManager.InventoryService.DeleteInventoryItem(userID, item); + m_commsManager.InventoryService.DeleteItem(item); } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 392d796..befb6c7 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -181,7 +181,8 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.ParentID = createdFolder.ParentID; createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + + m_commsManager.InventoryService.AddFolder(createdBaseFolder); } else { @@ -207,7 +208,7 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + m_commsManager.InventoryService.AddFolder(createdBaseFolder); } else { @@ -265,7 +266,8 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; baseFolder.Type = (short) type; baseFolder.Version = userProfile.RootFolder.Version; - m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); + + m_commsManager.InventoryService.AddFolder(baseFolder); } else { @@ -299,7 +301,8 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Owner = remoteClient.AgentId; baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); + + m_commsManager.InventoryService.MoveFolder(baseFolder); } else { @@ -544,7 +547,7 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder); + m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); purgedFolder.Purge(); } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index c82c946..5907c38 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -50,46 +50,46 @@ namespace OpenSim.Framework.Communications void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); /// - /// Add a new folder to the given user's inventory + /// Add a new folder to the user's inventory /// - /// /// - void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); + /// true if the folder was successfully added + bool AddFolder(InventoryFolderBase folder); /// /// Move an inventory folder to a new location /// - /// /// A folder containing the details of the new location - void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder); + /// true if the folder was successfully moved + bool MoveFolder(InventoryFolderBase folder); /// /// Purge an inventory folder of all its items and subfolders. /// - /// /// - void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder); + /// true if the folder was successfully purged + bool PurgeFolder(InventoryFolderBase folder); /// - /// Add a new item to the given user's inventory + /// Add a new item to the user's inventory /// - /// /// - void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); + /// true if the item was successfully added + bool AddItem(InventoryItemBase item); /// - /// Update an item in the given user's inventory + /// Update an item in the user's inventory /// - /// /// - void UpdateInventoryItem(LLUUID userID, InventoryItemBase item); + /// true if the item was successfully updated + bool UpdateItem(InventoryItemBase item); /// - /// Delete an item from the given user's inventory + /// Delete an item from the user's inventory /// - /// /// - void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + /// true if the item was successfully deleted + bool DeleteItem(InventoryItemBase item); /// /// Create a new inventory for the given user. diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index dab6a16..1601963 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -106,16 +106,6 @@ namespace OpenSim.Framework.Communications return userFolders; } - - // See IInventoryServices - public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder) - { - // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin - foreach (KeyValuePair plugin in m_plugins) - { - plugin.Value.moveInventoryFolder(folder); - } - } // See IInventoryServices public virtual bool HasInventoryForUser(LLUUID userID) @@ -159,25 +149,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); - - // See IInventoryServices - public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); - - // See IInventoryServices - public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); - - // See IInventoryServices - public abstract void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder); - - // See IInventoryServices - public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); - - // See IInventoryServices - public abstract void UpdateInventoryItem(LLUUID userID, InventoryItemBase item); - - // See IInventoryServices - public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); + public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); #endregion @@ -206,47 +178,74 @@ namespace OpenSim.Framework.Communications #endregion - protected void AddFolder(InventoryFolderBase folder) + public bool AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.Name, folder.ID, folder.ParentID); + "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); foreach (KeyValuePair plugin in m_plugins) { plugin.Value.addInventoryFolder(folder); } + + // FIXME: Should return false on failure + return true; } - protected void MoveFolder(InventoryFolderBase folder) + public bool MoveFolder(InventoryFolderBase folder) { + m_log.DebugFormat( + "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.moveInventoryFolder(folder); } + + // FIXME: Should return false on failure + return true; } - protected void AddItem(InventoryItemBase item) + public bool AddItem(InventoryItemBase item) { + m_log.DebugFormat( + "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.addInventoryItem(item); } + + // FIXME: Should return false on failure + return true; } - protected void UpdateItem(InventoryItemBase item) + public bool UpdateItem(InventoryItemBase item) { + m_log.InfoFormat( + "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.updateInventoryItem(item); } + + // FIXME: Should return false on failure + return true; } - protected void DeleteItem(InventoryItemBase item) + public bool DeleteItem(InventoryItemBase item) { + m_log.InfoFormat( + "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.deleteInventoryItem(item.ID); } + + // FIXME: Should return false on failure + return true; } /// @@ -256,8 +255,11 @@ namespace OpenSim.Framework.Communications /// already know... Needs heavy refactoring. /// /// - protected void PurgeFolder(InventoryFolderBase folder) + public bool PurgeFolder(InventoryFolderBase folder) { + m_log.DebugFormat( + "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); + List subFolders = RequestSubFolders(folder.ID); foreach (InventoryFolderBase subFolder in subFolders) @@ -276,6 +278,9 @@ namespace OpenSim.Framework.Communications { DeleteItem(item); } + + // FIXME: Should return false on failure + return true; } private void AddNewInventorySet(UsersInventory inventory) @@ -283,7 +288,7 @@ namespace OpenSim.Framework.Communications foreach (InventoryFolderBase folder in inventory.Folders.Values) { AddFolder(folder); - } + } } /// -- cgit v1.1 From a81edef2b9b32c6697a46f504af679185aab3ceb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 1 May 2008 21:22:03 +0000 Subject: * Refactor: Remove redundant userID from further up the inventory request chain --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/IInventoryServices.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index adf01b9..aa27abd 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -158,7 +158,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void InventoryReceive(LLUUID userID, ICollection folders, ICollection items) + public void InventoryReceive(ICollection folders, ICollection items) { // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 5907c38..c8a3c85 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -34,7 +34,8 @@ namespace OpenSim.Framework.Communications /// /// Callback used when a user's inventory is received from the inventory service /// - public delegate void InventoryReceiptCallback(LLUUID userId, ICollection folders, ICollection items); + public delegate void InventoryReceiptCallback( + ICollection folders, ICollection items); /// /// Defines all the operations one can perform on a user's inventory. -- cgit v1.1 From 058191e6cc45d546058ba0a0ae18054f7ada3bf6 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 2 May 2008 03:34:06 +0000 Subject: Update svn properties. --- .../Framework/Communications/GenericAsyncResult.cs | 310 ++++----- OpenSim/Framework/Communications/RestClient.cs | 734 ++++++++++----------- 2 files changed, 522 insertions(+), 522 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index ed41614..6c5f5f7 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -1,156 +1,156 @@ -using System; -using System.Threading; - -namespace OpenSim.Framework.Communications -{ - internal class SimpleAsyncResult : IAsyncResult - { - private readonly AsyncCallback m_callback; - - /// - /// Is process completed? - /// - /// Should really be boolean, but VolatileRead has no boolean method - private byte m_completed; - - /// - /// Did process complete synchroneously? - /// - /// I have a hard time imagining a scenario where this is the case, again, same issue about - /// booleans and VolatileRead as m_completed - /// - private byte m_completedSynchronously; - - private readonly object m_asyncState; - private ManualResetEvent m_waitHandle; - private Exception m_exception; - - internal SimpleAsyncResult(AsyncCallback cb, object state) - { - m_callback = cb; - m_asyncState = state; - m_completed = 0; - m_completedSynchronously = 1; - } - - #region IAsyncResult Members - - public object AsyncState - { - get { return m_asyncState; } - } - - public WaitHandle AsyncWaitHandle - { - get - { - if (m_waitHandle == null) - { - bool done = IsCompleted; - ManualResetEvent mre = new ManualResetEvent(done); - if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) - { - mre.Close(); - } - else - { - if (!done && IsCompleted) - { - m_waitHandle.Set(); - } - } - } - return m_waitHandle; - } - } - - - public bool CompletedSynchronously - { - get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } - } - - - public bool IsCompleted - { - get { return Thread.VolatileRead(ref m_completed) == 1; } - } - - #endregion - - #region class Methods - - internal void SetAsCompleted(bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - - SignalCompletion(); - } - - internal void HandleException(Exception e, bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - m_exception = e; - - SignalCompletion(); - } - - private void SignalCompletion() - { - if (m_waitHandle != null) m_waitHandle.Set(); - - if (m_callback != null) m_callback(this); - } - - public void EndInvoke() - { - // This method assumes that only 1 thread calls EndInvoke - if (!IsCompleted) - { - // If the operation isn't done, wait for it - AsyncWaitHandle.WaitOne(); - AsyncWaitHandle.Close(); - m_waitHandle = null; // Allow early GC - } - - // Operation is done: if an exception occured, throw it - if (m_exception != null) throw m_exception; - } - - #endregion - } - - internal class AsyncResult : SimpleAsyncResult - { - private T m_result = default(T); - - public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) - { - } - - public void SetAsCompleted(T result, bool completedSynchronously) - { - // Save the asynchronous operation's result - m_result = result; - - // Tell the base class that the operation completed - // sucessfully (no exception) - base.SetAsCompleted(completedSynchronously); - } - - public new T EndInvoke() - { - base.EndInvoke(); - return m_result; - } - } +using System; +using System.Threading; + +namespace OpenSim.Framework.Communications +{ + internal class SimpleAsyncResult : IAsyncResult + { + private readonly AsyncCallback m_callback; + + /// + /// Is process completed? + /// + /// Should really be boolean, but VolatileRead has no boolean method + private byte m_completed; + + /// + /// Did process complete synchroneously? + /// + /// I have a hard time imagining a scenario where this is the case, again, same issue about + /// booleans and VolatileRead as m_completed + /// + private byte m_completedSynchronously; + + private readonly object m_asyncState; + private ManualResetEvent m_waitHandle; + private Exception m_exception; + + internal SimpleAsyncResult(AsyncCallback cb, object state) + { + m_callback = cb; + m_asyncState = state; + m_completed = 0; + m_completedSynchronously = 1; + } + + #region IAsyncResult Members + + public object AsyncState + { + get { return m_asyncState; } + } + + public WaitHandle AsyncWaitHandle + { + get + { + if (m_waitHandle == null) + { + bool done = IsCompleted; + ManualResetEvent mre = new ManualResetEvent(done); + if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) + { + mre.Close(); + } + else + { + if (!done && IsCompleted) + { + m_waitHandle.Set(); + } + } + } + return m_waitHandle; + } + } + + + public bool CompletedSynchronously + { + get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } + } + + + public bool IsCompleted + { + get { return Thread.VolatileRead(ref m_completed) == 1; } + } + + #endregion + + #region class Methods + + internal void SetAsCompleted(bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + + SignalCompletion(); + } + + internal void HandleException(Exception e, bool completedSynchronously) + { + m_completed = 1; + if (completedSynchronously) + m_completedSynchronously = 1; + else + m_completedSynchronously = 0; + m_exception = e; + + SignalCompletion(); + } + + private void SignalCompletion() + { + if (m_waitHandle != null) m_waitHandle.Set(); + + if (m_callback != null) m_callback(this); + } + + public void EndInvoke() + { + // This method assumes that only 1 thread calls EndInvoke + if (!IsCompleted) + { + // If the operation isn't done, wait for it + AsyncWaitHandle.WaitOne(); + AsyncWaitHandle.Close(); + m_waitHandle = null; // Allow early GC + } + + // Operation is done: if an exception occured, throw it + if (m_exception != null) throw m_exception; + } + + #endregion + } + + internal class AsyncResult : SimpleAsyncResult + { + private T m_result = default(T); + + public AsyncResult(AsyncCallback asyncCallback, Object state) : + base(asyncCallback, state) + { + } + + public void SetAsCompleted(T result, bool completedSynchronously) + { + // Save the asynchronous operation's result + m_result = result; + + // Tell the base class that the operation completed + // sucessfully (no exception) + base.SetAsCompleted(completedSynchronously); + } + + public new T EndInvoke() + { + base.EndInvoke(); + return m_result; + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index b0b7b1e..d0ac833 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -1,368 +1,368 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Web; -using log4net; - -namespace OpenSim.Framework.Communications -{ - /// - /// Implementation of a generic REST client - /// - /// - /// This class is a generic implementation of a REST (Representational State Transfer) web service. This - /// class is designed to execute both synchroneously and asynchroneously. - /// - /// Internally the implementation works as a two stage asynchroneous web-client. - /// When the request is initiated, RestClient will query asynchroneously for for a web-response, - /// sleeping until the initial response is returned by the server. Once the initial response is retrieved - /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response - /// object into a memorystream as a sequence of asynchroneous reads. - /// - /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing - /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be - /// invoked by the caller in either synchroneous mode or asynchroneous mode. - /// - public class RestClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string realuri; - - #region member variables - - /// - /// The base Uri of the web-service e.g. http://www.google.com - /// - private string _url; - - /// - /// Path elements of the query - /// - private List _pathElements = new List(); - - /// - /// Parameter elements of the query, e.g. min=34 - /// - private Dictionary _parameterElements = new Dictionary(); - - /// - /// Request method. E.g. GET, POST, PUT or DELETE - /// - private string _method; - - /// - /// Temporary buffer used to store bytes temporarily as they come in from the server - /// - private byte[] _readbuf; - - /// - /// MemoryStream representing the resultiong resource - /// - private Stream _resource; - - /// - /// WebRequest object, held as a member variable - /// - private HttpWebRequest _request; - - /// - /// WebResponse object, held as a member variable, so we can close it - /// - private HttpWebResponse _response; - - /// - /// This flag will help block the main synchroneous method, in case we run in synchroneous mode - /// - public static ManualResetEvent _allDone = new ManualResetEvent(false); - - /// - /// Default time out period - /// - private const int DefaultTimeout = 10*1000; // 10 seconds timeout - - /// - /// Default Buffer size of a block requested from the web-server - /// - private const int BufferSize = 4096; // Read blocks of 4 KB. - - - /// - /// if an exception occours during async processing, we need to save it, so it can be - /// rethrown on the primary thread; - /// - private Exception _asyncException; - - #endregion member variables - - #region constructors - - /// - /// Instantiate a new RestClient - /// - /// Web-service to query, e.g. http://osgrid.org:8003 - public RestClient(string url) - { - _url = url; - _readbuf = new byte[BufferSize]; - _resource = new MemoryStream(); - _request = null; - _response = null; - _lock = new object(); - } - - private object _lock; - - #endregion constructors - - /// - /// Add a path element to the query, e.g. assets - /// - /// path entry - public void AddResourcePath(string element) - { - if (isSlashed(element)) - _pathElements.Add(element.Substring(0, element.Length - 1)); - else - _pathElements.Add(element); - } - - /// - /// Add a query parameter to the Url - /// - /// Name of the parameter, e.g. min - /// Value of the parameter, e.g. 42 - public void AddQueryParameter(string name, string value) - { - _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); - } - - /// - /// Add a query parameter to the Url - /// - /// Name of the parameter, e.g. min - public void AddQueryParameter(string name) - { - _parameterElements.Add(HttpUtility.UrlEncode(name), null); - } - - /// - /// Web-Request method, e.g. GET, PUT, POST, DELETE - /// - public string RequestMethod - { - get { return _method; } - set { _method = value; } - } - - /// - /// True if string contains a trailing slash '/' - /// - /// string to be examined - /// true if slash is present - private static bool isSlashed(string s) - { - return s.Substring(s.Length - 1, 1) == "/"; - } - - /// - /// Build a Uri based on the initial Url, path elements and parameters - /// - /// fully constructed Uri - private Uri buildUri() - { - StringBuilder sb = new StringBuilder(); - sb.Append(_url); - - foreach (string e in _pathElements) - { - sb.Append("/"); - sb.Append(e); - } - - bool firstElement = true; - foreach (KeyValuePair kv in _parameterElements) - { - if (firstElement) - { - sb.Append("?"); - firstElement = false; - } - else - sb.Append("&"); - - sb.Append(kv.Key); - if (!string.IsNullOrEmpty(kv.Value)) - { - sb.Append("="); - sb.Append(kv.Value); - } - } - realuri = sb.ToString(); - //m_log.InfoFormat("[REST CLIENT]: RestURL: {0}", realuri); - return new Uri(sb.ToString()); - } - - #region Async communications with server - - /// - /// Async method, invoked when a block of data has been received from the service - /// - /// - private void StreamIsReadyDelegate(IAsyncResult ar) - { - try - { - Stream s = (Stream) ar.AsyncState; - int read = s.EndRead(ar); - - if (read > 0) - { - _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = - s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - } - else - { - s.Close(); - _allDone.Set(); - } - } - catch (Exception e) - { - _allDone.Set(); - _asyncException = e; - } - } - - #endregion Async communications with server - - /// - /// Perform synchroneous request - /// - public Stream Request() - { - lock (_lock) - { - _request = (HttpWebRequest) WebRequest.Create(buildUri()); - _request.KeepAlive = false; - _request.ContentType = "application/xml"; - _request.Timeout = 200000; - _asyncException = null; - -// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse) _request.GetResponse(); - Stream src = _response.GetResponseStream(); - int length = src.Read(_readbuf, 0, BufferSize); - while (length > 0) - { - _resource.Write(_readbuf, 0, length); - length = src.Read(_readbuf, 0, BufferSize); - } - - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - -// _allDone.WaitOne(); - if (_response != null) - _response.Close(); - if (_asyncException != null) - throw _asyncException; - - if (_resource != null) - { - _resource.Flush(); - _resource.Seek(0, SeekOrigin.Begin); - } - - return _resource; - } - } - - public Stream Request(Stream src) - { - _request = (HttpWebRequest) WebRequest.Create(buildUri()); - _request.KeepAlive = false; - _request.ContentType = "application/xml"; - _request.Timeout = 900000; - _request.Method = RequestMethod; - _asyncException = null; - _request.ContentLength = src.Length; - - m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); - m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); - src.Seek(0, SeekOrigin.Begin); - m_log.Info("[REST]: Seek is ok"); - Stream dst = _request.GetRequestStream(); - m_log.Info("[REST]: GetRequestStream is ok"); - - byte[] buf = new byte[1024]; - int length = src.Read(buf, 0, 1024); - m_log.Info("[REST]: First Read is ok"); - while (length > 0) - { - dst.Write(buf, 0, length); - length = src.Read(buf, 0, 1024); - } - - _response = (HttpWebResponse) _request.GetResponse(); - -// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - - return null; - } - - #region Async Invocation - - public IAsyncResult BeginRequest(AsyncCallback callback, object state) - { - /// - /// In case, we are invoked asynchroneously this object will keep track of the state - /// - AsyncResult ar = new AsyncResult(callback, state); - ThreadPool.QueueUserWorkItem(RequestHelper, ar); - return ar; - } - - public Stream EndRequest(IAsyncResult asyncResult) - { - AsyncResult ar = (AsyncResult) asyncResult; - - // Wait for operation to complete, then return result or - // throw exception - return ar.EndInvoke(); - } - - private void RequestHelper(Object asyncResult) - { - // We know that it's really an AsyncResult object - AsyncResult ar = (AsyncResult) asyncResult; - try - { - // Perform the operation; if sucessful set the result - Stream s = Request(); - ar.SetAsCompleted(s, false); - } - catch (Exception e) - { - // If operation fails, set the exception - ar.HandleException(e, false); - } - } - - #endregion Async Invocation - } +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Web; +using log4net; + +namespace OpenSim.Framework.Communications +{ + /// + /// Implementation of a generic REST client + /// + /// + /// This class is a generic implementation of a REST (Representational State Transfer) web service. This + /// class is designed to execute both synchroneously and asynchroneously. + /// + /// Internally the implementation works as a two stage asynchroneous web-client. + /// When the request is initiated, RestClient will query asynchroneously for for a web-response, + /// sleeping until the initial response is returned by the server. Once the initial response is retrieved + /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response + /// object into a memorystream as a sequence of asynchroneous reads. + /// + /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing + /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be + /// invoked by the caller in either synchroneous mode or asynchroneous mode. + /// + public class RestClient + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string realuri; + + #region member variables + + /// + /// The base Uri of the web-service e.g. http://www.google.com + /// + private string _url; + + /// + /// Path elements of the query + /// + private List _pathElements = new List(); + + /// + /// Parameter elements of the query, e.g. min=34 + /// + private Dictionary _parameterElements = new Dictionary(); + + /// + /// Request method. E.g. GET, POST, PUT or DELETE + /// + private string _method; + + /// + /// Temporary buffer used to store bytes temporarily as they come in from the server + /// + private byte[] _readbuf; + + /// + /// MemoryStream representing the resultiong resource + /// + private Stream _resource; + + /// + /// WebRequest object, held as a member variable + /// + private HttpWebRequest _request; + + /// + /// WebResponse object, held as a member variable, so we can close it + /// + private HttpWebResponse _response; + + /// + /// This flag will help block the main synchroneous method, in case we run in synchroneous mode + /// + public static ManualResetEvent _allDone = new ManualResetEvent(false); + + /// + /// Default time out period + /// + private const int DefaultTimeout = 10*1000; // 10 seconds timeout + + /// + /// Default Buffer size of a block requested from the web-server + /// + private const int BufferSize = 4096; // Read blocks of 4 KB. + + + /// + /// if an exception occours during async processing, we need to save it, so it can be + /// rethrown on the primary thread; + /// + private Exception _asyncException; + + #endregion member variables + + #region constructors + + /// + /// Instantiate a new RestClient + /// + /// Web-service to query, e.g. http://osgrid.org:8003 + public RestClient(string url) + { + _url = url; + _readbuf = new byte[BufferSize]; + _resource = new MemoryStream(); + _request = null; + _response = null; + _lock = new object(); + } + + private object _lock; + + #endregion constructors + + /// + /// Add a path element to the query, e.g. assets + /// + /// path entry + public void AddResourcePath(string element) + { + if (isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length - 1)); + else + _pathElements.Add(element); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + /// Value of the parameter, e.g. 42 + public void AddQueryParameter(string name, string value) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + } + + /// + /// Add a query parameter to the Url + /// + /// Name of the parameter, e.g. min + public void AddQueryParameter(string name) + { + _parameterElements.Add(HttpUtility.UrlEncode(name), null); + } + + /// + /// Web-Request method, e.g. GET, PUT, POST, DELETE + /// + public string RequestMethod + { + get { return _method; } + set { _method = value; } + } + + /// + /// True if string contains a trailing slash '/' + /// + /// string to be examined + /// true if slash is present + private static bool isSlashed(string s) + { + return s.Substring(s.Length - 1, 1) == "/"; + } + + /// + /// Build a Uri based on the initial Url, path elements and parameters + /// + /// fully constructed Uri + private Uri buildUri() + { + StringBuilder sb = new StringBuilder(); + sb.Append(_url); + + foreach (string e in _pathElements) + { + sb.Append("/"); + sb.Append(e); + } + + bool firstElement = true; + foreach (KeyValuePair kv in _parameterElements) + { + if (firstElement) + { + sb.Append("?"); + firstElement = false; + } + else + sb.Append("&"); + + sb.Append(kv.Key); + if (!string.IsNullOrEmpty(kv.Value)) + { + sb.Append("="); + sb.Append(kv.Value); + } + } + realuri = sb.ToString(); + //m_log.InfoFormat("[REST CLIENT]: RestURL: {0}", realuri); + return new Uri(sb.ToString()); + } + + #region Async communications with server + + /// + /// Async method, invoked when a block of data has been received from the service + /// + /// + private void StreamIsReadyDelegate(IAsyncResult ar) + { + try + { + Stream s = (Stream) ar.AsyncState; + int read = s.EndRead(ar); + + if (read > 0) + { + _resource.Write(_readbuf, 0, read); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + + // TODO! Implement timeout, without killing the server + //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + } + else + { + s.Close(); + _allDone.Set(); + } + } + catch (Exception e) + { + _allDone.Set(); + _asyncException = e; + } + } + + #endregion Async communications with server + + /// + /// Perform synchroneous request + /// + public Stream Request() + { + lock (_lock) + { + _request = (HttpWebRequest) WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "application/xml"; + _request.Timeout = 200000; + _asyncException = null; + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + _response = (HttpWebResponse) _request.GetResponse(); + Stream src = _response.GetResponseStream(); + int length = src.Read(_readbuf, 0, BufferSize); + while (length > 0) + { + _resource.Write(_readbuf, 0, length); + length = src.Read(_readbuf, 0, BufferSize); + } + + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + +// _allDone.WaitOne(); + if (_response != null) + _response.Close(); + if (_asyncException != null) + throw _asyncException; + + if (_resource != null) + { + _resource.Flush(); + _resource.Seek(0, SeekOrigin.Begin); + } + + return _resource; + } + } + + public Stream Request(Stream src) + { + _request = (HttpWebRequest) WebRequest.Create(buildUri()); + _request.KeepAlive = false; + _request.ContentType = "application/xml"; + _request.Timeout = 900000; + _request.Method = RequestMethod; + _asyncException = null; + _request.ContentLength = src.Length; + + m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); + m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); + src.Seek(0, SeekOrigin.Begin); + m_log.Info("[REST]: Seek is ok"); + Stream dst = _request.GetRequestStream(); + m_log.Info("[REST]: GetRequestStream is ok"); + + byte[] buf = new byte[1024]; + int length = src.Read(buf, 0, 1024); + m_log.Info("[REST]: First Read is ok"); + while (length > 0) + { + dst.Write(buf, 0, length); + length = src.Read(buf, 0, 1024); + } + + _response = (HttpWebResponse) _request.GetResponse(); + +// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + + return null; + } + + #region Async Invocation + + public IAsyncResult BeginRequest(AsyncCallback callback, object state) + { + /// + /// In case, we are invoked asynchroneously this object will keep track of the state + /// + AsyncResult ar = new AsyncResult(callback, state); + ThreadPool.QueueUserWorkItem(RequestHelper, ar); + return ar; + } + + public Stream EndRequest(IAsyncResult asyncResult) + { + AsyncResult ar = (AsyncResult) asyncResult; + + // Wait for operation to complete, then return result or + // throw exception + return ar.EndInvoke(); + } + + private void RequestHelper(Object asyncResult) + { + // We know that it's really an AsyncResult object + AsyncResult ar = (AsyncResult) asyncResult; + try + { + // Perform the operation; if sucessful set the result + Stream s = Request(); + ar.SetAsCompleted(s, false); + } + catch (Exception e) + { + // If operation fails, set the exception + ar.HandleException(e, false); + } + } + + #endregion Async Invocation + } } \ No newline at end of file -- cgit v1.1 From 4a8f43244160ca9324cc43a54ba64a51e10268bf Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 2 May 2008 12:35:24 +0000 Subject: minor refactoring. Change getName and GetVersion methods (yes the had different casings) to Name and Version properties for the User stores. --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0a877f6..29bfe22 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -81,7 +81,7 @@ namespace OpenSim.Framework.Communications public void AddPlugin(IUserData plug) { plug.Initialise(); - _plugins.Add(plug.getName(), plug); + _plugins.Add(plug.Name, plug); m_log.Info("[USERSTORAGE]: Added IUserData Interface"); } -- cgit v1.1 From 1b7f1c956c86458bc0cee341ea95ee593be76703 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 2 May 2008 18:59:12 +0000 Subject: plumb in connection string to the user database paths. mysql and mssql just ignore this for now, but it lets us get connect strings to sqlite and nhibernate. --- OpenSim/Framework/Communications/UserManagerBase.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 29bfe22..51a5036 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// /// The filename to the user server plugin DLL - public void AddPlugin(string FileName) + public void AddPlugin(string FileName, string connect) { if (!String.IsNullOrEmpty(FileName)) { @@ -71,16 +71,16 @@ namespace OpenSim.Framework.Communications { IUserData plug = (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - AddPlugin(plug); + AddPlugin(plug, connect); } } } } } - public void AddPlugin(IUserData plug) + public void AddPlugin(IUserData plug, string connect) { - plug.Initialise(); + plug.Initialise(connect); _plugins.Add(plug.Name, plug); m_log.Info("[USERSTORAGE]: Added IUserData Interface"); } -- cgit v1.1 From e8acb49fefc0e567510b4058b6571599a0158b62 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 3 May 2008 15:39:40 +0000 Subject: * For your fragging desire, damage enabled land works, but watch out!, life does not regenerate until you're dead! --- OpenSim/Framework/Communications/CommunicationsManager.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index ee0d164..2813aa0 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -259,6 +259,19 @@ namespace OpenSim.Framework.Communications } } } + public string UUIDNameRequestString(LLUUID uuid) + { + UserProfileData profileData = m_userService.GetUserProfile(uuid); + if (profileData != null) + { + //LLUUID profileId = profileData.ID; + string firstname = profileData.FirstName; + string lastname = profileData.SurName; + + return firstname + " " + lastname; + } + return "(hippos)"; + } public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { -- cgit v1.1 From f5609ba452ba019d2e84643a69c4776c9ec8af66 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 18:01:38 +0000 Subject: * Refactor: remove pointless agentId parameter from CachedUserInfo.AddItem() * Remove old framework asset transactions files which were region modularized --- .../Communications/Cache/AgentAssetTransactions.cs | 558 --------------------- .../Cache/AgentAssetTransactionsManager.cs | 205 -------- .../Communications/Cache/CachedUserInfo.cs | 2 +- 3 files changed, 1 insertion(+), 764 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs delete mode 100644 OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs deleted file mode 100644 index 8ab958a..0000000 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//moved to a module, left here until the module is found to have no problems -/* -using System; -using System.Collections.Generic; -using System.IO; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; - -namespace OpenSim.Framework.Communications.Cache -{ - /// - /// Manage asset transactions for a single agent. - /// - public class AgentAssetTransactions - { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - // Fields - public List CapsUploaders = new List(); - public List NotecardUpdaters = new List(); - public LLUUID UserID; - public Dictionary XferUploaders = new Dictionary(); - public AgentAssetTransactionsManager Manager; - private bool m_dumpAssetsToFile; - - // Methods - public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) - { - UserID = agentID; - Manager = manager; - m_dumpAssetsToFile = dumpAssetsToFile; - } - - public AssetCapsUploader RequestCapsUploader() - { - AssetCapsUploader uploader = new AssetCapsUploader(); - CapsUploaders.Add(uploader); - return uploader; - } - - public NoteCardCapsUpdate RequestNoteCardUpdater() - { - NoteCardCapsUpdate update = new NoteCardCapsUpdate(); - NotecardUpdaters.Add(update); - return update; - } - - public AssetXferUploader RequestXferUploader(LLUUID transactionID) - { - if (!XferUploaders.ContainsKey(transactionID)) - { - AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); - - lock (XferUploaders) - { - XferUploaders.Add(transactionID, uploader); - } - - return uploader; - } - return null; - } - - public void HandleXfer(ulong xferID, uint packetID, byte[] data) - { - AssetXferUploader uploaderFound = null; - - lock (XferUploaders) - { - foreach (AssetXferUploader uploader in XferUploaders.Values) - { - if (uploader.XferID == xferID) - { - if (uploader.HandleXferPacket(xferID, packetID, data)) - { - uploaderFound = uploader; - } - - break; - } - } - - // Remove the uploader once the uploader is complete - //[don't think we can be sure a upload has finished from here, uploads are multi part things] - // [or maybe we can if we do more checking like data lenght checks] - if (uploaderFound != null) - { -// m_log.InfoFormat( -// "[ASSET TRANSACTIONS] Removing asset xfer uploader with transfer id {0}, transaction {1}", -// xferID, uploaderFound.TransactionID); - - // XferUploaders.Remove(uploaderFound.TransactionID); - - //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", XferUploaders.Count); - } - } - } - - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) - { - if (XferUploaders.ContainsKey(transactionID)) - { - XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, - callbackID, description, name, invType, type, - wearableType, nextOwnerMask); - } - } - - public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, - InventoryItemBase item) - { - if (XferUploaders.ContainsKey(transactionID)) - { - XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); - } - } - - /// - /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. - /// - /// - /// The asset if the upload has completed, null if it has not. - public AssetBase GetTransactionAsset(LLUUID transactionID) - { - if (XferUploaders.ContainsKey(transactionID)) - { - AssetXferUploader uploader = XferUploaders[transactionID]; - AssetBase asset = uploader.GetAssetData(); - - lock (XferUploaders) - { - XferUploaders.Remove(transactionID); - } - - return asset; - } - - return null; - } - - // Nested Types - public class AssetXferUploader - { - // Fields - public bool AddToInventory; - public AssetBase Asset; - public LLUUID InventFolder = LLUUID.Zero; - private IClientAPI ourClient; - public LLUUID TransactionID = LLUUID.Zero; - public bool UploadComplete; - public ulong XferID; - private string m_name = String.Empty; - private string m_description = String.Empty; - private sbyte type = 0; - private sbyte invType = 0; - private uint nextPerm = 0; - private bool m_finished = false; - private bool m_createItem = false; - private AgentAssetTransactions m_userTransactions; - private bool m_storeLocal; - private bool m_dumpAssetToFile; - - public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) - { - m_userTransactions = transactions; - m_dumpAssetToFile = dumpAssetToFile; - } - - /// - /// Process transfer data received from the client. - /// - /// - /// - /// - /// True if the transfer is complete, false otherwise or if the xferID was not valid - public bool HandleXferPacket(ulong xferID, uint packetID, byte[] data) - { - if (XferID == xferID) - { - if (Asset.Data.Length > 1) - { - byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; - Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); - Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); - Asset.Data = destinationArray; - } - else - { - byte[] buffer2 = new byte[data.Length - 4]; - Array.Copy(data, 4, buffer2, 0, data.Length - 4); - Asset.Data = buffer2; - } - ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); - newPack.XferID.ID = xferID; - newPack.XferID.Packet = packetID; - ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); - if ((packetID & 0x80000000) != 0) - { - SendCompleteMessage(); - return true; - } - } - - return false; - } - - /// - /// Initialise asset transfer from the client - /// - /// - /// - /// - /// True if the transfer is complete, false otherwise - public bool Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, - bool storeLocal, bool tempFile) - { - ourClient = remoteClient; - Asset = new AssetBase(); - Asset.FullID = assetID; - Asset.InvType = type; - Asset.Type = type; - Asset.Data = data; - Asset.Name = "blank"; - Asset.Description = "empty"; - Asset.Local = storeLocal; - Asset.Temporary = tempFile; - - TransactionID = transaction; - m_storeLocal = storeLocal; - if (Asset.Data.Length > 2) - { - SendCompleteMessage(); - return true; - } - else - { - RequestStartXfer(); - } - - return false; - } - - protected void RequestStartXfer() - { - UploadComplete = false; - XferID = Util.GetNextXferID(); - RequestXferPacket newPack = new RequestXferPacket(); - newPack.XferID.ID = XferID; - newPack.XferID.VFileType = Asset.Type; - newPack.XferID.VFileID = Asset.FullID; - newPack.XferID.FilePath = 0; - newPack.XferID.Filename = new byte[0]; - ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); - } - - protected void SendCompleteMessage() - { - UploadComplete = true; - AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); - newPack.AssetBlock.Type = Asset.Type; - newPack.AssetBlock.Success = true; - newPack.AssetBlock.UUID = Asset.FullID; - ourClient.OutPacket(newPack, ThrottleOutPacketType.Asset); - m_finished = true; - if (m_createItem) - { - DoCreateItem(); - } - else if (m_storeLocal) - { - m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); - } - - // Console.WriteLine("upload complete "+ this.TransactionID); - - if (m_dumpAssetToFile) - { - DateTime now = DateTime.Now; - string filename = - String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, - now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); - SaveAssetToFile(filename, Asset.Data); - } - } - - ///Left this in and commented in case there are unforseen issues - //private void SaveAssetToFile(string filename, byte[] data) - //{ - // FileStream fs = File.Create(filename); - // BinaryWriter bw = new BinaryWriter(fs); - // bw.Write(data); - // bw.Close(); - // fs.Close(); - //} - private void SaveAssetToFile(string filename, byte[] data) - { - string assetPath = "UserAssets"; - if (!Directory.Exists(assetPath)) - { - Directory.CreateDirectory(assetPath); - } - FileStream fs = File.Create(Path.Combine(assetPath, filename)); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); - } - - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) - { - if (TransactionID == transactionID) - { - InventFolder = folderID; - m_name = name; - m_description = description; - this.type = type; - this.invType = invType; - nextPerm = nextOwnerMask; - Asset.Name = name; - Asset.Description = description; - Asset.Type = type; - Asset.InvType = invType; - m_createItem = true; - if (m_finished) - { - DoCreateItem(); - } - } - } - - public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, - InventoryItemBase item) - { - if (TransactionID == transactionID) - { - CachedUserInfo userInfo = - m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails( - remoteClient.AgentId); - - if (userInfo != null) - { - LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); - - AssetBase asset - = m_userTransactions.Manager.CommsManager.AssetCache.GetAsset( - assetID, (item.assetType == (int) AssetType.Texture ? true : false)); - - if (asset == null) - { - asset = m_userTransactions.GetTransactionAsset(transactionID); - } - - if (asset != null && asset.FullID == assetID) - { - asset.Name = item.inventoryName; - asset.Description = item.inventoryDescription; - asset.InvType = (sbyte) item.invType; - asset.Type = (sbyte) item.assetType; - item.assetID = asset.FullID; - - m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); - } - - userInfo.UpdateItem(remoteClient.AgentId, item); - } - } - } - - private void DoCreateItem() - { - //really need to fix this call, if lbsa71 saw this he would die. - m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); - CachedUserInfo userInfo = - m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails(ourClient.AgentId); - if (userInfo != null) - { - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = ourClient.AgentId; - item.creatorsID = ourClient.AgentId; - item.inventoryID = LLUUID.Random(); - item.assetID = Asset.FullID; - item.inventoryDescription = m_description; - item.inventoryName = m_name; - item.assetType = type; - item.invType = invType; - item.parentFolderID = InventFolder; - item.inventoryBasePermissions = 2147483647; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = nextPerm; - - userInfo.AddItem(ourClient.AgentId, item); - ourClient.SendInventoryItemCreateUpdate(item); - } - } - - public AssetBase GetAssetData() - { - if (m_finished) - { - return Asset; - } - return null; - } - } - - #region Nested Classes currently not in use (waiting for them to be enabled) - - public class AssetCapsUploader - { - // Fields - private BaseHttpServer httpListener; - private LLUUID inventoryItemID; - private string m_assetDescription = String.Empty; - private string m_assetName = String.Empty; - private LLUUID m_folderID; - private LLUUID newAssetID; - private bool m_dumpImageToFile; - private string uploaderPath = String.Empty; - - // Events - public event UpLoadedAsset OnUpLoad; - - // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, - LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) - { - m_assetName = assetName; - m_assetDescription = assetDescription; - m_folderID = folderID; - newAssetID = assetID; - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - m_dumpImageToFile = dumpImageToFile; - } - - private void SaveImageToFile(string filename, byte[] data) - { - FileStream output = File.Create(filename); - BinaryWriter writer = new BinaryWriter(output); - writer.Write(data); - writer.Close(); - output.Close(); - } - - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inventoryItemID = this.inventoryItemID; - string text = String.Empty; - LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = newAssetID.ToString(); - complete.new_inventory_item = inventoryItemID; - complete.state = "complete"; - text = LLSDHelpers.SerialiseLLSDReply(complete); - httpListener.RemoveStreamHandler("POST", uploaderPath); - if (m_dumpImageToFile) - { - SaveImageToFile(m_assetName + ".jp2", data); - } - if (OnUpLoad != null) - { - OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, String.Empty, String.Empty); - } - return text; - } - } - - public class NoteCardCapsUpdate - { - // Fields - private BaseHttpServer httpListener; - private LLUUID inventoryItemID; - private string m_assetName = String.Empty; - private LLUUID newAssetID; - private bool SaveImages = false; - private string uploaderPath = String.Empty; - - // Events - public event UpLoadedAsset OnUpLoad; - - // Methods - public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) - { - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - newAssetID = LLUUID.Random(); - } - - private void SaveImageToFile(string filename, byte[] data) - { - FileStream output = File.Create(filename); - BinaryWriter writer = new BinaryWriter(output); - writer.Write(data); - writer.Close(); - output.Close(); - } - - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inventoryItemID = this.inventoryItemID; - string text = String.Empty; - LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = newAssetID.ToString(); - complete.new_inventory_item = inventoryItemID; - complete.state = "complete"; - text = LLSDHelpers.SerialiseLLSDReply(complete); - httpListener.RemoveStreamHandler("POST", uploaderPath); - if (SaveImages) - { - SaveImageToFile(m_assetName + "notecard.txt", data); - } - if (OnUpLoad != null) - { - OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, String.Empty, String.Empty); - } - return text; - } - } - - #endregion - } -} -*/ diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs deleted file mode 100644 index e9d042d..0000000 --- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//moved to a module, left here until the module is found to have no problems -/* -using System; -using System.Collections.Generic; - -using libsecondlife; - -namespace OpenSim.Framework.Communications.Cache -{ - /// - /// Provider handlers for processing asset transactions originating from the agent. This encompasses - /// clothing creation and update as well as asset uploads. - /// - public class AgentAssetTransactionsManager - { - private static readonly log4net.ILog m_log - = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - // Fields - public CommunicationsManager CommsManager; - - /// - /// Each agent has its own singleton collection of transactions - /// - private Dictionary AgentTransactions = - new Dictionary(); - - /// - /// Should we dump uploaded assets to the filesystem? - /// - private bool m_dumpAssetsToFile; - - public AgentAssetTransactionsManager(CommunicationsManager commsManager, bool dumpAssetsToFile) - { - CommsManager = commsManager; - m_dumpAssetsToFile = dumpAssetsToFile; - } - - /// - /// Get the collection of asset transactions for the given user. If one does not already exist, it - /// is created. - /// - /// - /// - private AgentAssetTransactions GetUserTransactions(LLUUID userID) - { - lock (AgentTransactions) - { - if (!AgentTransactions.ContainsKey(userID)) - { - AgentAssetTransactions transactions - = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); - AgentTransactions.Add(userID, transactions); - } - - return AgentTransactions[userID]; - } - } - - /// - /// Remove the given agent asset transactions. This should be called when a client is departing - /// from a scene (and hence won't be making any more transactions here). - /// - /// - public void RemoveAgentAssetTransactions(LLUUID userID) - { - m_log.DebugFormat("Removing agent asset transactions structure for agent {0}", userID); - - lock (AgentTransactions) - { - AgentTransactions.Remove(userID); - } - } - - /// - /// Create an inventory item from data that has been received through a transaction. - /// - /// This is called when new clothing or body parts are created. It may also be called in other - /// situations. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) - { - m_log.DebugFormat( - "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); - - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - - transactions.RequestCreateInventoryItem( - remoteClient, transactionID, folderID, callbackID, description, - name, invType, type, wearableType, nextOwnerMask); - } - - /// - /// Update an inventory item with data that has been received through a transaction. - /// - /// This is called when clothing or body parts are updated (for instance, with new textures or - /// colours). It may also be called in other situations. - /// - /// - /// - /// - public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, - InventoryItemBase item) - { - m_log.DebugFormat( - "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", - item.inventoryName); - - AgentAssetTransactions transactions - = CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId); - - transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); - } - - /// - /// Request that a client (agent) begin an asset transfer. - /// - /// - /// - /// - /// - /// - /// - public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, - byte[] data, bool storeLocal, bool tempFile) - { - // Console.WriteLine("asset upload of " + assetID); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - - AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); - if (uploader != null) - { - // Upload has already compelted uploading... - - if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) - { - //[commenting out as this removal breaks uploads] - /*lock (transactions.XferUploaders) - { - - // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary - transactions.XferUploaders.Remove(uploader.TransactionID); - - //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count); - }*/ - /* } - } - } - - /// - /// Handle asset transfer data packets received in response to the asset upload request in - /// HandleUDPUploadRequest() - /// - /// - /// - /// - /// - public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) - { - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - - transactions.HandleXfer(xferID, packetID, data); - } - } -} -*/ diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index aa27abd..ca9669a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -302,7 +302,7 @@ namespace OpenSim.Framework.Communications.Cache /// Add an item to the user's inventory /// /// - public void AddItem(LLUUID userID, InventoryItemBase itemInfo) + public void AddItem(InventoryItemBase itemInfo) { if (HasInventory) { -- cgit v1.1 From a5dfca8958a28da415719ba880a77138ec205842 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 18:13:32 +0000 Subject: * Refactor: remove redundant userId parameter from UpdateItem() and DeleteItem() * Put warning in remove folder method about non implementation (not that this is used anyway - may be legacy) --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ca9669a..86c24bc 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -316,9 +316,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) + public void UpdateItem(InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && HasInventory) + if (HasInventory) { m_commsManager.InventoryService.UpdateItem(itemInfo); } @@ -330,10 +330,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool DeleteItem(LLUUID userID, InventoryItemBase item) + public bool DeleteItem(InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.ID) && HasInventory) + if (HasInventory) { result = RootFolder.DeleteItem(item.ID); if (result) -- cgit v1.1 From 10875427058e68784ca6f5538a00a0cafd46a72b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 18:57:02 +0000 Subject: * Refactor: Move bulk of CreateFolder from UserProfileCacheService into CachedUserInfo * Remove unused/superseded methods from GridInventoryService --- .../Communications/Cache/CachedUserInfo.cs | 100 ++++++++++++++++++++- .../Cache/UserProfileCacheService.cs | 76 ++-------------- .../Communications/InventoryServiceBase.cs | 12 ++- 3 files changed, 115 insertions(+), 73 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 86c24bc..f55b492 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -28,11 +28,16 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; + using libsecondlife; using log4net; namespace OpenSim.Framework.Communications.Cache { + internal delegate void CreateInventoryFolderDelegate( + string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); + /// /// Stores user profile and inventory data received from backend services for a particular user. /// @@ -297,6 +302,99 @@ namespace OpenSim.Framework.Communications.Cache } } } + + /// + /// Create a folder in this agent's inventory + /// + /// + /// + public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); + + if (HasInventory) + { + if (RootFolder.ID == parentID) + { + InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + + if (createdFolder != null) + { + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.Owner = createdFolder.Owner; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; + + m_commsManager.InventoryService.AddFolder(createdBaseFolder); + + return true; + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + folderName, folderID); + + return false; + } + } + else + { + InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID); + + if (folder != null) + { + InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); + + if (createdFolder != null) + { + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.Owner = createdFolder.Owner; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; + + m_commsManager.InventoryService.AddFolder(createdBaseFolder); + + return true; + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + folderName, folderID); + + return false; + } + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}", + parentID, folderName, folderID); + + return false; + } + } + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"), + new object[] { folderName, folderID, folderType, parentID })); + + return true; + } + + return false; + } /// /// Add an item to the user's inventory @@ -360,7 +458,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Generic inventory request /// - public class InventoryRequest : IInventoryRequest + class InventoryRequest : IInventoryRequest { private Delegate m_delegat; private Object[] m_args; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index befb6c7..f1929c8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -34,8 +34,6 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { - internal delegate void CreateInventoryFolderDelegate( - IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); internal delegate void UpdateInventoryFolderDelegate( @@ -157,80 +155,16 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) - { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); - + { CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) + if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID)) { - if (userProfile.RootFolder.ID == parentID) - { - InventoryFolderImpl createdFolder = - userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_commsManager.InventoryService.AddFolder(createdBaseFolder); - } - else - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists", - folderName, folderID, remoteClient.Name, remoteClient.AgentId); - } - } - else - { - InventoryFolderImpl folder = userProfile.RootFolder.GetDescendentFolder(parentID); - if (folder != null) - { - InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); - - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_commsManager.InventoryService.AddFolder(createdBaseFolder); - } - else - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists", - folderName, folderID, remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2} for user {3} {4}", - parentID, folderName, folderID, remoteClient.Name, remoteClient.AgentId); - } - } - } - else - { - userProfile.AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "HandleCreateInventoryFolder"), - new object[] { remoteClient, folderID, folderType, folderName, parentID })); + m_log.WarnFormat( + "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", + remoteClient.Name, remoteClient.AgentId); } } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 1601963..e81d8c4 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -28,11 +28,16 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; + using libsecondlife; using log4net; namespace OpenSim.Framework.Communications { + /// + /// Abstract base class used by local and grid implementations of an inventory service. + /// public abstract class InventoryServiceBase : IInventoryServices { private static readonly ILog m_log @@ -178,10 +183,11 @@ namespace OpenSim.Framework.Communications #endregion + // See IInventoryServices public bool AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); foreach (KeyValuePair plugin in m_plugins) { @@ -192,6 +198,7 @@ namespace OpenSim.Framework.Communications return true; } + // See IInventoryServices public bool MoveFolder(InventoryFolderBase folder) { m_log.DebugFormat( @@ -206,6 +213,7 @@ namespace OpenSim.Framework.Communications return true; } + // See IInventoryServices public bool AddItem(InventoryItemBase item) { m_log.DebugFormat( @@ -220,6 +228,7 @@ namespace OpenSim.Framework.Communications return true; } + // See IInventoryServices public bool UpdateItem(InventoryItemBase item) { m_log.InfoFormat( @@ -234,6 +243,7 @@ namespace OpenSim.Framework.Communications return true; } + // See IInventoryServices public bool DeleteItem(InventoryItemBase item) { m_log.InfoFormat( -- cgit v1.1 From 45a71bb045b710a4d59c05f87936da5ca03eb9b2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 19:12:17 +0000 Subject: * Make user profile cache service complain if the caller assumes a profile exists when in fact it does not --- .../Cache/UserProfileCacheService.cs | 55 +++++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f1929c8..71da8dc 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -107,7 +107,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.WarnFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userID); + m_log.ErrorFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userID); } } @@ -133,7 +133,8 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Get the details of the given user. + /// Get the details of the given user. A caller should try this method first if it isn't sure that + /// a user profile exists for the given user. /// /// /// null if no user details are found @@ -162,11 +163,17 @@ namespace OpenSim.Framework.Communications.Cache { if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID)) { - m_log.WarnFormat( + m_log.ErrorFormat( "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + } } /// @@ -211,6 +218,12 @@ namespace OpenSim.Framework.Communications.Cache new object[] { remoteClient, folderID, type, name, parentID })); } } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + } } /// @@ -246,6 +259,12 @@ namespace OpenSim.Framework.Communications.Cache new object[] { remoteClient, folderID, parentID })); } } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + } } /// @@ -337,7 +356,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", remoteClient.Name); + m_log.ErrorFormat("[AGENT INVENTORY]: Could not find root folder for user {0}", remoteClient.Name); return; } @@ -345,15 +364,15 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.ErrorFormat( - "[USER CACHE]: HandleFetchInventoryDescendents() could not find user profile {0}, {1}", - remoteClient.Name, remoteClient.AgentId); - + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + return; } // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find folder {0} for user {1}", + m_log.ErrorFormat("[AGENT INVENTORY]: Could not find folder {0} for user {1}", folderID, remoteClient.Name); } @@ -431,23 +450,21 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID.ToString()); + m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID); return null; } } else { - m_log.ErrorFormat( - "[USER CACHE]: HandleFetchInventoryDescendentsCAPS() Could not find user profile for {0}", - agentID); + m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID); return null; } // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists - m_log.ErrorFormat("[INVENTORY CACHE]: " + + m_log.ErrorFormat("[AGENT INVENTORY]: " + "Could not find folder {0} for user {1}", folderID, agentID.ToString()); @@ -494,6 +511,12 @@ namespace OpenSim.Framework.Communications.Cache new object[] { remoteClient, folderID })); } } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + } } public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) @@ -517,6 +540,12 @@ namespace OpenSim.Framework.Communications.Cache } } } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + remoteClient.Name, remoteClient.AgentId); + } } } } -- cgit v1.1 From 45430a5403ec45abceac123a76cb7a0c61475b5e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 19:27:34 +0000 Subject: * Refactor: move UpdateFolder into CachedUserInfo --- .../Communications/Cache/CachedUserInfo.cs | 49 +++++++++++++++++++--- .../Cache/UserProfileCacheService.cs | 23 ++-------- 2 files changed, 48 insertions(+), 24 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f55b492..35c2002 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Communications.Cache { internal delegate void CreateInventoryFolderDelegate( string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); + internal delegate void UpdateInventoryFolderDelegate( + string name, LLUUID folderID, ushort type, LLUUID parentID); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -336,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", folderName, folderID); return false; @@ -367,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", folderName, folderID); return false; @@ -376,7 +378,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}", + "[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}", parentID, folderName, folderID); return false; @@ -392,9 +394,46 @@ namespace OpenSim.Framework.Communications.Cache return true; } - - return false; } + + /// + /// Handle a client request to update the inventory folder + /// + /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE + /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, + /// and needs to be changed. + /// + /// + /// + /// + /// + public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); + + if (HasInventory) + { + InventoryFolderBase baseFolder = new InventoryFolderBase(); + baseFolder.Owner = m_userProfile.ID; + baseFolder.ID = folderID; + baseFolder.Name = name; + baseFolder.ParentID = parentID; + baseFolder.Type = (short) type; + baseFolder.Version = RootFolder.Version; + + m_commsManager.InventoryService.AddFolder(baseFolder); + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"), + new object[] { name, folderID, type, parentID })); + } + + return true; + } /// /// Add an item to the user's inventory diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 71da8dc..f640fb8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -36,8 +36,6 @@ namespace OpenSim.Framework.Communications.Cache { internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); - internal delegate void UpdateInventoryFolderDelegate( - IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); /// /// Holds user profile information and retrieves it from backend services. @@ -198,24 +196,11 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) - { - InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.Owner = remoteClient.AgentId; - baseFolder.ID = folderID; - baseFolder.Name = name; - baseFolder.ParentID = parentID; - baseFolder.Type = (short) type; - baseFolder.Version = userProfile.RootFolder.Version; - - m_commsManager.InventoryService.AddFolder(baseFolder); - } - else + if (!userProfile.UpdateFolder(name, folderID, type, parentID)) { - userProfile.AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "HandleUpdateInventoryFolder"), - new object[] { remoteClient, folderID, type, name, parentID })); + m_log.ErrorFormat( + "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", + remoteClient.Name, remoteClient.AgentId); } } else -- cgit v1.1 From 068163b14bae4f411bb3cf2b34981eb212b7639b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 19:50:49 +0000 Subject: * Refactor: Move MoveFolder() and PurgeFolder() into CachedUserInfo (which arguably should be split) --- .../Communications/Cache/CachedUserInfo.cs | 97 +++++++++++++++++++--- .../Cache/UserProfileCacheService.cs | 65 +++------------ 2 files changed, 100 insertions(+), 62 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 35c2002..ceca1a4 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -35,10 +35,10 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { - internal delegate void CreateInventoryFolderDelegate( - string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); - internal delegate void UpdateInventoryFolderDelegate( - string name, LLUUID folderID, ushort type, LLUUID parentID); + internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); + internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); + internal delegate void PurgeFolderDelegate(LLUUID folderID); + internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -54,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache private readonly CommunicationsManager m_commsManager; public UserProfileData UserProfile { get { return m_userProfile; } } - private UserProfileData m_userProfile; + private readonly UserProfileData m_userProfile; /// /// Has we received the user's inventory from the inventory service? @@ -389,7 +389,7 @@ namespace OpenSim.Framework.Communications.Cache { AddRequest( new InventoryRequest( - Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"), + Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"), new object[] { folderName, folderID, folderType, parentID })); return true; @@ -428,11 +428,88 @@ namespace OpenSim.Framework.Communications.Cache { AddRequest( new InventoryRequest( - Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"), + Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"), new object[] { name, folderID, type, parentID })); } return true; + } + + /// + /// Handle an inventory folder move request from the client. + /// + /// + /// + public bool MoveFolder(LLUUID folderID, LLUUID parentID) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", +// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); + + if (HasInventory) + { + InventoryFolderBase baseFolder = new InventoryFolderBase(); + baseFolder.Owner = m_userProfile.ID; + baseFolder.ID = folderID; + baseFolder.ParentID = parentID; + + m_commsManager.InventoryService.MoveFolder(baseFolder); + + return true; + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"), + new object[] { folderID, parentID })); + + return true; + } + } + + /// + /// This method will delete all the items and folders in the given folder. + /// + /// + public bool PurgeFolder(LLUUID folderID) + { +// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", +// folderID, remoteClient.Name, remoteClient.AgentId); + + if (HasInventory) + { + InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID); + + if (purgedFolder != null) + { + // XXX Nasty - have to create a new object to hold details we already have + InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); + purgedBaseFolder.Owner = purgedFolder.Owner; + purgedBaseFolder.ID = purgedFolder.ID; + purgedBaseFolder.Name = purgedFolder.Name; + purgedBaseFolder.ParentID = purgedFolder.ParentID; + purgedBaseFolder.Type = purgedFolder.Type; + purgedBaseFolder.Version = purgedFolder.Version; + + m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + + purgedFolder.Purge(); + + return true; + } + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"), + new object[] { folderID })); + + return true; + } + + return false; } /// @@ -499,18 +576,18 @@ namespace OpenSim.Framework.Communications.Cache /// class InventoryRequest : IInventoryRequest { - private Delegate m_delegat; + private Delegate m_delegate; private Object[] m_args; internal InventoryRequest(Delegate delegat, Object[] args) { - m_delegat = delegat; + m_delegate = delegat; m_args = args; } public void Execute() { - m_delegat.DynamicInvoke(m_args); + m_delegate.DynamicInvoke(m_args); } } } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f640fb8..0404477 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -33,10 +33,7 @@ using libsecondlife; using log4net; namespace OpenSim.Framework.Communications.Cache -{ - internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); - internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); - +{ /// /// Holds user profile information and retrieves it from backend services. /// @@ -199,7 +196,7 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.UpdateFolder(name, folderID, type, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", + "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } @@ -219,29 +216,15 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", -// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); - CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) - { - InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.Owner = remoteClient.AgentId; - baseFolder.ID = folderID; - baseFolder.ParentID = parentID; - - m_commsManager.InventoryService.MoveFolder(baseFolder); - } - else + if (!userProfile.MoveFolder(folderID, parentID)) { - userProfile.AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(MoveInventoryFolderDelegate), this, "HandleMoveInventoryFolder"), - new object[] { remoteClient, folderID, parentID })); + m_log.ErrorFormat( + "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", + remoteClient.Name, remoteClient.AgentId); } } else @@ -249,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache m_log.ErrorFormat( "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } /// @@ -463,37 +446,15 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) { -// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", -// folderID, remoteClient.Name, remoteClient.AgentId); - CachedUserInfo userProfile; + if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) + if (!userProfile.PurgeFolder(folderID)) { - InventoryFolderImpl purgedFolder = userProfile.RootFolder.GetDescendentFolder(folderID); - if (purgedFolder != null) - { - // XXX Nasty - have to create a new object to hold details we already have - InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); - purgedBaseFolder.Owner = purgedFolder.Owner; - purgedBaseFolder.ID = purgedFolder.ID; - purgedBaseFolder.Name = purgedFolder.Name; - purgedBaseFolder.ParentID = purgedFolder.ParentID; - purgedBaseFolder.Type = purgedFolder.Type; - purgedBaseFolder.Version = purgedFolder.Version; - - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); - - purgedFolder.Purge(); - } - } - else - { - userProfile.AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(PurgeInventoryDescendentsDelegate), this, "HandlePurgeInventoryDescendents"), - new object[] { remoteClient, folderID })); + m_log.ErrorFormat( + "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", + remoteClient.Name, remoteClient.AgentId); } } else @@ -501,7 +462,7 @@ namespace OpenSim.Framework.Communications.Cache m_log.ErrorFormat( "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) -- cgit v1.1 From 688940e8103f2b1f55bb48ebe2566d32f872b8f5 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 22:39:33 +0000 Subject: * Refactor: Renaming item and folder tree search methods to have Find*() prefixes --- .../Communications/Cache/CachedUserInfo.cs | 12 ++++++------ .../Communications/Cache/InventoryFolderImpl.cs | 21 ++++++++++----------- .../Communications/Cache/UserProfileCacheService.cs | 10 +++++----- 3 files changed, 21 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ceca1a4..6a7b6b7 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -35,7 +35,8 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { - internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); + //internal delegate void DeleteItemDelegate( + internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void PurgeFolderDelegate(LLUUID folderID); internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); @@ -234,7 +235,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); + InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); lock (folder.SubFolders) { if (folder != null) @@ -275,7 +276,6 @@ namespace OpenSim.Framework.Communications.Cache { if (!RootFolder.Items.ContainsKey(itemInfo.ID)) { - RootFolder.Items.Add(itemInfo.ID, itemInfo); } else @@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.GetDescendentFolder(itemInfo.Folder); + InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); if (folder != null) { lock (folder.Items) @@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID); + InventoryFolderImpl folder = RootFolder.FindFolder(parentID); if (folder != null) { @@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache if (HasInventory) { - InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID); + InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID); if (purgedFolder != null) { diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index f6accf6..39296eb 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -104,14 +104,12 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Does this folder or any of its subfolders contain the given item? + /// Returns the item if it exists in this folder or any of this folder's subfolders? /// /// - /// - public InventoryItemBase HasItem(LLUUID itemID) + /// null if the item is not found + public InventoryItemBase FindItem(LLUUID itemID) { - InventoryItemBase base2 = null; - lock (Items) { if (Items.ContainsKey(itemID)) @@ -124,15 +122,16 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in SubFolders.Values) { - base2 = folder.HasItem(itemID); - if (base2 != null) + InventoryItemBase item = folder.FindItem(itemID); + + if (item != null) { - break; + return item; } } } - return base2; + return null; } /// @@ -171,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache /// Returns the folder requested if it exists as a descendent of this folder /// /// The requested folder if it exists, null if it does not. - public InventoryFolderImpl GetDescendentFolder(LLUUID folderID) + public InventoryFolderImpl FindFolder(LLUUID folderID) { InventoryFolderImpl returnFolder = null; @@ -185,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in SubFolders.Values) { - returnFolder = folder.GetDescendentFolder(folderID); + returnFolder = folder.FindFolder(folderID); if (returnFolder != null) { break; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 0404477..92b08e5 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -259,7 +259,7 @@ namespace OpenSim.Framework.Communications.Cache return; } - if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) + if ((fold = libraryRoot.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( libraryRoot.Owner, folderID, fold.RequestListOfItems(), @@ -308,7 +308,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) + if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Found folder {0} for client {1}", @@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache return libraryRoot.RequestListOfItems(); } - if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) + if ((fold = libraryRoot.FindFolder(folderID)) != null) { return fold.RequestListOfItems(); } @@ -410,7 +410,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) + if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) { return fold.RequestListOfItems(); } @@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.HasInventory) { - InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); + InventoryItemBase item = userProfile.RootFolder.FindItem(itemID); if (item != null) { remoteClient.SendInventoryItemDetails(ownerID, item); -- cgit v1.1 From 56827894e9fca8d15b84a1f897b24e88c8ab9c29 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 23:23:46 +0000 Subject: * Refactor RemoveItem() --- .../Communications/Cache/CachedUserInfo.cs | 61 ++++++++++++++++++---- .../Communications/Cache/InventoryFolderImpl.cs | 1 + 2 files changed, 51 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6a7b6b7..84e42a3 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -35,7 +35,8 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { - //internal delegate void DeleteItemDelegate( + internal delegate void DeleteItemDelegate(LLUUID itemID); + internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void PurgeFolderDelegate(LLUUID folderID); @@ -306,7 +307,10 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Create a folder in this agent's inventory + /// Create a folder in this agent's inventory. + /// + /// If the inventory service has not yet delievered the inventory + /// for this user then the request will be queued. /// /// /// @@ -399,10 +403,14 @@ namespace OpenSim.Framework.Communications.Cache /// /// Handle a client request to update the inventory folder /// + /// If the inventory service has not yet delievered the inventory + /// for this user then the request will be queued. + /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, /// and needs to be changed. /// + /// /// /// /// @@ -437,7 +445,11 @@ namespace OpenSim.Framework.Communications.Cache /// /// Handle an inventory folder move request from the client. + /// + /// If the inventory service has not yet delievered the inventory + /// for this user then the request will be queued. /// + /// /// /// public bool MoveFolder(LLUUID folderID, LLUUID parentID) @@ -470,7 +482,11 @@ namespace OpenSim.Framework.Communications.Cache /// /// This method will delete all the items and folders in the given folder. + /// + /// If the inventory service has not yet delievered the inventory + /// for this user then the request will be queued. /// + /// /// public bool PurgeFolder(LLUUID folderID) { @@ -540,23 +556,46 @@ namespace OpenSim.Framework.Communications.Cache /// /// Delete an item from the user's inventory + /// + /// If the inventory service has not yet delievered the inventory + /// for this user then the request will be queued. /// - /// - /// - /// - public bool DeleteItem(InventoryItemBase item) + /// + /// + /// true on a successful delete or a if the request is queued. + /// Returns false on an immediate failure + /// + public bool DeleteItem(LLUUID itemID) { - bool result = false; if (HasInventory) { - result = RootFolder.DeleteItem(item.ID); - if (result) + // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though + // really only the item id is required. + InventoryItemBase item = RootFolder.FindItem(itemID); + + if (null == item) { - m_commsManager.InventoryService.DeleteItem(item); + m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID); + + return false; + } + + if (RootFolder.DeleteItem(item.ID)) + { + return m_commsManager.InventoryService.DeleteItem(item); } } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"), + new object[] { itemID })); + + return true; + } - return result; + return false; } } diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 39296eb..af05af3 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -163,6 +163,7 @@ namespace OpenSim.Framework.Communications.Cache } } } + return found; } -- cgit v1.1 From 27a7391d6b3df7d5e3d688ae27fa3ff21dcf421f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 23:33:20 +0000 Subject: * Add ability to defer item actions for AddItem() and DeleteItem(). This won't be useful until we let the client cache (again?) --- .../Communications/Cache/CachedUserInfo.cs | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 84e42a3..6f7c4da 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -35,6 +35,8 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { + internal delegate void AddItemDelegate(InventoryItemBase itemInfo); + internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); internal delegate void DeleteItemDelegate(LLUUID itemID); internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); @@ -532,13 +534,20 @@ namespace OpenSim.Framework.Communications.Cache /// Add an item to the user's inventory /// /// - public void AddItem(InventoryItemBase itemInfo) + public void AddItem(InventoryItemBase item) { if (HasInventory) { - ItemReceive(itemInfo); - m_commsManager.InventoryService.AddItem(itemInfo); + ItemReceive(item); + m_commsManager.InventoryService.AddItem(item); } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(AddItemDelegate), this, "AddItem"), + new object[] { item })); + } } /// @@ -546,12 +555,19 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void UpdateItem(InventoryItemBase itemInfo) + public void UpdateItem(InventoryItemBase item) { if (HasInventory) { - m_commsManager.InventoryService.UpdateItem(itemInfo); + m_commsManager.InventoryService.UpdateItem(item); } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(UpdateItemDelegate), this, "UpdateItem"), + new object[] { item })); + } } /// -- cgit v1.1 From 0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 4 May 2008 00:06:34 +0000 Subject: * Simplify CreateFolder() by folding previous special root case into FindFolder() --- .../Communications/Cache/CachedUserInfo.cs | 89 +++++++--------------- .../Communications/Cache/InventoryFolderImpl.cs | 34 ++++----- 2 files changed, 46 insertions(+), 77 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6f7c4da..5b84958 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -239,6 +239,7 @@ namespace OpenSim.Framework.Communications.Cache else { InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); + lock (folder.SubFolders) { if (folder != null) @@ -323,72 +324,40 @@ namespace OpenSim.Framework.Communications.Cache if (HasInventory) { - if (RootFolder.ID == parentID) + InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); + + if (null == parentFolder) { - InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + m_log.WarnFormat( + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", + folderName, folderID, parentID); + + return false; + } + + InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_commsManager.InventoryService.AddFolder(createdBaseFolder); - - return true; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", - folderName, folderID); - - return false; - } + if (createdFolder != null) + { + InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); + createdBaseFolder.Owner = createdFolder.Owner; + createdBaseFolder.ID = createdFolder.ID; + createdBaseFolder.Name = createdFolder.Name; + createdBaseFolder.ParentID = createdFolder.ParentID; + createdBaseFolder.Type = createdFolder.Type; + createdBaseFolder.Version = createdFolder.Version; + + m_commsManager.InventoryService.AddFolder(createdBaseFolder); + + return true; } else { - InventoryFolderImpl folder = RootFolder.FindFolder(parentID); + m_log.WarnFormat( + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", + folderName, folderID); - if (folder != null) - { - InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); - - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_commsManager.InventoryService.AddFolder(createdBaseFolder); - - return true; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", - folderName, folderID); - - return false; - } - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}", - parentID, folderName, folderID); - - return false; - } + return false; } } else diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index af05af3..c8cec69 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// The newly created subfolder. Returns null if the folder already exists - public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolderImpl CreateChildFolder(LLUUID folderID, string folderName, ushort type) { lock (SubFolders) { @@ -82,6 +82,7 @@ namespace OpenSim.Framework.Communications.Cache subFold.ParentID = this.ID; subFold.Owner = Owner; SubFolders.Add(subFold.ID, subFold); + return subFold; } } @@ -135,7 +136,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Delete an item from the folder. + /// Deletes an item if it exists in this folder or any children /// /// /// @@ -157,6 +158,7 @@ namespace OpenSim.Framework.Communications.Cache foreach (InventoryFolderImpl folder in SubFolders.Values) { found = folder.DeleteItem(itemID); + if (found == true) { break; @@ -168,37 +170,35 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Returns the folder requested if it exists as a descendent of this folder + /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth + /// first. /// /// The requested folder if it exists, null if it does not. public InventoryFolderImpl FindFolder(LLUUID folderID) { - InventoryFolderImpl returnFolder = null; + if (folderID == ID) + { + return this; + } lock (SubFolders) { - if (SubFolders.ContainsKey(folderID)) - { - returnFolder = SubFolders[folderID]; - } - else + foreach (InventoryFolderImpl folder in SubFolders.Values) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + InventoryFolderImpl returnFolder = folder.FindFolder(folderID); + + if (returnFolder != null) { - returnFolder = folder.FindFolder(folderID); - if (returnFolder != null) - { - break; - } + return returnFolder; } } } - return returnFolder; + return null; } /// - /// Return the list of items in this folder + /// Return the list of child items in this folder /// public List RequestListOfItems() { -- cgit v1.1 From 9646258fdfd317d870872f2af24c86fb34a71686 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 4 May 2008 00:53:01 +0000 Subject: * Refactor: Simplify CachedUserInfo.FolderReceive() by removing root folder special case --- .../Communications/Cache/CachedUserInfo.cs | 62 ++++++++++------------ 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 5b84958..18bd994 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -117,7 +117,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Store a folder pending categorization when its parent is received. + /// Store a folder pending arrival of its parent /// /// private void AddPendingFolder(InventoryFolderImpl folder) @@ -138,26 +138,26 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Add any pending folders which are children of parent + /// Add any pending folders which were received before the given folder /// /// /// A /// - private void ResolvePendingFolders(InventoryFolderImpl parent) + private void ResolvePendingFolders(InventoryFolderImpl newFolder) { - if (pendingCategorizationFolders.ContainsKey(parent.ID)) + if (pendingCategorizationFolders.ContainsKey(newFolder.ID)) { - foreach (InventoryFolderImpl folder in pendingCategorizationFolders[parent.ID]) + foreach (InventoryFolderImpl folder in pendingCategorizationFolders[newFolder.ID]) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - lock (parent.SubFolders) + lock (newFolder.SubFolders) { - if (!parent.SubFolders.ContainsKey(folder.ID)) + if (!newFolder.SubFolders.ContainsKey(folder.ID)) { - parent.SubFolders.Add(folder.ID, folder); + newFolder.SubFolders.Add(folder.ID, folder); } } } @@ -209,7 +209,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - private void FolderReceive(InventoryFolderImpl folderInfo) + private void FolderReceive(InventoryFolderImpl newFolder) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", @@ -217,46 +217,42 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder == null) { - if (folderInfo.ParentID == LLUUID.Zero) + if (newFolder.ParentID == LLUUID.Zero) { - m_rootFolder = folderInfo; + m_rootFolder = newFolder; } - } - else if (RootFolder.ID == folderInfo.ParentID) - { - lock (RootFolder.SubFolders) + else { - if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) - { - RootFolder.SubFolders.Add(folderInfo.ID, folderInfo); - } - else - { - AddPendingFolder(folderInfo); - } + AddPendingFolder(newFolder); } } else { - InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); + InventoryFolderImpl parentFolder = RootFolder.FindFolder(newFolder.ParentID); - lock (folder.SubFolders) + if (parentFolder != null) { - if (folder != null) + lock (parentFolder.SubFolders) { - if (!folder.SubFolders.ContainsKey(folderInfo.ID)) + if (!parentFolder.SubFolders.ContainsKey(newFolder.ID)) { - folder.SubFolders.Add(folderInfo.ID, folderInfo); + parentFolder.SubFolders.Add(newFolder.ID, newFolder); + } + else + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", + newFolder.Name, newFolder.ID); } - } - else - { - AddPendingFolder(folderInfo); } } + else + { + AddPendingFolder(newFolder); + } } - ResolvePendingFolders(folderInfo); + ResolvePendingFolders(newFolder); } /// -- cgit v1.1 From 6c62985fd524cf502f8468b4aa303e558aff3b1c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 4 May 2008 01:04:49 +0000 Subject: * Refactor: Do the root case removal thing again, this time in ItemReceive() --- .../Communications/Cache/CachedUserInfo.cs | 47 ++++++---------------- 1 file changed, 13 insertions(+), 34 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 18bd994..03ba1db 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -258,7 +258,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Callback invoked when an item is received from an async request to the inventory service. /// - /// We're assuming here that items are always received after all the folders have been + /// We're assuming here that items are always received after all the folders /// received. /// /// @@ -267,41 +267,20 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat( // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); + InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); - if (RootFolder != null) + if (null == folder) { - if (itemInfo.Folder == RootFolder.ID) - { - lock (RootFolder.Items) - { - if (!RootFolder.Items.ContainsKey(itemInfo.ID)) - { - RootFolder.Items.Add(itemInfo.ID, itemInfo); - } - else - { - RootFolder.Items[itemInfo.ID] = itemInfo; - } - } - } - else - { - InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); - if (folder != null) - { - lock (folder.Items) - { - if (!folder.Items.ContainsKey(itemInfo.ID)) - { - folder.Items.Add(itemInfo.ID, itemInfo); - } - else - { - folder.Items[itemInfo.ID] = itemInfo; - } - } - } - } + m_log.WarnFormat( + "Received item {0} {1} but its folder {2} does not exist", + itemInfo.Name, itemInfo.ID, itemInfo.Folder); + + return; + } + + lock (folder.Items) + { + folder.Items[itemInfo.ID] = itemInfo; } } -- cgit v1.1 From 5ab392d0ee041a78f0d2752c4cc3302855a12abb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 4 May 2008 01:14:21 +0000 Subject: * Refactor: A final root folder special case removal, this time in HandleFetchInventoryDescendents[CAPS] --- .../Cache/UserProfileCacheService.cs | 67 ++++++---------------- 1 file changed, 18 insertions(+), 49 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 92b08e5..176e75e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -250,15 +250,6 @@ namespace OpenSim.Framework.Communications.Cache // XXX We're not handling sortOrder yet! InventoryFolderImpl fold = null; - if (folderID == libraryRoot.ID) - { - remoteClient.SendInventoryFolderDetails( - libraryRoot.Owner, libraryRoot.ID, libraryRoot.RequestListOfItems(), - libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); - - return; - } - if ((fold = libraryRoot.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( @@ -293,33 +284,23 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.HasInventory) { - if (userProfile.RootFolder.ID == folderID) + if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Found root folder {0} for client {1}", -// folderID, remoteClient.AgentId); +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Found folder {0} for client {1}", +// folderID, remoteClient.AgentId); remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), - userProfile.RootFolder.RequestListOfFolders(), - fetchFolders, fetchItems); + remoteClient.AgentId, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } else { - if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) - { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Found folder {0} for client {1}", -// folderID, remoteClient.AgentId); - - remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fetchFolders, fetchItems); - - return; - } + m_log.WarnFormat( + "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", + folderID, remoteClient.Name, remoteClient.AgentId); } } else @@ -363,12 +344,7 @@ namespace OpenSim.Framework.Communications.Cache // XXX We're not handling sortOrder yet! - InventoryFolderImpl fold = null; - if (folderID == libraryRoot.ID) - { - return libraryRoot.RequestListOfItems(); - } - + InventoryFolderImpl fold; if ((fold = libraryRoot.FindFolder(folderID)) != null) { return fold.RequestListOfItems(); @@ -404,17 +380,18 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile.HasInventory) { - if (userProfile.RootFolder.ID == folderID) + if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) { - return userProfile.RootFolder.RequestListOfItems(); + return fold.RequestListOfItems(); } else { - if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) - { - return fold.RequestListOfItems(); - } - } + m_log.WarnFormat( + "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}", + folderID, agentID); + + return null; + } } else { @@ -429,14 +406,6 @@ namespace OpenSim.Framework.Communications.Cache return null; } - - // If we've reached this point then we couldn't find the folder, even though the client thinks - // it exists - m_log.ErrorFormat("[AGENT INVENTORY]: " + - "Could not find folder {0} for user {1}", - folderID, agentID.ToString()); - - return new List(); } /// -- cgit v1.1 From e35e83312df57eeed0b2cbdecd0d608c64611be9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 7 May 2008 15:53:27 +0000 Subject: * Increase number of poll attempts an inventory items request will make under CAPS --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 176e75e..e8cc7d2 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -363,7 +363,7 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.HasInventory) { int attempts = 0; - while (attempts++ < 20) + while (attempts++ < 30) { m_log.DebugFormat( "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", -- cgit v1.1 From ba8ff761c0f807e4963b0b5a2d4e0513b352b485 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 8 May 2008 04:47:38 +0000 Subject: * Reduced sleep durations in a number of files. --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index e8cc7d2..ea27346 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -268,12 +268,13 @@ namespace OpenSim.Framework.Communications.Cache // inventory failure. // // This is a crude way of dealing with that by retrying the lookup. + //BUG: This should be replaced with a async event. if (!userProfile.HasInventory) { int attempts = 5; while (attempts-- > 0) { - Thread.Sleep(3000); + Thread.Sleep(500); if (userProfile.HasInventory) { @@ -369,7 +370,7 @@ namespace OpenSim.Framework.Communications.Cache "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", attempts, folderID, agentID); - Thread.Sleep(3000); + Thread.Sleep(500); if (userProfile.HasInventory) { -- cgit v1.1 From 4fa0cbdfbb9b8c1b60c8f23edb6301962afd8533 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 8 May 2008 05:35:01 +0000 Subject: * You can haz more spring cleaning. * Eventually this codebase will be clean. >_> --- .../Framework/Communications/Cache/AssetCache.cs | 74 ++++------------------ 1 file changed, 14 insertions(+), 60 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 69e0437..fddf01d 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -334,18 +334,9 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { - string temporary = asset.Temporary ? "temporary" : String.Empty; - string type = asset.Type == 0 ? "texture" : "asset"; - - string result = "Ignored"; - if (asset.Type == 0) { - if (Textures.ContainsKey(asset.FullID)) - { - result = "Duplicate ignored."; - } - else + if (!Textures.ContainsKey(asset.FullID)) { TextureImage textur = new TextureImage(asset); Textures.Add(textur.FullID, textur); @@ -353,24 +344,15 @@ namespace OpenSim.Framework.Communications.Cache if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddTexture(textur); - if (asset.Temporary) - { - result = "Added to cache"; - } - else + if (!asset.Temporary) { m_assetServer.StoreAndCommitAsset(asset); - result = "Added to server"; } } } else { - if (Assets.ContainsKey(asset.FullID)) - { - result = "Duplicate ignored."; - } - else + if (!Assets.ContainsKey(asset.FullID)) { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); @@ -378,29 +360,17 @@ namespace OpenSim.Framework.Communications.Cache if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAsset(assetInf); - if (asset.Temporary) - { - result = "Added to cache"; - } - else + if (!asset.Temporary) { m_assetServer.StoreAndCommitAsset(asset); - result = "Added to server"; } } } -#if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); -#endif } // See IAssetReceiver public void AssetReceived(AssetBase asset, bool IsTexture) { -#if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: Received {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID); -#endif - 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 @@ -411,13 +381,7 @@ namespace OpenSim.Framework.Communications.Cache if (IsTexture) { TextureImage image = new TextureImage(asset); - if (Textures.ContainsKey(image.FullID)) - { -#if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID); -#endif - } - else + if (!Textures.ContainsKey(image.FullID)) { Textures.Add(image.FullID, image); @@ -430,13 +394,7 @@ namespace OpenSim.Framework.Communications.Cache else { AssetInfo assetInf = new AssetInfo(asset); - if (Assets.ContainsKey(assetInf.FullID)) - { -#if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID); -#endif - } - else + if (!Assets.ContainsKey(assetInf.FullID)) { Assets.Add(assetInf.FullID, assetInf); @@ -446,18 +404,14 @@ namespace OpenSim.Framework.Communications.Cache } if (RequestedAssets.ContainsKey(assetInf.FullID)) - { - #if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID); - #endif - - AssetRequest req = RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - req.NumPackets = CalculateNumPackets(assetInf.Data); - - RequestedAssets.Remove(assetInf.FullID); - AssetRequests.Add(req); - } + { + AssetRequest req = RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + req.NumPackets = CalculateNumPackets(assetInf.Data); + + RequestedAssets.Remove(assetInf.FullID); + AssetRequests.Add(req); + } } } -- cgit v1.1 From fe8f9a4b25871c62feff6c4f1c0e09d773242ad1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 13:36:08 +0000 Subject: * Restoring some initial inventory lookup polling delays in order to deal with situations seen on osgrid --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index ea27346..3143437 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -274,7 +274,7 @@ namespace OpenSim.Framework.Communications.Cache int attempts = 5; while (attempts-- > 0) { - Thread.Sleep(500); + Thread.Sleep(2000); if (userProfile.HasInventory) { @@ -370,7 +370,7 @@ namespace OpenSim.Framework.Communications.Cache "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", attempts, folderID, agentID); - Thread.Sleep(500); + Thread.Sleep(2000); if (userProfile.HasInventory) { -- cgit v1.1 From 6e2c7da0182c0ee5bf95cb50e95878caa968a77b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 15:51:02 +0000 Subject: * Minor: Insert utility function to format raw xml strings into indented xml for debugging purposes --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 +++- OpenSim/Framework/Communications/Capabilities/Caps.cs | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 3143437..b167682 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -341,7 +341,9 @@ namespace OpenSim.Framework.Communications.Cache public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - //m_log.DebugFormat("[INVENTORY CACHE]: Fetching folders/items from {0} for agent {1}", folderID, agentID); +// m_log.DebugFormat( +// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", +// fetchFolders, fetchItems, folderID, agentID); // XXX We're not handling sortOrder yet! diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 8061e28..ad3d79d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -269,8 +269,9 @@ namespace OpenSim.Framework.Communications.Capabilities { response = "folders" + response + ""; } - - //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request {0}", response); + + //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); + //m_log.Debug(Util.GetFormattedXml(response)); return response; } @@ -960,4 +961,4 @@ namespace OpenSim.Framework.Communications.Capabilities } } } -} \ No newline at end of file +} -- cgit v1.1 From d9dffc4a9a1e561921013aa076eee70faa9b7b92 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 17:23:27 +0000 Subject: From: Michael Osias Stop .net generating ambiguous operator errors when two integers are compared for equality in LSL --- .../Framework/Communications/Capabilities/Caps.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index ad3d79d..d794db3 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -208,7 +208,15 @@ namespace OpenSim.Framework.Communications.Capabilities // FIXME: these all should probably go into the respective region // modules + + /// + /// Processes a fetch inventory request and sends the reply + /// + /// + /// + /// + /// // Request is like: // // folders @@ -255,8 +263,10 @@ namespace OpenSim.Framework.Communications.Capabilities inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); inventoryitemstr = inventoryitemstr.Replace("folders", ""); inventoryitemstr = inventoryitemstr.Replace("", ""); + response += inventoryitemstr; } + if (response.Length == 0) { // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. @@ -276,6 +286,11 @@ namespace OpenSim.Framework.Communications.Capabilities return response; } + /// + /// Construct an LLSD reply packet to a CAPS inventory request + /// + /// + /// private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) { LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); @@ -333,6 +348,11 @@ namespace OpenSim.Framework.Communications.Capabilities return reply; } + /// + /// Convert an internal inventory item object into an LLSD object. + /// + /// + /// private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) { LLSDInventoryItem llsdItem = new LLSDInventoryItem(); -- cgit v1.1 From 3f345bf685a80189c8a33ec1514c356064a6fa70 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 21:33:19 +0000 Subject: * Removing polling delay for non-CAPS inventory fetch if the client has not yet received data from the inventory service * Replaced instead with the system now used by other requests where the fetch request is placed on a queue and service when the data comes in --- .../Communications/Cache/CachedUserInfo.cs | 51 +++++++++++++++++- .../Cache/UserProfileCacheService.cs | 62 ++-------------------- 2 files changed, 54 insertions(+), 59 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 03ba1db..218fd5a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -42,7 +42,10 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void PurgeFolderDelegate(LLUUID folderID); - internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); + internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); + + internal delegate void SendInventoryDescendentsDelegate( + IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -557,6 +560,52 @@ namespace OpenSim.Framework.Communications.Cache return false; } + + /// + /// Send details of the inventory items and/or folders in a given folder to the client. + /// + /// + /// + /// + /// + /// true if the request was queued or successfully processed, false otherwise + public bool SendInventoryDecendents(IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems) + { + if (HasInventory) + { + InventoryFolderImpl folder; + + if ((folder = RootFolder.FindFolder(folderID)) != null) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Found folder {0} for client {1}", +// folderID, remoteClient.AgentId); + + client.SendInventoryFolderDetails( + client.AgentId, folderID, folder.RequestListOfItems(), + folder.RequestListOfFolders(), fetchFolders, fetchItems); + + return true; + } + else + { + m_log.WarnFormat( + "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", + folderID, client.Name, client.AgentId); + + return false; + } + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents"), + new object[] { client, folderID, fetchFolders, fetchItems })); + + return true; + } + } } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b167682..7f911dc 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - // XXX We're not handling sortOrder yet! + // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold = null; if ((fold = libraryRoot.FindFolder(folderID)) != null) @@ -262,68 +262,14 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - // XXX: When a client crosses into a scene, their entire inventory is fetched - // asynchronously. However, if the client is logging on and does not have a cached root - // folder, then the root folder request usually comes in *before* the async completes, leading to - // inventory failure. - // - // This is a crude way of dealing with that by retrying the lookup. - //BUG: This should be replaced with a async event. - if (!userProfile.HasInventory) - { - int attempts = 5; - while (attempts-- > 0) - { - Thread.Sleep(2000); - - if (userProfile.HasInventory) - { - break; - } - } - } - - if (userProfile.HasInventory) - { - if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) - { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Found folder {0} for client {1}", -// folderID, remoteClient.AgentId); - - remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fetchFolders, fetchItems); - - return; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", - folderID, remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.ErrorFormat("[AGENT INVENTORY]: Could not find root folder for user {0}", remoteClient.Name); - - return; - } + userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems); } else { m_log.ErrorFormat( "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - - return; - } - - // If we've reached this point then we couldn't find the folder, even though the client thinks - // it exists - m_log.ErrorFormat("[AGENT INVENTORY]: Could not find folder {0} for user {1}", - folderID, remoteClient.Name); + } } /// @@ -345,7 +291,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", // fetchFolders, fetchItems, folderID, agentID); - // XXX We're not handling sortOrder yet! + // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold; if ((fold = libraryRoot.FindFolder(folderID)) != null) -- cgit v1.1 From 57fea65c825d69dfecd6c9ad9bc08fc87ddde84f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 9 May 2008 21:50:22 +0000 Subject: * Revert caps fetch inventory service back to UDP for now * Linden client 1.19.1.4 appears to be happy using UDP for this request again, and Linden's own servers (1.21) don't appear to be supplying the CAPS version currently * This should for now fix the bug where texture selection in the edit window both shows only already open textures, and later stops subsequent inventory requests from working. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d794db3..399b3b9 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -148,8 +148,20 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); - m_capsHandlers["FetchInventoryDescendents"] = - new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); + + // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and + // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires + // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, + // but when I went on the Linden grid, the + // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, + // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP + // + // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid + // we will be + // able to get the data we need to implement the necessary part of the protocol to fix the issue above. +// m_capsHandlers["FetchInventoryDescendents"] = +// new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); + // m_capsHandlers["FetchInventoryDescendents"] = // new LLSDStreamhandler("POST", // capsBase + m_fetchInventory, -- cgit v1.1 From e8478dadc87586aaed173f60c44bc5ee2722d9dd Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 10 May 2008 10:28:49 +0000 Subject: * Experiment in Zerocoding. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index fddf01d..1414260 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -606,6 +606,7 @@ namespace OpenSim.Framework.Communications.Cache } Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; + Transfer.Header.Zerocoded = true; req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); if (req.NumPackets == 1) @@ -616,6 +617,7 @@ namespace OpenSim.Framework.Communications.Cache TransferPacket.TransferData.TransferID = req.TransferRequestID; TransferPacket.TransferData.Data = req.AssetInf.Data; TransferPacket.TransferData.Status = 1; + TransferPacket.Header.Zerocoded = true; req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); } else @@ -647,7 +649,7 @@ namespace OpenSim.Framework.Communications.Cache { TransferPacket.TransferData.Status = 1; } - + TransferPacket.Header.Zerocoded = true; req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); processedLength += chunkSize; -- cgit v1.1 From d3fb6039cad7b828dec8a1d7aef66aa10e6afdf2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 12 May 2008 16:57:56 +0000 Subject: * If a region running in grid mode fails to login to the grid service, startup will now terminate instead of carrying on (and thus burying the error message) --- OpenSim/Framework/Communications/IGridServices.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 9e34672..39f04c3 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -38,6 +38,7 @@ namespace OpenSim.Framework.Communications /// /// /// + /// Thrown if region registration failed RegionCommsListener RegisterRegion(RegionInfo regionInfos); bool DeregisterRegion(RegionInfo regionInfo); -- cgit v1.1 From 550018f02dbe9d725ff9cdd69f3cf17fac727220 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 13 May 2008 13:36:21 +0000 Subject: * As part of the region registration process, the grid service now requests the status of the region using the region http uri just passed in * If the status cannot be retrieved, then the region startup will terminate. * The aim of this is for earlier detection of situations where the region can send messages out but cannot accept incoming requests (often due to firewall issues) * This is currently an extremely simplistic check which completely trusts whatever http uri is given by the region * This contact may be problematic, though since the user service needs to be able to contact the region http uri, it doesn't seem unreasonable for the grid to have to be able to do so too at this stage * This change will require a prebuild --- OpenSim/Framework/Communications/RestClient.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index d0ac833..4ed62bf 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -15,17 +15,17 @@ namespace OpenSim.Framework.Communications /// /// /// This class is a generic implementation of a REST (Representational State Transfer) web service. This - /// class is designed to execute both synchroneously and asynchroneously. + /// class is designed to execute both synchronously and asynchronously. /// - /// Internally the implementation works as a two stage asynchroneous web-client. - /// When the request is initiated, RestClient will query asynchroneously for for a web-response, + /// Internally the implementation works as a two stage asynchronous web-client. + /// When the request is initiated, RestClient will query asynchronously for for a web-response, /// sleeping until the initial response is returned by the server. Once the initial response is retrieved - /// the second stage of asynchroneous requests will be triggered, in an attempt to read of the response - /// object into a memorystream as a sequence of asynchroneous reads. + /// the second stage of asynchronous requests will be triggered, in an attempt to read of the response + /// object into a memorystream as a sequence of asynchronous reads. /// /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing - /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be - /// invoked by the caller in either synchroneous mode or asynchroneous mode. + /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be + /// invoked by the caller in either synchronous mode or asynchronous modes. /// public class RestClient { @@ -245,7 +245,7 @@ namespace OpenSim.Framework.Communications #endregion Async communications with server /// - /// Perform synchroneous request + /// Perform a synchronous request /// public Stream Request() { @@ -365,4 +365,4 @@ namespace OpenSim.Framework.Communications #endregion Async Invocation } -} \ No newline at end of file +} -- cgit v1.1 From c995d60d37032db3198b8496e186aa7a892dc7a8 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 14 May 2008 05:11:23 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 399b3b9..705f369 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -196,7 +196,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// public void DeregisterHandlers() { - foreach(string capsName in m_capsHandlers.Caps) + foreach (string capsName in m_capsHandlers.Caps) { m_capsHandlers.Remove(capsName); } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 13361c7..e869267 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -37,7 +37,7 @@ using libsecondlife; namespace OpenSim.Framework.Communications.Capabilities { /// - /// Borrowed from (a older version of ) libsl for now, as their new llsd code doesn't work we our decoding code. + /// Borrowed from (a older version of) libsl for now, as their new llsd code doesn't work we our decoding code. /// public static class LLSD { -- cgit v1.1 From 8fe9943293f7e6230538bb1e661e85fa89217da6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 14 May 2008 17:03:25 +0000 Subject: From: Dr Schofield Rename SearializableRegionInfo to SerializableRegionInfo (class was already named correctly) --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index f018dd6..28b0e12 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications void CheckRegion(string address, uint port); bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData, int XMLMethod); - bool RegionUp(SearializableRegionInfo region, ulong regionhandle); + bool RegionUp(SerializableRegionInfo region, ulong regionhandle); bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); -- cgit v1.1 From 1ef37b196c6df054a3a6e19492c9f1d11a30656f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 14 May 2008 22:30:43 +0000 Subject: * Minor: Fussy little wording change on inventory service failure --- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b6f1f69..bccac74 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -248,7 +248,7 @@ namespace OpenSim.Framework.Communications { return GenerateFailureResponse( "key", - "The agent inventory service is not responding. Please notify your login region operator.", + "The avatar inventory service is not responding. Please notify your login region operator.", "false"); } -- cgit v1.1 From 4ff4475d02a26805749897bc62feddcc21b1c5da Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 15 May 2008 18:42:27 +0000 Subject: remove my UserAppearance object, switch all code to use AvatarAppearance instead. --- OpenSim/Framework/Communications/IUserService.cs | 4 ++-- OpenSim/Framework/Communications/UserManagerBase.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index f8d5541..7d71d02 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -111,9 +111,9 @@ namespace OpenSim.Framework.Communications /// /// Get's the User Appearance - UserAppearance GetUserAppearance(LLUUID user); + AvatarAppearance GetUserAppearance(LLUUID user); - void UpdateUserAppearance(LLUUID user, UserAppearance appearance); + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); void AddAttachment(LLUUID user, LLUUID attach); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 51a5036..8e0b75c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -598,7 +598,7 @@ namespace OpenSim.Framework.Communications /// Appearance /// TODO: stubs for now to get us to a compiling state gently - public UserAppearance GetUserAppearance(LLUUID user) + public AvatarAppearance GetUserAppearance(LLUUID user) { foreach (KeyValuePair plugin in _plugins) { @@ -611,10 +611,10 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); } } - return new UserAppearance(); + return new AvatarAppearance(); } - public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) + public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { foreach (KeyValuePair plugin in _plugins) { -- cgit v1.1 From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 16 May 2008 01:22:11 +0000 Subject: Formatting cleanup. --- .../Framework/Communications/Cache/AssetCache.cs | 22 +-- .../Communications/Cache/AssetServerBase.cs | 8 +- .../Communications/Cache/CachedUserInfo.cs | 220 ++++++++++----------- .../Communications/Cache/GridAssetClient.cs | 8 +- .../Communications/Cache/InventoryFolderImpl.cs | 46 ++--- .../Communications/Cache/LibraryRootFolder.cs | 72 +++---- .../Cache/UserProfileCacheService.cs | 78 ++++---- .../Framework/Communications/Capabilities/Caps.cs | 130 ++++++------ .../Communications/Capabilities/CapsHandlers.cs | 16 +- .../Framework/Communications/Capabilities/LLSD.cs | 26 +-- .../Communications/Capabilities/LLSDHelpers.cs | 10 +- .../Capabilities/LLSDInventoryItem.cs | 2 +- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 4 +- .../Capabilities/LLSDStreamHandler.cs | 2 +- .../LLSDTaskInventoryUploadComplete.cs | 2 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 6 +- .../Capabilities/LLSDVoiceAccountResponse.cs | 4 +- .../Communications/CommunicationsManager.cs | 2 +- .../Framework/Communications/GenericAsyncResult.cs | 4 +- .../Framework/Communications/IInventoryServices.cs | 22 +-- OpenSim/Framework/Communications/IUserService.cs | 8 +- .../Communications/InventoryServiceBase.cs | 122 ++++++------ .../Communications/Limit/IRequestLimitStrategy.cs | 10 +- .../Communications/Limit/NullLimitStrategy.cs | 6 +- .../Communications/Limit/RepeatLimitStrategy.cs | 38 ++-- .../Communications/Limit/TimeLimitStrategy.cs | 50 ++--- OpenSim/Framework/Communications/LoginResponse.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 108 +++++----- .../Communications/Properties/AssemblyInfo.cs | 10 +- OpenSim/Framework/Communications/RestClient.cs | 12 +- .../Framework/Communications/UserManagerBase.cs | 26 +-- 31 files changed, 539 insertions(+), 539 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1414260..0669ce9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -40,12 +40,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Manages local cache of assets and their sending to viewers. - /// + /// /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and /// AssetNotFound(), which means they do share the same asset and texture caches. - /// + /// /// TODO Assets in this cache are effectively immortal (they are never disposed off through old age). /// This is not a huge problem at the moment since other memory use usually dwarfs that used by assets /// but it's something to bear in mind. @@ -281,8 +281,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to - /// load it into the cache. - /// + /// load it into the cache. + /// /// XXX We'll keep polling the cache until we get the asset or we exceed /// the allowed number of polls. This isn't a very good way of doing things since a single thread /// is processing inbound packets, so if the asset server is slow, we could block this for up to @@ -431,11 +431,11 @@ namespace OpenSim.Framework.Communications.Cache //making a copy of the list is not ideal //but the old method of locking around this whole block of code was causing a multi-thread lock //between this and the TextureDownloadModule - //while the localAsset thread running this and trying to send a texture to the callback in the + //while the localAsset thread running this and trying to send a texture to the callback in the //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding - // the lock in the texturedownload module) was trying to + // the lock in the texturedownload module) was trying to //request a new asset and hitting a lock in here on the RequestLists. - + List theseRequests = new List(reqList.Requests); reqList.Requests.Clear(); @@ -460,7 +460,7 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); - // Notify requesters for this asset + // Notify requesters for this asset AssetRequestsList reqList = null; lock (RequestLists) { @@ -552,7 +552,7 @@ namespace OpenSim.Framework.Communications.Cache } return; } - //it is in our cache + //it is in our cache AssetInfo asset = Assets[requestID]; // add to the AssetRequests list @@ -679,14 +679,14 @@ namespace OpenSim.Framework.Communications.Cache public byte AssetRequestSource = 2; public byte[] Params = null; //public bool AssetInCache; - //public int TimeRequested; + //public int TimeRequested; public int DiscardLevel = -1; public AssetRequest() { } } - + public class AssetInfo : AssetBase { public AssetInfo() diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 1a7f872..b16512c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications.Cache { public abstract class AssetServerBase : IAssetServer { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IAssetReceiver m_receiver; @@ -47,12 +47,12 @@ namespace OpenSim.Framework.Communications.Cache // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); - + protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); /// - /// This method must be implemented by a subclass to retrieve the asset named in the + /// This method must be implemented by a subclass to retrieve the asset named in the /// AssetRequest. If the asset is not found, null should be returned. /// /// @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache protected abstract AssetBase GetAsset(AssetRequest req); /// - /// Process an asset request. This method will call GetAsset(AssetRequest req) + /// Process an asset request. This method will call GetAsset(AssetRequest req) /// on the subclass. /// /// diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 218fd5a..f40f078 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -36,55 +36,55 @@ using log4net; namespace OpenSim.Framework.Communications.Cache { internal delegate void AddItemDelegate(InventoryItemBase itemInfo); - internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); + internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); internal delegate void DeleteItemDelegate(LLUUID itemID); - + internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); - internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); + internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void PurgeFolderDelegate(LLUUID folderID); internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); - + internal delegate void SendInventoryDescendentsDelegate( IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); - + /// /// Stores user profile and inventory data received from backend services for a particular user. /// public class CachedUserInfo { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + /// /// The comms manager holds references to services (user, grid, inventory, etc.) - /// + /// private readonly CommunicationsManager m_commsManager; - + public UserProfileData UserProfile { get { return m_userProfile; } } - private readonly UserProfileData m_userProfile; + private readonly UserProfileData m_userProfile; /// /// Has we received the user's inventory from the inventory service? /// private bool m_hasInventory; - + /// /// Inventory requests waiting for receipt of this user's inventory from the inventory service. /// - private readonly IList m_pendingRequests = new List(); - + private readonly IList m_pendingRequests = new List(); + /// /// Has this user info object yet received its inventory information from the invetnroy service? /// public bool HasInventory { get { return m_hasInventory; } } - + private InventoryFolderImpl m_rootFolder; - public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } - + public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } + /// /// FIXME: This could be contained within a local variable - it doesn't need to be a field /// - private IDictionary> pendingCategorizationFolders + private IDictionary> pendingCategorizationFolders = new Dictionary>(); /// @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager = commsManager; m_userProfile = userProfile; } - + /// /// This allows a request to be added to be processed once we receive a user's inventory /// from the inventory service. If we already have the inventory, the request @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Communications.Cache } } } - + /// /// Store a folder pending arrival of its parent /// @@ -126,7 +126,7 @@ namespace OpenSim.Framework.Communications.Cache private void AddPendingFolder(InventoryFolderImpl folder) { LLUUID parentFolderId = folder.ParentID; - + if (pendingCategorizationFolders.ContainsKey(parentFolderId)) { pendingCategorizationFolders[parentFolderId].Add(folder); @@ -135,11 +135,11 @@ namespace OpenSim.Framework.Communications.Cache { IList folders = new List(); folders.Add(folder); - + pendingCategorizationFolders[parentFolderId] = folders; } } - + /// /// Add any pending folders which were received before the given folder /// @@ -155,18 +155,18 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat( // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - + lock (newFolder.SubFolders) { if (!newFolder.SubFolders.ContainsKey(folder.ID)) { newFolder.SubFolders.Add(folder.ID, folder); - } + } } } } } - + /// /// Callback invoked when the inventory is received from an async request to the inventory service /// @@ -177,12 +177,12 @@ namespace OpenSim.Framework.Communications.Cache // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed try - { + { foreach (InventoryFolderImpl folder in folders) { FolderReceive(folder); } - + foreach (InventoryItemBase item in items) { ItemReceive(item); @@ -191,15 +191,15 @@ namespace OpenSim.Framework.Communications.Cache catch (Exception e) { m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); - } - + } + // Deal with pending requests lock (m_pendingRequests) { // We're going to change inventory status within the lock to avoid a race condition // where requests are processed after the AddRequest() method has been called. m_hasInventory = true; - + foreach (IInventoryRequest request in m_pendingRequests) { request.Execute(); @@ -215,7 +215,7 @@ namespace OpenSim.Framework.Communications.Cache private void FolderReceive(InventoryFolderImpl newFolder) { // m_log.DebugFormat( -// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", +// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.Name, folderInfo.ID, userID); if (RootFolder == null) @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache else { InventoryFolderImpl parentFolder = RootFolder.FindFolder(newFolder.ParentID); - + if (parentFolder != null) { lock (parentFolder.SubFolders) @@ -252,44 +252,44 @@ namespace OpenSim.Framework.Communications.Cache else { AddPendingFolder(newFolder); - } + } } - + ResolvePendingFolders(newFolder); } /// /// Callback invoked when an item is received from an async request to the inventory service. - /// + /// /// We're assuming here that items are always received after all the folders /// received. /// - /// + /// private void ItemReceive(InventoryItemBase itemInfo) { // m_log.DebugFormat( -// "[INVENTORY CACHE]: Received item {0} {1} for user {2}", +// "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); - + if (null == folder) { m_log.WarnFormat( - "Received item {0} {1} but its folder {2} does not exist", + "Received item {0} {1} but its folder {2} does not exist", itemInfo.Name, itemInfo.ID, itemInfo.Folder); - + return; } - + lock (folder.Items) { folder.Items[itemInfo.ID] = itemInfo; } } - + /// - /// Create a folder in this agent's inventory. - /// + /// Create a folder in this agent's inventory. + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// @@ -299,20 +299,20 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.DebugFormat( // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); - + if (HasInventory) { InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); - + if (null == parentFolder) { m_log.WarnFormat( "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", folderName, folderID, parentID); - + return false; } - + InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); if (createdFolder != null) @@ -324,17 +324,17 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.ParentID = createdFolder.ParentID; createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - + m_commsManager.InventoryService.AddFolder(createdBaseFolder); - + return true; } else { m_log.WarnFormat( - "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", folderName, folderID); - + return false; } } @@ -344,22 +344,22 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"), new object[] { folderName, folderID, folderType, parentID })); - + return true; - } + } } - + /// /// Handle a client request to update the inventory folder - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. - /// + /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, /// and needs to be changed. /// - /// + /// /// /// /// @@ -367,7 +367,7 @@ namespace OpenSim.Framework.Communications.Cache public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID) { // m_log.DebugFormat( -// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); +// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); if (HasInventory) { @@ -378,7 +378,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; baseFolder.Type = (short) type; baseFolder.Version = RootFolder.Version; - + m_commsManager.InventoryService.AddFolder(baseFolder); } else @@ -387,18 +387,18 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"), new object[] { name, folderID, type, parentID })); - } - + } + return true; - } - + } + /// /// Handle an inventory folder move request from the client. - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// - /// + /// /// /// public bool MoveFolder(LLUUID folderID, LLUUID parentID) @@ -413,9 +413,9 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Owner = m_userProfile.ID; baseFolder.ID = folderID; baseFolder.ParentID = parentID; - + m_commsManager.InventoryService.MoveFolder(baseFolder); - + return true; } else @@ -424,30 +424,30 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"), new object[] { folderID, parentID })); - + return true; - } - } - + } + } + /// /// This method will delete all the items and folders in the given folder. - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// - /// + /// /// public bool PurgeFolder(LLUUID folderID) { -// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", +// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", // folderID, remoteClient.Name, remoteClient.AgentId); - + if (HasInventory) { InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID); - + if (purgedFolder != null) - { + { // XXX Nasty - have to create a new object to hold details we already have InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); purgedBaseFolder.Owner = purgedFolder.Owner; @@ -455,12 +455,12 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Name = purgedFolder.Name; purgedBaseFolder.ParentID = purgedFolder.ParentID; purgedBaseFolder.Type = purgedFolder.Type; - purgedBaseFolder.Version = purgedFolder.Version; - - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); - + purgedBaseFolder.Version = purgedFolder.Version; + + m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + purgedFolder.Purge(); - + return true; } } @@ -470,12 +470,12 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"), new object[] { folderID })); - + return true; - } - + } + return false; - } + } /// /// Add an item to the user's inventory @@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(AddItemDelegate), this, "AddItem"), new object[] { item })); - } + } } /// @@ -514,18 +514,18 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(UpdateItemDelegate), this, "UpdateItem"), new object[] { item })); - } + } } /// /// Delete an item from the user's inventory - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// /// /// - /// true on a successful delete or a if the request is queued. + /// true on a successful delete or a if the request is queued. /// Returns false on an immediate failure /// public bool DeleteItem(LLUUID itemID) @@ -535,14 +535,14 @@ namespace OpenSim.Framework.Communications.Cache // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though // really only the item id is required. InventoryItemBase item = RootFolder.FindItem(itemID); - + if (null == item) { m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID); - + return false; } - + if (RootFolder.DeleteItem(item.ID)) { return m_commsManager.InventoryService.DeleteItem(item); @@ -554,13 +554,13 @@ namespace OpenSim.Framework.Communications.Cache new InventoryRequest( Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"), new object[] { itemID })); - + return true; - } - + } + return false; } - + /// /// Send details of the inventory items and/or folders in a given folder to the client. /// @@ -574,13 +574,13 @@ namespace OpenSim.Framework.Communications.Cache if (HasInventory) { InventoryFolderImpl folder; - + if ((folder = RootFolder.FindFolder(folderID)) != null) { // m_log.DebugFormat( -// "[AGENT INVENTORY]: Found folder {0} for client {1}", +// "[AGENT INVENTORY]: Found folder {0} for client {1}", // folderID, remoteClient.AgentId); - + client.SendInventoryFolderDetails( client.AgentId, folderID, folder.RequestListOfItems(), folder.RequestListOfFolders(), fetchFolders, fetchItems); @@ -592,7 +592,7 @@ namespace OpenSim.Framework.Communications.Cache m_log.WarnFormat( "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", folderID, client.Name, client.AgentId); - + return false; } } @@ -604,13 +604,13 @@ namespace OpenSim.Framework.Communications.Cache new object[] { client, folderID, fetchFolders, fetchItems })); return true; - } + } } } - + /// /// Should be implemented by callers which require a callback when the user's inventory is received - /// + /// public interface IInventoryRequest { /// @@ -618,7 +618,7 @@ namespace OpenSim.Framework.Communications.Cache /// void Execute(); } - + /// /// Generic inventory request /// @@ -626,16 +626,16 @@ namespace OpenSim.Framework.Communications.Cache { private Delegate m_delegate; private Object[] m_args; - + internal InventoryRequest(Delegate delegat, Object[] args) { - m_delegate = delegat; + m_delegate = delegat; m_args = args; } - + public void Execute() { m_delegate.DynamicInvoke(m_args); } - } + } } diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index d5b7fea..4b4ef17 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -95,9 +95,9 @@ namespace OpenSim.Framework.Communications.Cache // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); // xs.Serialize(s, asset); // RestClient rc = new RestClient(_assetServerUrl); - - string assetUrl = _assetServerUrl + "/assets/"; - + + string assetUrl = _assetServerUrl + "/assets/"; + //rc.AddResourcePath("assets"); // rc.RequestMethod = "POST"; @@ -105,7 +105,7 @@ namespace OpenSim.Framework.Communications.Cache //m_log.InfoFormat("[ASSET]: Stored {0}", rc); m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); - + RestObjectPoster.BeginPostObject(assetUrl, asset); } catch (Exception e) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index c8cec69..0fbc427 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications.Cache public class InventoryFolderImpl : InventoryFolderBase { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + // Fields public Dictionary Items = new Dictionary(); public Dictionary SubFolders = new Dictionary(); @@ -82,14 +82,14 @@ namespace OpenSim.Framework.Communications.Cache subFold.ParentID = this.ID; subFold.Owner = Owner; SubFolders.Add(subFold.ID, subFold); - + return subFold; } } - + return null; } - + /// /// Delete all the folders and items in this folder. /// @@ -97,9 +97,9 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in SubFolders.Values) { - folder.Purge(); + folder.Purge(); } - + SubFolders.Clear(); Items.Clear(); } @@ -118,20 +118,20 @@ namespace OpenSim.Framework.Communications.Cache return Items[itemID]; } } - + lock (SubFolders) { foreach (InventoryFolderImpl folder in SubFolders.Values) { InventoryItemBase item = folder.FindItem(itemID); - + if (item != null) { return item; } } } - + return null; } @@ -143,7 +143,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID itemID) { bool found = false; - + lock (Items) { if (Items.ContainsKey(itemID)) @@ -152,20 +152,20 @@ namespace OpenSim.Framework.Communications.Cache return true; } } - + lock (SubFolders) { foreach (InventoryFolderImpl folder in SubFolders.Values) { found = folder.DeleteItem(itemID); - + if (found == true) { break; } } } - + return found; } @@ -175,25 +175,25 @@ namespace OpenSim.Framework.Communications.Cache /// /// The requested folder if it exists, null if it does not. public InventoryFolderImpl FindFolder(LLUUID folderID) - { + { if (folderID == ID) { return this; } - + lock (SubFolders) { foreach (InventoryFolderImpl folder in SubFolders.Values) { InventoryFolderImpl returnFolder = folder.FindFolder(folderID); - + if (returnFolder != null) { return returnFolder; } } } - + return null; } @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Communications.Cache public List RequestListOfItems() { List itemList = new List(); - + lock (Items) { foreach (InventoryItemBase item in Items.Values) @@ -211,9 +211,9 @@ namespace OpenSim.Framework.Communications.Cache itemList.Add(item); } } - + //m_log.DebugFormat("[INVENTORY FOLDER IMPL]: Found {0} items", itemList.Count); - + return itemList; } @@ -221,9 +221,9 @@ namespace OpenSim.Framework.Communications.Cache /// Return the list of immediate child folders in this folder. /// public List RequestListOfFolders() - { + { List folderList = new List(); - + lock (SubFolders) { foreach (InventoryFolderBase folder in SubFolders.Values) @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Cache folderList.Add(folder); } } - + return folderList; } } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index b3852c0..ca7eb13 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -45,34 +45,34 @@ namespace OpenSim.Framework.Communications.Cache private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - + /// /// Holds the root library folder and all its descendents. This is really only used during inventory /// setup so that we don't have to repeatedly search the tree of library folders. /// - protected Dictionary libraryFolders + protected Dictionary libraryFolders = new Dictionary(); public LibraryRootFolder() { m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); - + Owner = libOwner; ID = new LLUUID("00000112-000f-0000-0000-000100bba000"); Name = "OpenSim Library"; ParentID = LLUUID.Zero; Type = (short) 8; Version = (ushort) 1; - + libraryFolders.Add(ID, this); - + LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); // CreateLibraryItems(); } /// - /// Hardcoded item creation. Please don't add any more items here - future items should be created + /// Hardcoded item creation. Please don't add any more items here - future items should be created /// in the xml in the bin/inventory folder. /// /// @@ -132,7 +132,7 @@ namespace OpenSim.Framework.Communications.Cache item.NextPermissions = 0x7FFFFFFF; return item; } - + /// /// Use the asset set information at path to load assets /// @@ -142,49 +142,49 @@ namespace OpenSim.Framework.Communications.Cache { m_log.InfoFormat( "[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath); - + LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); } - + /// /// Read a library set from config /// /// protected void ReadLibraryFromConfig(IConfig config) { - string foldersPath + string foldersPath = Path.Combine( Util.inventoryDir(), config.GetString("foldersFile", String.Empty)); - + LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); - - string itemsPath + + string itemsPath = Path.Combine( Util.inventoryDir(), config.GetString("itemsFile", String.Empty)); - + LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); } - + /// /// Read a library inventory folder from a loaded configuration /// /// private void ReadFolderFromConfig(IConfig config) - { + { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - + folderInfo.ID = new LLUUID(config.GetString("folderID", ID.ToString())); - folderInfo.Name = config.GetString("name", "unknown"); + folderInfo.Name = config.GetString("name", "unknown"); folderInfo.ParentID = new LLUUID(config.GetString("parentFolderID", ID.ToString())); folderInfo.Type = (short)config.GetInt("type", 8); - - folderInfo.Owner = libOwner; - folderInfo.Version = 1; - + + folderInfo.Owner = libOwner; + folderInfo.Version = 1; + if (libraryFolders.ContainsKey(folderInfo.ParentID)) - { + { InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; - + libraryFolders.Add(folderInfo.ID, folderInfo); parentFolder.SubFolders.Add(folderInfo.ID, folderInfo); @@ -201,7 +201,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Read a library inventory item metadata from a loaded configuration /// - /// + /// private void ReadItemFromConfig(IConfig config) { InventoryItemBase item = new InventoryItemBase(); @@ -218,11 +218,11 @@ namespace OpenSim.Framework.Communications.Cache item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); - + if (libraryFolders.ContainsKey(item.Folder)) { InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; - + parentFolder.Items.Add(item.ID, item); } else @@ -230,11 +230,11 @@ namespace OpenSim.Framework.Communications.Cache m_log.WarnFormat( "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", item.Name, item.ID, item.Folder); - } + } } - - private delegate void ConfigAction(IConfig config); - + + private delegate void ConfigAction(IConfig config); + /// /// Load the given configuration at a path and perform an action on each Config contained within it /// @@ -242,7 +242,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// private static void LoadFromFile(string path, string fileDescription, ConfigAction action) - { + { if (File.Exists(path)) { try @@ -250,21 +250,21 @@ namespace OpenSim.Framework.Communications.Cache XmlConfigSource source = new XmlConfigSource(path); for (int i = 0; i < source.Configs.Count; i++) - { + { action(source.Configs[i]); } } catch (XmlException e) { m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e); - } + } } else { m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path); - } + } } - + /// /// Looks like a simple getter, but is written like this for some consistency with the other Request /// methods in the superclass diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 7f911dc..fe61406 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -33,7 +33,7 @@ using libsecondlife; using log4net; namespace OpenSim.Framework.Communications.Cache -{ +{ /// /// Holds user profile information and retrieves it from backend services. /// @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache /// The comms manager holds references to services (user, grid, inventory, etc.) /// private readonly CommunicationsManager m_commsManager; - + /// /// Each user has a cached profile. /// @@ -84,8 +84,8 @@ namespace OpenSim.Framework.Communications.Cache } } } - } - + } + /// /// Remove this user's profile cache. /// @@ -103,9 +103,9 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.ErrorFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userID); - } + } } - + return false; } @@ -118,14 +118,14 @@ namespace OpenSim.Framework.Communications.Cache { CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) - { + { m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); } else { m_log.ErrorFormat("[USER CACHE]: RequestInventoryForUser() - user profile for user {0} not found", userID); } - } + } /// /// Get the details of the given user. A caller should try this method first if it isn't sure that @@ -151,7 +151,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) - { + { CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -159,21 +159,21 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", + "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); } } /// /// Handle a client request to update the inventory folder - /// + /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, /// and needs to be changed. @@ -188,7 +188,7 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.DebugFormat( // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); - + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) @@ -196,16 +196,16 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.UpdateFolder(name, folderID, type, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", + "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } /// @@ -223,16 +223,16 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.MoveFolder(folderID, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", + "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } /// @@ -267,14 +267,14 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } /// /// Handle the caps inventory descendents fetch. - /// + /// /// Since the folder structure is sent to the client on login, I believe we only need to handle items. /// /// @@ -288,20 +288,20 @@ namespace OpenSim.Framework.Communications.Cache bool fetchFolders, bool fetchItems, int sortOrder) { // m_log.DebugFormat( -// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", +// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", // fetchFolders, fetchItems, folderID, agentID); - + // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold; if ((fold = libraryRoot.FindFolder(folderID)) != null) { return fold.RequestListOfItems(); - } + } CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(agentID, out userProfile)) - { + { // XXX: When a client crosses into a scene, their entire inventory is fetched // asynchronously. If the client makes a request before the inventory is received, we need // to give the inventory a chance to come in. @@ -315,18 +315,18 @@ namespace OpenSim.Framework.Communications.Cache while (attempts++ < 30) { m_log.DebugFormat( - "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", + "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", attempts, folderID, agentID); - + Thread.Sleep(2000); - + if (userProfile.HasInventory) { break; } } - } - + } + if (userProfile.HasInventory) { if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) @@ -338,9 +338,9 @@ namespace OpenSim.Framework.Communications.Cache m_log.WarnFormat( "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}", folderID, agentID); - + return null; - } + } } else { @@ -352,7 +352,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID); - + return null; } } @@ -371,16 +371,16 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.PurgeFolder(folderID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", + "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", remoteClient.Name, remoteClient.AgentId); } } else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) @@ -407,9 +407,9 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", + "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - } + } } } } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 705f369..dac2f34 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -64,16 +64,16 @@ namespace OpenSim.Framework.Communications.Capabilities public class Caps { - private static readonly ILog m_log = + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private string m_httpListenerHostName; private uint m_httpListenPort; - + /// /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. /// - private string m_capsObjectPath; + private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } private CapsHandlers m_capsHandlers; @@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Capabilities // The following two entries are in a module, however, there also here so that we don't re-assign // the path to another cap by mistake. - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. //private string eventQueue = "0100/"; @@ -100,7 +100,7 @@ namespace OpenSim.Framework.Communications.Capabilities private bool m_dumpAssetsToFile; private string m_regionName; - // These are callbacks which will be setup by the scene so that we can update scene data when we + // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; @@ -128,46 +128,46 @@ namespace OpenSim.Framework.Communications.Capabilities public void RegisterHandlers() { DeregisterHandlers(); - - string capsBase = "/CAPS/" + m_capsObjectPath; - + + string capsBase = "/CAPS/" + m_capsObjectPath; + try { // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); - m_capsHandlers["MapLayer"] = - new LLSDStreamhandler("POST", - capsBase + m_mapLayerPath, + m_capsHandlers["MapLayer"] = + new LLSDStreamhandler("POST", + capsBase + m_mapLayerPath, GetMapLayer); - m_capsHandlers["NewFileAgentInventory"] = + m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler("POST", capsBase + m_newInventory, NewAgentInventoryRequest); - m_capsHandlers["UpdateNotecardAgentInventory"] = + m_capsHandlers["UpdateNotecardAgentInventory"] = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; - m_capsHandlers["UpdateScriptTaskInventory"] = + m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); - - // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and - // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires - // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, - // but when I went on the Linden grid, the + + // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and + // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires + // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, + // but when I went on the Linden grid, the // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP // - // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid - // we will be + // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid + // we will be // able to get the data we need to implement the necessary part of the protocol to fix the issue above. -// m_capsHandlers["FetchInventoryDescendents"] = +// m_capsHandlers["FetchInventoryDescendents"] = // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); - - // m_capsHandlers["FetchInventoryDescendents"] = + + // m_capsHandlers["FetchInventoryDescendents"] = // new LLSDStreamhandler("POST", // capsBase + m_fetchInventory, // FetchInventory)); // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", - // capsBase + m_requestTexture, + // capsBase + m_requestTexture, // RequestTexture); } catch (Exception e) @@ -181,7 +181,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - public void RegisterHandler(string capName, IRequestHandler handler) + public void RegisterHandler(string capName, IRequestHandler handler) { m_capsHandlers[capName] = handler; m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); @@ -189,14 +189,14 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// Remove all CAPS service handlers. - /// + /// /// /// /// /// public void DeregisterHandlers() { - foreach (string capsName in m_capsHandlers.Caps) + foreach (string capsName in m_capsHandlers.Caps) { m_capsHandlers.Remove(capsName); } @@ -220,7 +220,7 @@ namespace OpenSim.Framework.Communications.Capabilities // FIXME: these all should probably go into the respective region // modules - + /// /// Processes a fetch inventory request and sends the reply @@ -229,7 +229,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - // Request is like: + // Request is like: // // folders // @@ -240,14 +240,14 @@ namespace OpenSim.Framework.Communications.Capabilities // // // - // multiple fetch-folder maps are allowed within the larger folders map. + // multiple fetch-folder maps are allowed within the larger folders map. public string FetchInventoryRequest(string request, string path, string param) { string unmodifiedRequest = request.ToString(); - + //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); - + Hashtable hash = new Hashtable(); try { @@ -258,7 +258,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); m_log.Error("Request: " + request.ToString()); } - + ArrayList foldersrequested = (ArrayList)hash["folders"]; string response = ""; @@ -275,15 +275,15 @@ namespace OpenSim.Framework.Communications.Capabilities inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); inventoryitemstr = inventoryitemstr.Replace("folders", ""); inventoryitemstr = inventoryitemstr.Replace("", ""); - + response += inventoryitemstr; } - + if (response.Length == 0) { // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. // Therefore, I'm concluding that the client only has so many threads available to do requests - // and when a thread stalls.. is stays stalled. + // and when a thread stalls.. is stays stalled. // Therefore we need to return something valid response = "folders"; } @@ -291,7 +291,7 @@ namespace OpenSim.Framework.Communications.Capabilities { response = "folders" + response + ""; } - + //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); //m_log.Debug(Util.GetFormattedXml(response)); @@ -310,7 +310,7 @@ namespace OpenSim.Framework.Communications.Capabilities contents.agent___id = m_agentID; contents.owner___id = invFetch.owner_id; contents.folder___id = invFetch.folder_id; - + // The version number being sent back was originally 1. // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins // without clearing client cache, objects in the root folder disappear until the cache is cleared, @@ -318,8 +318,8 @@ namespace OpenSim.Framework.Communications.Capabilities // // Seeing the version to something other than 0 may be the right thing to do, but there is // a greater subtlety of the second life protocol that needs to be understood first. - contents.version = 0; - + contents.version = 0; + contents.descendents = 0; reply.folders.Array.Add(contents); List itemList = null; @@ -327,7 +327,7 @@ namespace OpenSim.Framework.Communications.Capabilities { itemList = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order); } - + if (itemList != null) { foreach (InventoryItemBase invItem in itemList) @@ -336,12 +336,12 @@ namespace OpenSim.Framework.Communications.Capabilities } } else - { + { IClientAPI client = GetClient(m_agentID); - - // We're going to both notify the client of inventory service failure and send back a 'no folder contents' response. + + // We're going to both notify the client of inventory service failure and send back a 'no folder contents' response. // If we don't send back the response, - // the client becomes unhappy (see Teravus' comment in FetchInventoryRequest()) + // the client becomes unhappy (see Teravus' comment in FetchInventoryRequest()) if (client != null) { client.SendAgentAlertMessage( @@ -351,11 +351,11 @@ namespace OpenSim.Framework.Communications.Capabilities else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", + "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", m_agentID); } } - + contents.descendents = contents.items.Array.Count; return reply; } @@ -375,7 +375,7 @@ namespace OpenSim.Framework.Communications.Capabilities llsdItem.item_id = invItem.ID; llsdItem.name = invItem.Name; llsdItem.parent_id = invItem.Folder; - llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); + llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower(); llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.Creator; @@ -395,7 +395,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -408,7 +408,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// protected static LLSDMapLayer GetLLSDMapLayerResponse() @@ -421,7 +421,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -437,7 +437,7 @@ namespace OpenSim.Framework.Communications.Capabilities #region EventQueue (Currently not enabled) /// - /// + /// /// /// /// @@ -463,7 +463,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -482,7 +482,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// public string CreateEmptyEventResponse() @@ -590,7 +590,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -622,7 +622,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -708,7 +708,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// Item to update /// Prim containing item to update /// Signals whether the script to update is currently running - /// New asset data + /// New asset data public void TaskScriptUpdated(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data) { if (TaskScriptUpdatedCall != null) @@ -751,7 +751,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -807,7 +807,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// This class is a callback invoked when a client sends asset data to + /// This class is a callback invoked when a client sends asset data to /// an agent inventory notecard update url /// public class ItemUpdater @@ -831,7 +831,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -889,7 +889,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// This class is a callback invoked when a client sends asset data to + /// This class is a callback invoked when a client sends asset data to /// a task inventory script update url /// public class TaskInventoryScriptUpdater @@ -921,7 +921,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -931,7 +931,7 @@ namespace OpenSim.Framework.Communications.Capabilities { try { -// m_log.InfoFormat("[CAPS]: " + +// m_log.InfoFormat("[CAPS]: " + // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", // data, path, param)); diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index e76a5c5..4a3d00f 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -64,14 +64,14 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// name of the capability of the cap /// handler to be removed - public void Remove(string capsName) + public void Remove(string capsName) { // This line must be here, or caps will break! m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); m_capsHandlers.Remove(capsName); } - public bool ContainsCap(string cap) + public bool ContainsCap(string cap) { return m_capsHandlers.ContainsKey(cap); } @@ -85,14 +85,14 @@ namespace OpenSim.Framework.Communications.Capabilities /// retrieve a cap handler for a cap that is not contained in /// CapsHandlers. /// - public IRequestHandler this[string idx] + public IRequestHandler this[string idx] { - get + get { return m_capsHandlers[idx]; } - set + set { if (m_capsHandlers.ContainsKey(idx)) { @@ -111,9 +111,9 @@ namespace OpenSim.Framework.Communications.Capabilities /// Return the list of cap names for which this CapsHandlers /// object contains cap handlers. /// - public string[] Caps + public string[] Caps { - get + get { string[] __keys = new string[m_capsHandlers.Keys.Count]; m_capsHandlers.Keys.CopyTo(__keys, 0); @@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// Return an LLSD-serializable Hashtable describing the /// capabilities and their handler details. /// - public Hashtable CapsDetails + public Hashtable CapsDetails { get { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index e869267..bcf7a88 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -37,12 +37,12 @@ using libsecondlife; namespace OpenSim.Framework.Communications.Capabilities { /// - /// Borrowed from (a older version of) libsl for now, as their new llsd code doesn't work we our decoding code. + /// Borrowed from (a older version of) libsl for now, as their new llsd code doesn't work we our decoding code. /// public static class LLSD { /// - /// + /// /// public class LLSDParseException : Exception { @@ -52,7 +52,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// public class LLSDSerializeException : Exception { @@ -62,7 +62,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -96,7 +96,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -116,7 +116,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -217,7 +217,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -360,7 +360,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -405,7 +405,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -441,7 +441,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -453,7 +453,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// /// @@ -661,7 +661,7 @@ namespace OpenSim.Framework.Communications.Capabilities } /// - /// + /// /// /// private static void SkipWS(XmlTextReader reader) diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 409d2e0..507f12b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -35,9 +35,9 @@ namespace OpenSim.Framework.Communications.Capabilities { public class LLSDHelpers { -// private static readonly log4net.ILog m_log +// private static readonly log4net.ILog m_log // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + public static string SerialiseLLSDReply(object obj) { StringWriter sw = new StringWriter(); @@ -47,9 +47,9 @@ namespace OpenSim.Framework.Communications.Capabilities SerializeLLSDType(writer, obj); writer.WriteEndElement(); writer.Close(); - + //m_log.DebugFormat("[LLSD Helpers]: Generated serialized LLSD reply {0}", sw.ToString()); - + return sw.ToString(); } @@ -146,7 +146,7 @@ namespace OpenSim.Framework.Communications.Capabilities 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. + // but first we need to know the right class to deserialise them into. } else { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 31896c2..1a75aba 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -91,7 +91,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int descendents; public LLUUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names public LLSDArray items = new LLSDArray(); - public LLUUID owner___id; // and of course we can't have field names with "-" in + public LLUUID owner___id; // and of course we can't have field names with "-" in public int version; } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index fb5eaa8..c045dcf 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -23,7 +23,7 @@ * 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; @@ -41,7 +41,7 @@ namespace OpenSim.Framework.Communications.Capabilities { } - public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) + public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) { region_name = region; parcel_local_id = localID; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 5e8a08f..8683cea 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) + // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) // libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index ee9ff1b..8bfd20c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -34,7 +34,7 @@ namespace OpenSim.Framework.Communications.Capabilities { /// /// The task inventory item that was updated - /// + /// public LLUUID item_id; /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index df32d1a..e45d9de 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -34,17 +34,17 @@ namespace OpenSim.Framework.Communications.Capabilities { /// /// The item containing the script to update - /// + /// public LLUUID item_id; /// /// The task containing the script - /// + /// public LLUUID task_id; /// /// Signals whether the script is currently active - /// + /// public int is_script_running; } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 67064b0..8143233 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -23,7 +23,7 @@ * 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.Framework.Communications.Capabilities @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.Capabilities { } - public LLSDVoiceAccountResponse(string user, string pass) + public LLSDVoiceAccountResponse(string user, string pass) { username = user; password = pass; diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2813aa0..37020f6 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -236,7 +236,7 @@ namespace OpenSim.Framework.Communications public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) { - m_userService.UpdateUserProfileProperties(UserProfile); + m_userService.UpdateUserProfileProperties(UserProfile); return; } diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index 6c5f5f7..48f72a0 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -112,7 +112,7 @@ namespace OpenSim.Framework.Communications public void EndInvoke() { - // This method assumes that only 1 thread calls EndInvoke + // This method assumes that only 1 thread calls EndInvoke if (!IsCompleted) { // If the operation isn't done, wait for it @@ -142,7 +142,7 @@ namespace OpenSim.Framework.Communications // Save the asynchronous operation's result m_result = result; - // Tell the base class that the operation completed + // Tell the base class that the operation completed // sucessfully (no exception) base.SetAsCompleted(completedSynchronously); } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index c8a3c85..f7a8857 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -43,62 +43,62 @@ namespace OpenSim.Framework.Communications public interface IInventoryServices { /// - /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the + /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received /// /// /// void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); - + /// /// Add a new folder to the user's inventory /// /// /// true if the folder was successfully added bool AddFolder(InventoryFolderBase folder); - + /// /// Move an inventory folder to a new location /// /// A folder containing the details of the new location /// true if the folder was successfully moved bool MoveFolder(InventoryFolderBase folder); - + /// /// Purge an inventory folder of all its items and subfolders. /// /// /// true if the folder was successfully purged bool PurgeFolder(InventoryFolderBase folder); - + /// /// Add a new item to the user's inventory /// /// /// true if the item was successfully added bool AddItem(InventoryItemBase item); - + /// /// Update an item in the user's inventory /// /// /// true if the item was successfully updated bool UpdateItem(InventoryItemBase item); - + /// /// Delete an item from the user's inventory /// /// /// true if the item was successfully deleted bool DeleteItem(InventoryItemBase item); - + /// /// Create a new inventory for the given user. /// /// /// true if the inventory was successfully created, false otherwise bool CreateNewUserInventory(LLUUID user); - + bool HasInventoryForUser(LLUUID userID); /// @@ -107,12 +107,12 @@ namespace OpenSim.Framework.Communications /// /// null if no root folder was found InventoryFolderBase RequestRootFolder(LLUUID userID); - + /// /// Returns a list of all the folders in a given user's inventory. /// /// - /// A flat list of the user's inventory folder tree, + /// A flat list of the user's inventory folder tree, /// null if there is no inventory for this user List GetInventorySkeleton(LLUUID userId); } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 7d71d02..67a8c78 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -37,7 +37,7 @@ namespace OpenSim.Framework.Communications /// /// First name /// Last name - /// A user profile. Returns null if no profile is found + /// A user profile. Returns null if no profile is found UserProfileData GetUserProfile(string firstName, string lastName); //UserProfileData GetUserProfile(string name); @@ -46,7 +46,7 @@ namespace OpenSim.Framework.Communications /// Loads a user profile from a database by UUID /// /// The target UUID - /// A user profile. Returns null if no user profile is found. + /// A user profile. Returns null if no user profile is found. UserProfileData GetUserProfile(LLUUID userId); void clearUserAgent(LLUUID avatarID); @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications UserProfileData SetupMasterUser(LLUUID userId); /// - /// + /// /// /// LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); @@ -110,7 +110,7 @@ namespace OpenSim.Framework.Communications List GetUserFriendList(LLUUID friendlistowner); /// - /// Get's the User Appearance + /// Get's the User Appearance AvatarAppearance GetUserAppearance(LLUUID user); void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index e81d8c4..dffeed3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -40,13 +40,13 @@ namespace OpenSim.Framework.Communications /// public abstract class InventoryServiceBase : IInventoryServices { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_plugins = new Dictionary(); #region Plugin methods - + /// /// Adds a new user server plugin - plugins will be requested in the order they were loaded. /// @@ -76,42 +76,42 @@ namespace OpenSim.Framework.Communications } } } - + #endregion - - #region IInventoryServices methods - + + #region IInventoryServices methods + // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); - + InventoryFolderBase rootFolder = RequestRootFolder(userId); - + // Agent has no inventory structure yet. if (null == rootFolder) { - return null; - } - - List userFolders = new List(); - + return null; + } + + List userFolders = new List(); + userFolders.Add(rootFolder); - + foreach (KeyValuePair plugin in m_plugins) { IList folders = plugin.Value.getFolderHierarchy(rootFolder.ID); userFolders.AddRange(folders); - } - + } + // foreach (InventoryFolderBase folder in userFolders) // { // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); // } - + return userFolders; } - + // See IInventoryServices public virtual bool HasInventoryForUser(LLUUID userID) { @@ -133,31 +133,31 @@ namespace OpenSim.Framework.Communications public bool CreateNewUserInventory(LLUUID user) { InventoryFolderBase existingRootFolder = RequestRootFolder(user); - + if (null != existingRootFolder) { m_log.WarnFormat( "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " - + "a root inventory folder with id {1}", + + "a root inventory folder with id {1}", user, existingRootFolder.ID); } else - { + { UsersInventory inven = new UsersInventory(); inven.CreateNewInventorySet(user); AddNewInventorySet(inven); - + return true; } - + return false; - } - + } + // See IInventoryServices - public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); - + public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); + #endregion - + #region Methods used by GridInventoryService public List RequestSubFolders(LLUUID parentFolderID) @@ -180,21 +180,21 @@ namespace OpenSim.Framework.Communications } return itemsList; } - + #endregion // See IInventoryServices public bool AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - + "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.addInventoryFolder(folder); } - - // FIXME: Should return false on failure + + // FIXME: Should return false on failure return true; } @@ -203,14 +203,14 @@ namespace OpenSim.Framework.Communications { m_log.DebugFormat( "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.moveInventoryFolder(folder); } - - // FIXME: Should return false on failure - return true; + + // FIXME: Should return false on failure + return true; } // See IInventoryServices @@ -218,14 +218,14 @@ namespace OpenSim.Framework.Communications { m_log.DebugFormat( "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); - + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.addInventoryItem(item); } - - // FIXME: Should return false on failure - return true; + + // FIXME: Should return false on failure + return true; } // See IInventoryServices @@ -233,14 +233,14 @@ namespace OpenSim.Framework.Communications { m_log.InfoFormat( "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.updateInventoryItem(item); } - - // FIXME: Should return false on failure - return true; + + // FIXME: Should return false on failure + return true; } // See IInventoryServices @@ -248,19 +248,19 @@ namespace OpenSim.Framework.Communications { m_log.InfoFormat( "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); - + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.deleteInventoryItem(item.ID); } - - // FIXME: Should return false on failure - return true; + + // FIXME: Should return false on failure + return true; } - + /// /// Purge a folder of all items items and subfolders. - /// + /// /// FIXME: Really nasty in a sense, because we have to query the database to get information we may /// already know... Needs heavy refactoring. /// @@ -269,13 +269,13 @@ namespace OpenSim.Framework.Communications { m_log.DebugFormat( "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); - + List subFolders = RequestSubFolders(folder.ID); - + foreach (InventoryFolderBase subFolder in subFolders) { // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); - + foreach (KeyValuePair plugin in m_plugins) { plugin.Value.deleteInventoryFolder(subFolder.ID); @@ -288,17 +288,17 @@ namespace OpenSim.Framework.Communications { DeleteItem(item); } - - // FIXME: Should return false on failure - return true; + + // FIXME: Should return false on failure + return true; } - + private void AddNewInventorySet(UsersInventory inventory) { foreach (InventoryFolderBase folder in inventory.Folders.Values) { AddFolder(folder); - } + } } /// @@ -340,7 +340,7 @@ namespace OpenSim.Framework.Communications folder.Type = (short)AssetType.Bodypart; folder.Version = 1; Folders.Add(folder.ID, folder); - + folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; @@ -348,7 +348,7 @@ namespace OpenSim.Framework.Communications folder.Name = "Calling Cards"; folder.Type = (short)AssetType.CallingCard; folder.Version = 1; - Folders.Add(folder.ID, folder); + Folders.Add(folder.ID, folder); folder = new InventoryFolderBase(); folder.ParentID = rootFolder; diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs index 6ec21d9..1a9cc24 100644 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs @@ -31,9 +31,9 @@ namespace OpenSim.Framework.Communications.Limit /// Interface for strategies that can limit requests from the client. Currently only used in the /// texture modules to deal with repeated requests for certain textures. However, limiting strategies /// could be used with other requests. - /// + /// public interface IRequestLimitStrategy - { + { /// /// Should the request be allowed? If the id is not monitored, then the request is always allowed. /// Otherwise, the strategy criteria will be applied. @@ -41,21 +41,21 @@ namespace OpenSim.Framework.Communications.Limit /// /// bool AllowRequest(TId id); - + /// /// Has the request been refused just once? /// /// False if the request has not yet been refused, or if the request has been refused more /// than once. bool IsFirstRefusal(TId id); - + /// /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring /// continues. /// /// void MonitorRequests(TId id); - + /// /// Is the id being monitored? /// diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 72d0586..932f780 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -26,15 +26,15 @@ */ namespace OpenSim.Framework.Communications.Limit -{ +{ /// /// Strategy which polices no limits /// public class NullLimitStrategy : IRequestLimitStrategy - { + { public bool AllowRequest(TId id) { return true; } public bool IsFirstRefusal(TId id) { return false; } public void MonitorRequests(TId id) { /* intentionally blank */ } - public bool IsMonitoringRequests(TId id) { return false; } + public bool IsMonitoringRequests(TId id) { return false; } } } diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index dfa05fa..bb72029 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -31,14 +31,14 @@ namespace OpenSim.Framework.Communications.Limit { /// /// Limit requests by discarding them after they've been repeated a certain number of times. - /// + /// public class RepeatLimitStrategy : IRequestLimitStrategy { /// /// Record each asset request that we're notified about. /// private readonly Dictionary requestCounts = new Dictionary(); - + /// /// The maximum number of requests that can be made before we drop subsequent requests. /// @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Limit { get { return m_maxRequests; } } - + /// /// The maximum number of requests that may be served before all further /// requests are dropped. @@ -55,52 +55,52 @@ namespace OpenSim.Framework.Communications.Limit { m_maxRequests = maxRequests; } - + /// /// /// public bool AllowRequest(TId id) - { + { if (requestCounts.ContainsKey(id)) { requestCounts[id] += 1; - + if (requestCounts[id] > m_maxRequests) - { + { return false; - } + } } - + return true; } - + /// /// - /// + /// public bool IsFirstRefusal(TId id) { if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) { return true; - } - + } + return false; } - + /// /// - /// + /// public void MonitorRequests(TId id) { if (!IsMonitoringRequests(id)) { requestCounts.Add(id, 1); - } - } - + } + } + /// /// - /// + /// public bool IsMonitoringRequests(TId id) { return requestCounts.ContainsKey(id); diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs index 34b01ff..b5b925e 100644 --- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs @@ -32,17 +32,17 @@ namespace OpenSim.Framework.Communications.Limit { /// /// Limit requests by discarding repeat attempts that occur within a given time period - /// + /// /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests /// for the same texture at different resolutions. - /// + /// public class TimeLimitStrategy : IRequestLimitStrategy { /// /// Record the time at which an asset request occurs. /// - private readonly Dictionary requests = new Dictionary(); - + private readonly Dictionary requests = new Dictionary(); + /// /// The minimum time period between which requests for the same data will be serviced. /// @@ -53,37 +53,37 @@ namespace OpenSim.Framework.Communications.Limit } /// - /// + /// public TimeLimitStrategy(TimeSpan repeatPeriod) { m_repeatPeriod = repeatPeriod; } - + /// /// /// public bool AllowRequest(TId id) - { + { if (IsMonitoringRequests(id)) { DateTime now = DateTime.Now; TimeSpan elapsed = now - requests[id].Time; - + if (elapsed < RepeatPeriod) { requests[id].Refusals += 1; return false; } - - requests[id].Time = now; + + requests[id].Time = now; } - + return true; } - + /// /// - /// + /// public bool IsFirstRefusal(TId id) { if (IsMonitoringRequests(id)) @@ -92,31 +92,31 @@ namespace OpenSim.Framework.Communications.Limit { return true; } - } - + } + return false; } - + /// /// - /// + /// public void MonitorRequests(TId id) { if (!IsMonitoringRequests(id)) { requests.Add(id, new Request(DateTime.Now)); - } - } - + } + } + /// /// - /// + /// public bool IsMonitoringRequests(TId id) { return requests.ContainsKey(id); - } + } } - + /// /// Private request details. /// @@ -126,12 +126,12 @@ namespace OpenSim.Framework.Communications.Limit /// Time of last request /// public DateTime Time; - + /// /// Number of refusals associated with this request /// public int Refusals; - + public Request(DateTime time) { Time = time; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index bccac74..6fdd06a 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -239,7 +239,7 @@ namespace OpenSim.Framework.Communications "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"); } - + /// /// Response to indicate that login failed because the agent's inventory was not available. /// @@ -249,7 +249,7 @@ namespace OpenSim.Framework.Communications return GenerateFailureResponse( "key", "The avatar inventory service is not responding. Please notify your login region operator.", - "false"); + "false"); } public XmlRpcResponse CreateAlreadyLoggedInResponse() diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index fa78a30..bd0fa53 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -48,8 +48,8 @@ namespace OpenSim.Framework.Communications protected string m_welcomeMessage = "Welcome to OpenSim"; protected UserManagerBase m_userManager = null; - protected Mutex m_loginMutex = new Mutex(false); - + protected Mutex m_loginMutex = new Mutex(false); + /// /// Used during login to send the skeleton of the OpenSim Library to the client. /// @@ -61,12 +61,12 @@ namespace OpenSim.Framework.Communications /// /// /// - public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, + public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, string welcomeMess) { m_userManager = userManager; m_libraryRootFolder = libraryRootFolder; - + if (welcomeMess != String.Empty) { m_welcomeMessage = welcomeMess; @@ -79,15 +79,15 @@ namespace OpenSim.Framework.Communications /// The existing response /// The user profile public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); - + /// /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. /// /// /// /// This will be thrown if there is a problem with the inventory service - protected abstract InventoryData GetInventorySkeleton(LLUUID userID); - + protected abstract InventoryData GetInventorySkeleton(LLUUID userID); + /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message /// @@ -112,7 +112,7 @@ namespace OpenSim.Framework.Communications UserProfileData userProfile; LoginResponse logResponse = new LoginResponse(); - + string firstname = String.Empty; string lastname = String.Empty; @@ -120,23 +120,23 @@ namespace OpenSim.Framework.Communications { firstname = (string) requestData["first"]; lastname = (string) requestData["last"]; - + m_log.InfoFormat( - "[LOGIN BEGIN]: Received login request message from user {0} {1}", + "[LOGIN BEGIN]: Received login request message from user {0} {1}", firstname, lastname); string clientVersion = "Unknown"; - + if (requestData.Contains("version")) { - clientVersion = (string)requestData["version"]; + clientVersion = (string)requestData["version"]; } - + if (requestData.Contains("start")) { startLocationRequest = (string)requestData["start"]; - } - + } + m_log.DebugFormat( "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); @@ -163,9 +163,9 @@ namespace OpenSim.Framework.Communications catch (Exception e) { m_log.InfoFormat( - "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", requestData["web_login_key"], firstname, lastname, e); - + return logResponse.CreateFailedResponse(); } GoodLogin = AuthenticateUser(userProfile, webloginkey); @@ -176,14 +176,14 @@ namespace OpenSim.Framework.Communications { m_log.Info( "[LOGIN END]: login_to_simulator login message did not contain all the required data"); - + return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { m_log.InfoFormat("[LOGIN END]: User {0} {1} failed authentication", firstname, lastname); - + return logResponse.CreateLoginFailedResponse(); } else @@ -199,11 +199,11 @@ namespace OpenSim.Framework.Communications m_userManager.CommitAgent(ref userProfile); // Reject the login - + m_log.InfoFormat( - "[LOGIN END]: Notifying user {0} {1} that they are already logged in", + "[LOGIN END]: Notifying user {0} {1} that they are already logged in", firstname, lastname); - + return logResponse.CreateAlreadyLoggedInResponse(); } // Otherwise... @@ -214,9 +214,9 @@ namespace OpenSim.Framework.Communications { LLUUID agentID = userProfile.ID; InventoryData inventData = null; - + try - { + { inventData = GetInventorySkeleton(agentID); } catch (Exception e) @@ -224,10 +224,10 @@ namespace OpenSim.Framework.Communications m_log.ErrorFormat( "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", agentID, e.GetType(), e.Message); - - return logResponse.CreateLoginInventoryFailedResponse(); - } - + + return logResponse.CreateLoginInventoryFailedResponse(); + } + ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -235,7 +235,7 @@ namespace OpenSim.Framework.Communications ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); userProfile.RootInventoryFolderID = inventData.RootFolderID; - + // Inventory Library Section Hashtable InventoryLibRootHash = new Hashtable(); InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; @@ -244,10 +244,10 @@ namespace OpenSim.Framework.Communications logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - + logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); + logResponse.InventoryLibrary = GetInventoryLibrary(); // Circuit Code uint circode = (uint) (Util.RandomClass.Next()); @@ -280,15 +280,15 @@ namespace OpenSim.Framework.Communications //return logResponse.ToXmlRpcResponse(); } CommitAgent(ref userProfile); - + // If we reach this point, then the login has successfully logged onto the grid if (StatsManager.UserStats != null) StatsManager.UserStats.AddSuccessfulLogin(); - + m_log.DebugFormat( "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", firstname, lastname); - + return logResponse.ToXmlRpcResponse(); } catch (Exception e) @@ -422,10 +422,10 @@ namespace OpenSim.Framework.Communications } CommitAgent(ref userProfile); - + // If we reach this point, then the login has successfully logged onto the grid if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); + StatsManager.UserStats.AddSuccessfulLogin(); return logResponse.ToLLSDResponse(); } @@ -449,7 +449,7 @@ namespace OpenSim.Framework.Communications // period, space, parens, and dash. Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); - + Hashtable returnactions = new Hashtable(); int statuscode = 200; @@ -467,7 +467,7 @@ namespace OpenSim.Framework.Communications // the client requires the HTML form field be named 'username' // however, the data it sends when it loads the first time is 'firstname' // another one of those little nuances. - + if (keysvals.Contains("firstname")) firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); @@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications if (keysvals.Contains("lang")) lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); - + if (keysvals.Contains("password")) password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); @@ -541,8 +541,8 @@ namespace OpenSim.Framework.Communications return returnactions; } - public string GetLoginForm(string firstname, string lastname, string location, string region, - string grid, string channel, string version, string lang, + public string GetLoginForm(string firstname, string lastname, string location, string region, + string grid, string channel, string version, string lang, string password, string errormessages) { // inject our values in the form at the markers @@ -559,7 +559,7 @@ namespace OpenSim.Framework.Communications loginform = sr.ReadToEnd(); sr.Close(); } - + loginform = loginform.Replace("[$firstname]", firstname); loginform = loginform.Replace("[$lastname]", lastname); loginform = loginform.Replace("[$location]", location); @@ -586,7 +586,7 @@ namespace OpenSim.Framework.Communications responseString += "OpenSim Login"; responseString += "
"; responseString += "
"; - + responseString += "
"; responseString += "
[$errors]
"; @@ -670,13 +670,13 @@ namespace OpenSim.Framework.Communications password = "$1$" + Util.Md5Hash(password); password = password.Remove(0, 3); //remove $1$ - + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - // Testing... + // Testing... //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); return passwordSuccess; @@ -694,7 +694,7 @@ namespace OpenSim.Framework.Communications } /// - /// + /// /// /// /// @@ -709,7 +709,7 @@ namespace OpenSim.Framework.Communications } /// - /// + /// /// /// /// @@ -720,7 +720,7 @@ namespace OpenSim.Framework.Communications } /// - /// + /// /// /// public virtual string GetMessage() @@ -741,17 +741,17 @@ namespace OpenSim.Framework.Communications } return buddylistreturn; } - + /// /// Converts the inventory library skeleton into the form required by the rpc request. /// /// protected virtual ArrayList GetInventoryLibrary() { - Dictionary rootFolders + Dictionary rootFolders = m_libraryRootFolder.RequestSelfAndDescendentFolders(); ArrayList folderHashes = new ArrayList(); - + foreach (InventoryFolderBase folder in rootFolders.Values) { Hashtable TempHash = new Hashtable(); @@ -762,12 +762,12 @@ namespace OpenSim.Framework.Communications TempHash["folder_id"] = folder.ID.ToString(); folderHashes.Add(TempHash); } - + return folderHashes; } /// - /// + /// /// /// protected virtual ArrayList GetLibraryOwner() diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 9a53499..2df5fbc 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -28,7 +28,7 @@ using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// 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. @@ -41,8 +41,8 @@ using System.Runtime.InteropServices; [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 +// 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)] @@ -54,11 +54,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// 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")] diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 4ed62bf..7c8876a 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -16,14 +16,14 @@ namespace OpenSim.Framework.Communications /// /// This class is a generic implementation of a REST (Representational State Transfer) web service. This /// class is designed to execute both synchronously and asynchronously. - /// + /// /// Internally the implementation works as a two stage asynchronous web-client. /// When the request is initiated, RestClient will query asynchronously for for a web-response, /// sleeping until the initial response is returned by the server. Once the initial response is retrieved /// the second stage of asynchronous requests will be triggered, in an attempt to read of the response /// object into a memorystream as a sequence of asynchronous reads. - /// - /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing + /// + /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be /// invoked by the caller in either synchronous mode or asynchronous modes. /// @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications #region member variables /// - /// The base Uri of the web-service e.g. http://www.google.com + /// The base Uri of the web-service e.g. http://www.google.com /// private string _url; @@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications /// - /// if an exception occours during async processing, we need to save it, so it can be + /// if an exception occours during async processing, we need to save it, so it can be /// rethrown on the primary thread; /// private Exception _asyncException; @@ -341,7 +341,7 @@ namespace OpenSim.Framework.Communications { AsyncResult ar = (AsyncResult) asyncResult; - // Wait for operation to complete, then return result or + // Wait for operation to complete, then return result or // throw exception return ar.EndInvoke(); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 8e0b75c..5a62682 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -43,12 +43,12 @@ namespace OpenSim.Framework.Communications ///
public abstract class UserManagerBase : IUserService { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; private Dictionary _plugins = new Dictionary(); - + /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// @@ -85,7 +85,7 @@ namespace OpenSim.Framework.Communications m_log.Info("[USERSTORAGE]: Added IUserData Interface"); } - #region Get UserProfile + #region Get UserProfile // see IUserService public UserProfileData GetUserProfile(string fname, string lname) @@ -103,8 +103,8 @@ namespace OpenSim.Framework.Communications return null; } - - // see IUserService + + // see IUserService public UserProfileData GetUserProfile(LLUUID uuid) { foreach (KeyValuePair plugin in _plugins) @@ -408,7 +408,7 @@ namespace OpenSim.Framework.Communications profile.CurrentAgent = agent; } - + /// /// Process a user logoff from OpenSim. /// @@ -422,7 +422,7 @@ namespace OpenSim.Framework.Communications { if (StatsManager.UserStats != null) StatsManager.UserStats.AddLogout(); - + UserProfileData userProfile; UserAgentData userAgent; LLVector3 currentPos = new LLVector3(posx, posy, posz); @@ -433,7 +433,7 @@ namespace OpenSim.Framework.Communications { // This line needs to be in side the above if statement or the UserServer will crash on some logouts. m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); - + userAgent = userProfile.CurrentAgent; if (userAgent != null) { @@ -462,7 +462,7 @@ namespace OpenSim.Framework.Communications m_log.Warn("[LOGOUT]: Unknown User logged out"); } } - + public void CreateAgent(UserProfileData profile, LLSD request) { UserAgentData agent = new UserAgentData(); @@ -516,7 +516,7 @@ namespace OpenSim.Framework.Communications #endregion /// - /// + /// /// /// public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) @@ -598,7 +598,7 @@ namespace OpenSim.Framework.Communications /// Appearance /// TODO: stubs for now to get us to a compiling state gently - public AvatarAppearance GetUserAppearance(LLUUID user) + public AvatarAppearance GetUserAppearance(LLUUID user) { foreach (KeyValuePair plugin in _plugins) { @@ -643,7 +643,7 @@ namespace OpenSim.Framework.Communications } } } - + public void RemoveAttachment(LLUUID user, LLUUID item) { foreach (KeyValuePair plugin in _plugins) @@ -658,7 +658,7 @@ namespace OpenSim.Framework.Communications } } } - + public List GetAttachments(LLUUID user) { foreach (KeyValuePair plugin in _plugins) -- cgit v1.1 From 772f88d2e5f4824e06575650736ec11b6ea564d8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 16 May 2008 16:37:31 +0000 Subject: * Removing unnecessary LLUUID.Zero check from AssetCache * This revision also includes a very temporary fix for the fact that NREs are received because of a missing avatar apperance in grid mode --- .../Framework/Communications/Cache/AssetCache.cs | 120 ++++++++++----------- 1 file changed, 58 insertions(+), 62 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0669ce9..e1d5d32 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -371,85 +371,81 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver 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) { - //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); + if (!Textures.ContainsKey(image.FullID)) { - TextureImage image = new TextureImage(asset); - if (!Textures.ContainsKey(image.FullID)) - { - Textures.Add(image.FullID, image); + Textures.Add(image.FullID, image); - if (StatsManager.SimExtraStats != null) - { - StatsManager.SimExtraStats.AddTexture(image); - } + if (StatsManager.SimExtraStats != null) + { + StatsManager.SimExtraStats.AddTexture(image); } } - else + } + else + { + AssetInfo assetInf = new AssetInfo(asset); + if (!Assets.ContainsKey(assetInf.FullID)) { - AssetInfo assetInf = new AssetInfo(asset); - if (!Assets.ContainsKey(assetInf.FullID)) - { - Assets.Add(assetInf.FullID, assetInf); + Assets.Add(assetInf.FullID, assetInf); - if (StatsManager.SimExtraStats != null) - { - StatsManager.SimExtraStats.AddAsset(assetInf); - } + if (StatsManager.SimExtraStats != null) + { + StatsManager.SimExtraStats.AddAsset(assetInf); + } - if (RequestedAssets.ContainsKey(assetInf.FullID)) - { - AssetRequest req = RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - req.NumPackets = CalculateNumPackets(assetInf.Data); + if (RequestedAssets.ContainsKey(assetInf.FullID)) + { + AssetRequest req = RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + req.NumPackets = CalculateNumPackets(assetInf.Data); - RequestedAssets.Remove(assetInf.FullID); - AssetRequests.Add(req); - } + RequestedAssets.Remove(assetInf.FullID); + AssetRequests.Add(req); } } + } + + // Notify requesters for this asset + if (RequestLists.ContainsKey(asset.FullID)) + { + AssetRequestsList reqList = null; + lock (RequestLists) + { + //m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #1)"); + reqList = RequestLists[asset.FullID]; - // Notify requesters for this asset - if (RequestLists.ContainsKey(asset.FullID)) + } + //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #1)"); + if (reqList != null) { - AssetRequestsList reqList = null; + //making a copy of the list is not ideal + //but the old method of locking around this whole block of code was causing a multi-thread lock + //between this and the TextureDownloadModule + //while the localAsset thread running this and trying to send a texture to the callback in the + //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding + // the lock in the texturedownload module) was trying to + //request a new asset and hitting a lock in here on the RequestLists. + + List theseRequests = new List(reqList.Requests); + reqList.Requests.Clear(); + lock (RequestLists) { - //m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #1)"); - reqList = RequestLists[asset.FullID]; - + // m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #2)"); + RequestLists.Remove(asset.FullID); } - //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #1)"); - if (reqList != null) - { - //making a copy of the list is not ideal - //but the old method of locking around this whole block of code was causing a multi-thread lock - //between this and the TextureDownloadModule - //while the localAsset thread running this and trying to send a texture to the callback in the - //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding - // the lock in the texturedownload module) was trying to - //request a new asset and hitting a lock in here on the RequestLists. - - List theseRequests = new List(reqList.Requests); - reqList.Requests.Clear(); - - lock (RequestLists) - { - // m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #2)"); - RequestLists.Remove(asset.FullID); - } - //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #2)"); + //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #2)"); - foreach (NewAssetRequest req in theseRequests) - { - req.Callback(asset.FullID, asset); - } + foreach (NewAssetRequest req in theseRequests) + { + req.Callback(asset.FullID, asset); } } } -- cgit v1.1 From c2581c95779bbf17538e0dedef89ca8b739cef2e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 16 May 2008 17:47:34 +0000 Subject: * Cache knowledge in the region server that the asset service has reported an asset to be missing * This prevents repeated requests for the same missing asset to the asset server, hopefully reducing the load a little --- .../Framework/Communications/Cache/AssetCache.cs | 43 +++++++++++++++------- .../Communications/Cache/AssetServerBase.cs | 2 +- 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e1d5d32..e6a0852 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache ///
private Dictionary Textures; - /// + /// /// Assets requests which are waiting for asset server data. This includes texture requests /// private Dictionary RequestedAssets; @@ -75,7 +75,6 @@ namespace OpenSim.Framework.Communications.Cache ///
private List AssetRequests; - /// /// Until the asset request is fulfilled, each asset request is associated with a list of requesters /// @@ -166,11 +165,11 @@ namespace OpenSim.Framework.Communications.Cache m_assetServer = assetServer; m_assetServer.SetReceiver(this); - m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - m_assetCacheThread.Name = "AssetCacheThread"; - m_assetCacheThread.IsBackground = true; - m_assetCacheThread.Start(); - ThreadTracker.Add(m_assetCacheThread); + m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + m_assetCacheThread.Name = "AssetCacheThread"; + m_assetCacheThread.IsBackground = true; + m_assetCacheThread.Start(); + ThreadTracker.Add(m_assetCacheThread); } /// @@ -452,10 +451,19 @@ namespace OpenSim.Framework.Communications.Cache } // See IAssetReceiver - public void AssetNotFound(LLUUID assetID) + public void AssetNotFound(LLUUID assetID, bool IsTexture) { - // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + if (IsTexture) + { + Textures[assetID] = null; + } + else + { + Assets[assetID] = null; + } + // Notify requesters for this asset AssetRequestsList reqList = null; lock (RequestLists) @@ -509,7 +517,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Make an asset request the result of which will be packeted up and sent directly back to the client. + /// Handle an asset request from the client. The result will be sent back asynchronously. /// /// /// @@ -546,12 +554,21 @@ namespace OpenSim.Framework.Communications.Cache RequestedAssets.Add(requestID, request); m_assetServer.RequestAsset(requestID, false); } + return; } - //it is in our cache + + // It has an entry in our cache AssetInfo asset = Assets[requestID]; - - // add to the AssetRequests list + + // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. + if (null == asset) + { + m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing", requestID); + return; + } + + // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; req.RequestAssetID = requestID; diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index b16512c..db71079 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache { //m_log.ErrorFormat("[ASSET SERVER]: Asset {0} not found by asset server", req.AssetID); - m_receiver.AssetNotFound(req.AssetID); + m_receiver.AssetNotFound(req.AssetID, req.IsTexture); } } -- cgit v1.1 From 63ddbfb97982335f947a58f1fe8d03d3403276ed Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 16 May 2008 18:10:04 +0000 Subject: * Eliminate occurences of "Got a texture uuid ... with no sender object to handle it..." by properly dealing with the situation where a client still has queued texture requests when it logs out --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e6a0852..1dd6529 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -453,7 +453,7 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver public void AssetNotFound(LLUUID assetID, bool IsTexture) { - m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + //m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); if (IsTexture) { -- cgit v1.1 From a510033df5bfc7e8c8b6f2498196a4e3e281c6a7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 16 May 2008 22:50:37 +0000 Subject: * Applying patch in mantis 0001293: [PATCH] Fix a bug that corrupts uploaded assets on disk write from Melane. Thanks Melanie! --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index dac2f34..9725c94 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -678,6 +678,8 @@ namespace OpenSim.Framework.Communications.Capabilities item.InvType = inType; item.Folder = parentFolder; item.CurrentPermissions = 2147483647; + item.BasePermissions = 2147483647; + item.EveryOnePermissions = 0; item.NextPermissions = 2147483647; if (AddNewInventoryItem != null) -- cgit v1.1 From f6add412d68b7af65e68a7dd31409867dffc689b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 18 May 2008 19:56:25 +0000 Subject: * Refactor: Eliminate empty if clause from AssetCache.GetAsset() --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1dd6529..805adb0 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -261,10 +261,7 @@ namespace OpenSim.Framework.Communications.Cache lock (RequestLists) { // m_log.Info("AssetCache: Lock taken on requestLists (GetAsset)"); - if (RequestLists.TryGetValue(assetId, out requestList)) - { - } - else + if (!RequestLists.TryGetValue(assetId, out requestList)) { requestList = new AssetRequestsList(assetId); RequestLists.Add(assetId, requestList); -- cgit v1.1 From d725d1208bfbeae02f181cc6731f5a98dc7fce6d Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 19 May 2008 11:38:35 +0000 Subject: adding OSHttpRequest and OSHttpResponse which wrap HttpListenerRequest and HttpListenerResponse respectively. enhancing IStreamHandler and IStreamedHandler interfaces so that OSHttp{Request,Response} get passed in, allowing RestHandlers to set response status code, redirections, etc. --- OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 8683cea..c5cb268 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -27,6 +27,7 @@ using System.Collections; using System.IO; +using System.Net; using System.Text; using OpenSim.Framework.Servers; @@ -43,7 +44,8 @@ namespace OpenSim.Framework.Communications.Capabilities m_method = method; } - public override byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) { //Encoding encoding = Encoding.UTF8; //StreamReader streamReader = new StreamReader(request, false); -- cgit v1.1 From 9808f39b6f21c26ac0e8cf9c8a04cc8ab2bfa7e9 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 19 May 2008 19:08:59 +0000 Subject: i can haz pantz? You sure can. This change set restores pants (and the rest of the default appearance) in grid mode. The root issue had to do with serializing multi-faced textures to the grid server. This also restores the lookup path through the avatar factory module, as that seems the reasonable place to have it live. Some clean up patches are coming later as well, plus testing on standalone, but this should be in a good kicking around state for grid users. --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 5a62682..87e06f1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -611,7 +611,7 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); } } - return new AvatarAppearance(); + return null; } public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) -- cgit v1.1 From 01b5425a2dc4e7675db9fceebc693479b37890ca Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 19 May 2008 20:05:10 +0000 Subject: Thank you kindly, Melanie for a patch that avoids a null ref in inventory give and also now causes items to appear in the correct folders now, no longer in the root folder. --- .../Communications/Cache/CachedUserInfo.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f40f078..1cbffc7 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -485,6 +485,14 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { + if(item.Folder == LLUUID.Zero) + { + InventoryFolderImpl f=FindFolderForType(item.AssetType); + if(f != null) + item.Folder=f.ID; + else + item.Folder=RootFolder.ID; + } ItemReceive(item); m_commsManager.InventoryService.AddItem(item); } @@ -606,6 +614,22 @@ namespace OpenSim.Framework.Communications.Cache return true; } } + + private InventoryFolderImpl FindFolderForType(int type) + { + if(RootFolder == null) + return null; + + lock(RootFolder.SubFolders) + { + foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values) + { + if(f.Type == type) + return f; + } + } + return null; + } } /// -- cgit v1.1 From 535d64b66b4d51d1dc474f9d6403f94c06be5491 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 20 May 2008 15:38:49 +0000 Subject: Add copyright notices. Fix spelling typo (Thanks ChrisDown for pointing this out) --- .../Framework/Communications/GenericAsyncResult.cs | 27 ++++++++++++++++++++++ OpenSim/Framework/Communications/RestClient.cs | 27 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index 48f72a0..e85289a 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Threading; diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7c8876a..e1b2b39 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections.Generic; using System.IO; -- cgit v1.1 From a53cea6b7e4094ea51339c80ab5fe160a19a9f6b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 20 May 2008 16:51:45 +0000 Subject: i'm extending the RestStreamHandler.Handler(...) signature to actually provide OSHttpRequest and OSHttpResponse to our REST handler. also, this adds proper RestPlugin.IsGod() checking against the X-OpenSim-Godkey HTTP request header. last, i added XML doc comments to RestPlugin.cs --- OpenSim/Framework/Communications/CAPSService.cs | 3 ++- OpenSim/Framework/Communications/Capabilities/Caps.cs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index caf96ff..07bea9d 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -45,7 +45,8 @@ namespace OpenSim.Framework.Communications m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); } - public string CapsRequest(string request, string path, string param) + public string CapsRequest(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) { System.Console.WriteLine("new caps request " + request + " from path " + path); return String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 9725c94..8d8f945 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -208,8 +208,11 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// + /// HTTP request header object + /// HTTP response header object /// - public string CapsRequest(string request, string path, string param) + public string CapsRequest(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); //Console.WriteLine("caps request " + request); @@ -503,8 +506,11 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// + /// HTTP request header object + /// HTTP response header object /// - public string ScriptTaskInventory(string request, string path, string param) + public string ScriptTaskInventory(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) { try { @@ -558,7 +564,8 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - public string NoteCardAgentInventory(string request, string path, string param) + public string NoteCardAgentInventory(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); -- cgit v1.1 From 1f57fd4becda90486ba1bc0f102574855ae6fbac Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 22 May 2008 00:41:03 +0000 Subject: * Minor: Tidy ups and logging tweaks. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 805adb0..796be5b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -561,7 +561,7 @@ namespace OpenSim.Framework.Communications.Cache // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. if (null == asset) { - m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing", requestID); + //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); return; } -- cgit v1.1 From 61bba6375c91ba246e5139c1f449d03169ce31ce Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 22 May 2008 00:49:17 +0000 Subject: * Fix mantis 1325. This is a minor issue where 'show assets' would not work fully in the region console --- .../Framework/Communications/Cache/AssetCache.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 796be5b..3ae18f1 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -104,22 +104,28 @@ namespace OpenSim.Framework.Communications.Cache foreach (TextureImage texture in Textures.Values) { - if (texture.Temporary) + if (texture != null) { - temporaryImages++; - } + if (texture.Temporary) + { + temporaryImages++; + } - imageBytes += texture.Data.GetLongLength(0); + imageBytes += texture.Data.GetLongLength(0); + } } foreach (AssetInfo asset in Assets.Values) { - if (asset.Temporary) + if (asset != null) { - temporaryAssets++; - } + if (asset.Temporary) + { + temporaryAssets++; + } - assetBytes += asset.Data.GetLongLength(0); + assetBytes += asset.Data.GetLongLength(0); + } } m_log.InfoFormat("Temporary Images: {0} Temporary Assets: {1}", -- cgit v1.1 From 5d77625e9ac4ce1fc7b8fd67aabf563678ef0d5d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 25 May 2008 23:27:38 +0000 Subject: Update svn properties. Formatting cleanup. --- OpenSim/Framework/Communications/CAPSService.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 6 +++--- OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index 07bea9d..0507173 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); } - public string CapsRequest(string request, string path, string param, + public string CapsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { System.Console.WriteLine("new caps request " + request + " from path " + path); diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 8d8f945..c2b0046 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// HTTP request header object /// HTTP response header object /// - public string CapsRequest(string request, string path, string param, + public string CapsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); @@ -509,7 +509,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// HTTP request header object /// HTTP response header object /// - public string ScriptTaskInventory(string request, string path, string param, + public string ScriptTaskInventory(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { try @@ -564,7 +564,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - public string NoteCardAgentInventory(string request, string path, string param, + public string NoteCardAgentInventory(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index c5cb268..36090e1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_method = method; } - public override byte[] Handle(string path, Stream request, + public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { //Encoding encoding = Encoding.UTF8; -- cgit v1.1 From 2cea74181ac01574c36dae97d8140f003d69e68c Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 27 May 2008 13:40:00 +0000 Subject: Thank you very much, Xantor for a patch that: If a request is made for an asset which is not in the cache yet, but has already been requested by something else, queue up the callbacks on that requester instead of swamping the asset server with multiple requests for the same asset. --- .../Framework/Communications/Cache/AssetCache.cs | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3ae18f1..feac65a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -248,6 +248,12 @@ namespace OpenSim.Framework.Communications.Cache { //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); + + // Xantor 20080526: + // if a request is made for an asset which is not in the cache yet, but has already been requested by + // something else, queue up the callbacks on that requestor instead of swamping the assetserver + // with multiple requests for the same asset. + AssetBase asset; if (TryGetCachedAsset(assetId, out asset)) @@ -257,9 +263,33 @@ namespace OpenSim.Framework.Communications.Cache else { #if DEBUG - //m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); + // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); #endif + + + NewAssetRequest req = new NewAssetRequest(assetId, callback); + AssetRequestsList requestList; + + lock (RequestLists) + { + if (RequestLists.TryGetValue(assetId, out requestList)) // do we already have a request pending? + { + // m_log.DebugFormat("[ASSET CACHE]: Intercepted Duplicate request for {0} {1}", isTexture ? "texture" : "asset", assetId); + // add to callbacks for this assetId + RequestLists[assetId].Requests.Add(req); + } + else + { + // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); + requestList = new AssetRequestsList(assetId); + RequestLists.Add(assetId, requestList); + requestList.Requests.Add(req); + m_assetServer.RequestAsset(assetId, isTexture); + } + } + + /* Old code doesn't handle duplicate requests right NewAssetRequest req = new NewAssetRequest(assetId, callback); // Make sure we always have a request list to which to add the asset @@ -278,6 +308,7 @@ namespace OpenSim.Framework.Communications.Cache requestList.Requests.Add(req); m_assetServer.RequestAsset(assetId, isTexture); + */ } } @@ -447,6 +478,8 @@ namespace OpenSim.Framework.Communications.Cache foreach (NewAssetRequest req in theseRequests) { + // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked + // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); req.Callback(asset.FullID, asset); } } -- cgit v1.1 From 5752c1f5c2ee069e2ff5ffc0ff2f186d7454c5c4 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 28 May 2008 03:44:49 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 20 ++++++++++---------- .../Framework/Communications/Cache/CachedUserInfo.cs | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index feac65a..dcb7d73 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -249,11 +249,11 @@ namespace OpenSim.Framework.Communications.Cache //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); - // Xantor 20080526: + // Xantor 20080526: // if a request is made for an asset which is not in the cache yet, but has already been requested by - // something else, queue up the callbacks on that requestor instead of swamping the assetserver + // something else, queue up the callbacks on that requestor instead of swamping the assetserver // with multiple requests for the same asset. - + AssetBase asset; if (TryGetCachedAsset(assetId, out asset)) @@ -265,8 +265,8 @@ namespace OpenSim.Framework.Communications.Cache #if DEBUG // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); #endif - - + + NewAssetRequest req = new NewAssetRequest(assetId, callback); AssetRequestsList requestList; @@ -499,7 +499,7 @@ namespace OpenSim.Framework.Communications.Cache { Assets[assetID] = null; } - + // Notify requesters for this asset AssetRequestsList reqList = null; lock (RequestLists) @@ -590,20 +590,20 @@ namespace OpenSim.Framework.Communications.Cache RequestedAssets.Add(requestID, request); m_assetServer.RequestAsset(requestID, false); } - + return; } - + // It has an entry in our cache AssetInfo asset = Assets[requestID]; - + // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. if (null == asset) { //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); return; } - + // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 1cbffc7..b98cec7 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -485,10 +485,10 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - if(item.Folder == LLUUID.Zero) + if (item.Folder == LLUUID.Zero) { InventoryFolderImpl f=FindFolderForType(item.AssetType); - if(f != null) + if (f != null) item.Folder=f.ID; else item.Folder=RootFolder.ID; @@ -617,14 +617,14 @@ namespace OpenSim.Framework.Communications.Cache private InventoryFolderImpl FindFolderForType(int type) { - if(RootFolder == null) + if (RootFolder == null) return null; - lock(RootFolder.SubFolders) + lock (RootFolder.SubFolders) { foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values) { - if(f.Type == type) + if (f.Type == type) return f; } } -- cgit v1.1 From 9cefda83d6d54edc9ed1587bb71e9cb8fb2d17d5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 29 May 2008 23:36:37 +0000 Subject: * Caches UUIDName requests * Looks up UUIDNames for script time and colliders in a separate thread. * Hopefully this'll allow you to look at top scripts on a region that has a lot of scripts without crashing your client thread. --- .../Communications/CommunicationsManager.cs | 61 ++++++++++++++++++---- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 37020f6..cc64e6c 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -41,6 +41,7 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IUserService m_userService; + protected Dictionary m_nameRequestCache = new Dictionary(); public IUserService UserService { @@ -248,27 +249,69 @@ namespace OpenSim.Framework.Communications } else { + string[] names = doUUIDNameRequest(uuid); + if (names.Length == 2) + { + remote_client.SendNameReply(uuid, names[0], names[1]); + } + + } + } + + private string[] doUUIDNameRequest(LLUUID uuid) + { + string[] returnstring = new string[0]; + bool doLookup = false; + + + lock (m_nameRequestCache) + { + if (m_nameRequestCache.ContainsKey(uuid)) + { + returnstring = m_nameRequestCache[uuid]; + } + else + { + // we don't want to lock the dictionary while we're doing the lookup + doLookup = true; + } + } + + if (doLookup) { UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) { + returnstring = new string[2]; LLUUID profileId = profileData.ID; - string firstname = profileData.FirstName; - string lastname = profileData.SurName; - - remote_client.SendNameReply(profileId, firstname, lastname); + returnstring[0] = profileData.FirstName; + returnstring[1] = profileData.SurName; + lock (m_nameRequestCache) + { + if (!m_nameRequestCache.ContainsKey(uuid)) + m_nameRequestCache.Add(uuid, returnstring); + } } } + return returnstring; + } + + public bool UUIDNameCachedTest(LLUUID uuid) + { + lock (m_nameRequestCache) + return m_nameRequestCache.ContainsKey(uuid); + } + public string UUIDNameRequestString(LLUUID uuid) { - UserProfileData profileData = m_userService.GetUserProfile(uuid); - if (profileData != null) + string[] names = doUUIDNameRequest(uuid); + if (names.Length == 2) { - //LLUUID profileId = profileData.ID; - string firstname = profileData.FirstName; - string lastname = profileData.SurName; + string firstname = names[0]; + string lastname = names[1]; return firstname + " " + lastname; + } return "(hippos)"; } -- cgit v1.1 From 04625109560fb54d613b1fc9c81a8a9f387720c9 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 30 May 2008 08:35:57 +0000 Subject: Update svn properties. Formatting cleanup. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index cc64e6c..e8353b4 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -255,28 +255,28 @@ namespace OpenSim.Framework.Communications remote_client.SendNameReply(uuid, names[0], names[1]); } - } + } } private string[] doUUIDNameRequest(LLUUID uuid) { string[] returnstring = new string[0]; bool doLookup = false; - - + + lock (m_nameRequestCache) { if (m_nameRequestCache.ContainsKey(uuid)) { returnstring = m_nameRequestCache[uuid]; } - else + else { // we don't want to lock the dictionary while we're doing the lookup doLookup = true; } } - + if (doLookup) { UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) @@ -293,7 +293,7 @@ namespace OpenSim.Framework.Communications } } return returnstring; - + } public bool UUIDNameCachedTest(LLUUID uuid) @@ -311,7 +311,7 @@ namespace OpenSim.Framework.Communications string lastname = names[1]; return firstname + " " + lastname; - + } return "(hippos)"; } -- cgit v1.1 From febe78d06249cd4d36a86e97610dd45ab518a757 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 31 May 2008 12:18:29 +0000 Subject: * Implements UserServer logoff in a few situations * User tries to log-in but is already logged in. Userserver will send message to simulator user was in to log the user out there. * From the UserServer, admin types 'logoff-user firstname lastname message'. * Some regions may not get the message because they're not updated yet. --- OpenSim/Framework/Communications/IUserService.cs | 7 +++++++ OpenSim/Framework/Communications/LoginService.cs | 15 ++++++++++++++- OpenSim/Framework/Communications/UserManagerBase.cs | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 67a8c78..59ad188 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -113,6 +113,13 @@ namespace OpenSim.Framework.Communications /// Get's the User Appearance AvatarAppearance GetUserAppearance(LLUUID user); + /// + /// Updates the current region the User is in + /// + /// User Region the Avatar is IN + /// User Region the Avatar is IN + void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle); + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); void AddAttachment(LLUUID user, LLUUID attach); diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index bd0fa53..08b071f 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -79,7 +79,15 @@ namespace OpenSim.Framework.Communications /// The existing response /// The user profile public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); + + /// + /// If the user is already logged in, try to notify the region that the user they've got is dead. + /// + /// + public virtual void LogOffUser(UserProfileData theUser, string message) + { + } /// /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. /// @@ -196,9 +204,14 @@ namespace OpenSim.Framework.Communications // because of some problem, for instance, the crashment of server or client, // the user cannot log in any longer. userProfile.CurrentAgent.AgentOnline = false; - m_userManager.CommitAgent(ref userProfile); + m_userManager.CommitAgent(ref userProfile); + + // try to tell the region that their user is dead. + LogOffUser(userProfile, "You were logged off because you logged in from another location"); + // Reject the login + m_log.InfoFormat( "[LOGIN END]: Notifying user {0} {1} that they are already logged in", diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 87e06f1..8985bb6 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -187,6 +187,21 @@ namespace OpenSim.Framework.Communications return null; } + public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); + } + catch (Exception e) + { + m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + /// /// Loads a user's friend list /// -- cgit v1.1 From d20cae2d03f26f92e88f28ec187de50934144fcb Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 1 Jun 2008 10:05:22 +0000 Subject: * Committing more unfinished stuff. Nothing significant at the moment. IM related. --- OpenSim/Framework/Communications/IUserService.cs | 2 ++ OpenSim/Framework/Communications/UserManagerBase.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 59ad188..a7f19e7 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -49,6 +49,8 @@ namespace OpenSim.Framework.Communications /// A user profile. Returns null if no user profile is found. UserProfileData GetUserProfile(LLUUID userId); + UserAgentData GetAgentByUUID(LLUUID userId); + void clearUserAgent(LLUUID avatarID); List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 8985bb6..fe09b03 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -103,7 +103,20 @@ namespace OpenSim.Framework.Communications return null; } + public UserAgentData GetAgentByUUID(LLUUID userId) + { + foreach (KeyValuePair plugin in _plugins) + { + UserAgentData agent = plugin.Value.GetAgentByUUID(userId); + if (agent != null) + { + return agent; + } + } + + return null; + } // see IUserService public UserProfileData GetUserProfile(LLUUID uuid) { -- cgit v1.1 From 5f6b26d9ba20ef41ead8ecc178c624c9f187fdd1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 2 Jun 2008 20:28:26 +0000 Subject: provide slightly more sane defaults in the file based asset loader --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index ca7eb13..1ff6350 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -208,12 +208,12 @@ namespace OpenSim.Framework.Communications.Cache item.Owner = libOwner; item.Creator = libOwner; item.ID = new LLUUID(config.GetString("inventoryID", ID.ToString())); - item.AssetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); + item.AssetID = new LLUUID(config.GetString("assetID", item.ID.ToString())); item.Folder = new LLUUID(config.GetString("folderID", ID.ToString())); - item.Description = config.GetString("description", String.Empty); item.Name = config.GetString("name", String.Empty); - item.AssetType = config.GetInt("assetType", 0); + item.Description = config.GetString("description", item.Name); item.InvType = config.GetInt("inventoryType", 0); + item.AssetType = config.GetInt("assetType", item.InvType); item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); -- cgit v1.1 From 67dee6410dcb982b899ec0bb9644d5afa4a8e2d1 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 4 Jun 2008 13:06:24 +0000 Subject: * fleshing out XMPP entities, adding XmppWriter and XmppSerializer having spent the last couple of days wrestling with .NET XmlSerializer and trying to get it to do what is required by XMPP (RFC 3920 & 3921) this is the preliminary result of that wrestling (you should see the other guy!): XmppSerializer allows us to serialize Xmpp stanza (and theoretically deserialize [or reify] them), XmppWriter helps avoiding various gratuitous crap added in by off-the-shelf XmlSerializer. this is currently not used anywhere but the plan is to use it for at least an XMPPBridgeModule. --- OpenSim/Framework/Communications/XMPP/Stanza.cs | 55 ------------- .../Framework/Communications/XMPP/XMPPParser.cs | 34 -------- OpenSim/Framework/Communications/XMPP/XmppError.cs | 41 ++++++++++ .../Framework/Communications/XMPP/XmppIqStanza.cs | 62 +++++++++++++++ .../Communications/XMPP/XmppMessageStanza.cs | 90 ++++++++++++++++++++++ .../Communications/XMPP/XmppSerializer.cs | 65 ++++++++++++++++ .../Framework/Communications/XMPP/XmppStanza.cs | 71 +++++++++++++++++ .../Framework/Communications/XMPP/XmppWriter.cs | 58 ++++++++++++++ 8 files changed, 387 insertions(+), 89 deletions(-) delete mode 100644 OpenSim/Framework/Communications/XMPP/Stanza.cs delete mode 100644 OpenSim/Framework/Communications/XMPP/XMPPParser.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppError.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppSerializer.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppStanza.cs create mode 100644 OpenSim/Framework/Communications/XMPP/XmppWriter.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/Stanza.cs b/OpenSim/Framework/Communications/XMPP/Stanza.cs deleted file mode 100644 index 3930bac..0000000 --- a/OpenSim/Framework/Communications/XMPP/Stanza.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Xml; - -namespace OpenSim.Framework.Communications.XMPP -{ - public class Stanza - { - public string localName = String.Empty; - public JId to; - public JId from; - public string id; - public string lang; - public string nodeName; - - public Stanza(XmlNode node, Object defaults, bool hasID) - { - - } - //public virtual XmlElement getNode() - //{ - //return new XmlElement(); - //} - public virtual string generateId() - { - return ""; - } - } -} diff --git a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs b/OpenSim/Framework/Communications/XMPP/XMPPParser.cs deleted file mode 100644 index 26a78b2..0000000 --- a/OpenSim/Framework/Communications/XMPP/XMPPParser.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -namespace OpenSim.Framework.Communications.XMPP -{ - public class XMPPParser - { - - } -} diff --git a/OpenSim/Framework/Communications/XMPP/XmppError.cs b/OpenSim/Framework/Communications/XMPP/XmppError.cs new file mode 100644 index 0000000..1698b6a --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppError.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + [XmlRoot("error")] + public class XmppErrorStanza + { + public XmppErrorStanza() + { + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs new file mode 100644 index 0000000..1789536 --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs @@ -0,0 +1,62 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + /// + /// An IQ needs to have one of the follow types set. + /// + public enum XmppIqType + { + [XmlEnum("set")] set, + [XmlEnum("get")] get, + [XmlEnum("result")] result, + [XmlEnum("error")] error, + } + + /// + /// XmppIqStanza needs to be subclassed as the query content is + /// specific to the query type. + /// + [XmlRoot("iq")] + public abstract class XmppIqStanza: XmppStanza + { + /// + /// IQ type: one of set, get, result, error + /// + [XmlAttribute("type")] + public XmppIqType Type; + + public XmppIqStanza(): base() + { + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs new file mode 100644 index 0000000..e80c0aa --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs @@ -0,0 +1,90 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + /// + /// Message types. + /// + public enum XmppMessageType + { + [XmlEnum("chat")] chat, + [XmlEnum("error")] error, + [XmlEnum("groupchat")] groupchat, + [XmlEnum("headline")] headline, + [XmlEnum("normal")] normal, + } + + /// + /// Message body. + /// + public class XmppMessageBody + { + [XmlText] + public string Text; + + public XmppMessageBody() + { + } + + public XmppMessageBody(string message) + { + Text = message; + } + } + + [XmlRoot("message")] + public class XmppMessageStanza: XmppStanza + { + /// + /// IQ type: one of set, get, result, error + /// + [XmlAttribute("type")] + public XmppMessageType MessageType; + + // [XmlAttribute("error")] + // public XmppError Error; + + [XmlElement("body")] + public XmppMessageBody Body; + + public XmppMessageStanza() : base() + { + } + + public XmppMessageStanza(string fromJid, string toJid, XmppMessageType mType, string message) : + base(fromJid, toJid) + { + MessageType = mType; + Body = new XmppMessageBody(message); + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs new file mode 100644 index 0000000..f0d2cd5 --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + public class XMPPSerializer + { + // need to do it this way, as XmlSerializer(type, extratypes) + // does not work on mono (at least). + private Dictionary _serializers = new Dictionary(); + private XmlSerializerNamespaces _xmlNs; + private string _defaultNS; + + public XMPPSerializer(bool server) + { + _xmlNs = new XmlSerializerNamespaces(); + _xmlNs.Add(String.Empty, String.Empty); + if (server) + _defaultNS = "jabber:server"; + else + _defaultNS = "jabber:client"; + + _serializers[typeof(XmppMessageStanza)] = new XmlSerializer(typeof(XmppMessageStanza), _defaultNS); + } + + public void Serialize(XmlWriter xw, object o) + { + if (!_serializers.ContainsKey(o.GetType())) + throw new ArgumentException(String.Format("no serializer available for type {0}", o.GetType())); + + _serializers[o.GetType()].Serialize(xw, o, _xmlNs); + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs new file mode 100644 index 0000000..00df14a --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + public abstract class XmppStanza + { + /// + /// counter used for generating ID + /// + [XmlIgnore] + private static ulong _ctr = 0; + + /// + /// recipient JID + /// + [XmlAttribute("to")] + public string ToJid; + + /// + /// sender JID + /// + [XmlAttribute("from")] + public string FromJid; + + /// + /// unique ID. + /// + [XmlAttribute("id")] + public string MessageId; + + public XmppStanza() + { + } + + public XmppStanza(string fromJid, string toJid) + { + ToJid = toJid; + FromJid = fromJid; + MessageId = String.Format("OpenSim_{0}{1}", DateTime.UtcNow.Ticks, _ctr++); + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs new file mode 100644 index 0000000..c5ad9b4 --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.IO; +using System.Text; +using System.Xml; + +using IOStream = System.IO.Stream; + +namespace OpenSim.Framework.Communications.XMPP +{ + public class XMPPWriter: XmlTextWriter + { + public XMPPWriter(TextWriter textWriter) : base(textWriter) + { + } + + public XMPPWriter(IOStream stream) : this(stream, Encoding.UTF8) + { + } + + public XMPPWriter(IOStream stream, Encoding enc) : base(stream, enc) + { + } + + public override void WriteStartDocument() + { + } + + public override void WriteStartDocument(bool standalone) + { + } + } +} -- cgit v1.1 From caee0288fbf5fdc2abfbaa0890d3de62110de324 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 4 Jun 2008 18:09:55 +0000 Subject: * adding XmppPresenceStanza and deserialization/reification support having reached the intermediate level of .NET's XmlSudoku, i've now figured out how to do deserialization using different XmlSerializers (this stuff begins to grow on me, sigh). [still not used code, work-in-progress] * adding convenience property on OSHttpRequest.cs (from awebb) --- .../Communications/XMPP/XmppMessageStanza.cs | 5 ++ .../Communications/XMPP/XmppPresenceStanza.cs | 71 ++++++++++++++++++++++ .../Communications/XMPP/XmppSerializer.cs | 30 +++++++-- 3 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs index e80c0aa..b221459 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs @@ -59,6 +59,11 @@ namespace OpenSim.Framework.Communications.XMPP { Text = message; } + + public string ToString() + { + return Text; + } } [XmlRoot("message")] diff --git a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs new file mode 100644 index 0000000..d63a0d1 --- /dev/null +++ b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.XMPP +{ + /// + /// Message types. + /// + public enum XmppPresenceType + { + [XmlEnum("unavailable")] unavailable, + [XmlEnum("subscribe")] subscribe, + [XmlEnum("subscribed")] subscribed, + [XmlEnum("unsubscribe")] unsubscribe, + [XmlEnum("unsubscribed")] unsubscribed, + [XmlEnum("probe")] probe, + [XmlEnum("error")] error, + } + + + [XmlRoot("message")] + public class XmppPresenceStanza: XmppStanza + { + /// + /// IQ type: one of set, get, result, error + /// + [XmlAttribute("type")] + public XmppPresenceType PresenceType; + + // [XmlAttribute("error")] + // public XmppError Error; + + public XmppPresenceStanza() : base() + { + } + + public XmppPresenceStanza(string fromJid, string toJid, XmppPresenceType pType) : + base(fromJid, toJid) + { + PresenceType = pType; + } + } +} diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs index f0d2cd5..30a9eac 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs @@ -28,21 +28,27 @@ using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Text; using System.Xml; using System.Xml.Serialization; +using log4net; namespace OpenSim.Framework.Communications.XMPP { - public class XMPPSerializer + public class XmppSerializer { + private static readonly ILog _log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // need to do it this way, as XmlSerializer(type, extratypes) // does not work on mono (at least). - private Dictionary _serializers = new Dictionary(); + private Dictionary _serializerForType = new Dictionary(); + private Dictionary _serializerForName = new Dictionary(); private XmlSerializerNamespaces _xmlNs; private string _defaultNS; - public XMPPSerializer(bool server) + public XmppSerializer(bool server) { _xmlNs = new XmlSerializerNamespaces(); _xmlNs.Add(String.Empty, String.Empty); @@ -51,15 +57,27 @@ namespace OpenSim.Framework.Communications.XMPP else _defaultNS = "jabber:client"; - _serializers[typeof(XmppMessageStanza)] = new XmlSerializer(typeof(XmppMessageStanza), _defaultNS); + // TODO: do this via reflection + _serializerForType[typeof(XmppMessageStanza)] = _serializerForName["message"] = + new XmlSerializer(typeof(XmppMessageStanza), _defaultNS); } public void Serialize(XmlWriter xw, object o) { - if (!_serializers.ContainsKey(o.GetType())) + if (!_serializerForType.ContainsKey(o.GetType())) throw new ArgumentException(String.Format("no serializer available for type {0}", o.GetType())); - _serializers[o.GetType()].Serialize(xw, o, _xmlNs); + _serializerForType[o.GetType()].Serialize(xw, o, _xmlNs); + } + + public object Deserialize(XmlReader xr) + { + // position on next element + xr.Read(); + if (!_serializerForName.ContainsKey(xr.LocalName)) + throw new ArgumentException(String.Format("no serializer available for name {0}", xr.LocalName)); + + return _serializerForName[xr.LocalName].Deserialize(xr); } } } -- cgit v1.1 From fbd37c420fff59968b31dfa8b4f25b23ca72d466 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 6 Jun 2008 01:19:15 +0000 Subject: Minor formatting cleanup. --- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index bcf7a88..aa9951c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -676,4 +676,4 @@ namespace OpenSim.Framework.Communications.Capabilities } } } -} \ No newline at end of file +} -- cgit v1.1 From 3794f25ebd4dae48c4eabfa3d63a4d4c30a5aa30 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 10 Jun 2008 23:35:04 +0000 Subject: * minor: Properly clear the pushed asset cache statistics where the clear-assets command is used on the region console * stop waiting for garbage collection when GC total memory used is requested, in case the periodic request of this lags the sim --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dcb7d73..dd9015b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -143,6 +143,10 @@ namespace OpenSim.Framework.Communications.Cache public void Clear() { m_log.Info("[ASSET CACHE]: Clearing Asset cache"); + + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.ClearAssetCacheStatistics(); + Initialize(); } -- cgit v1.1 From 7821cca2f5a7c31a41446656f218fdaf450969c0 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 11 Jun 2008 14:02:16 +0000 Subject: Mantis#1514. Thank you kindly, Boscata for an InventoryServer patch to allow the InventoryServer to work with MSSQL.. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/IInventoryServices.cs | 7 +++++++ OpenSim/Framework/Communications/InventoryServiceBase.cs | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b98cec7..d010bd5 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -379,7 +379,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short) type; baseFolder.Version = RootFolder.Version; - m_commsManager.InventoryService.AddFolder(baseFolder); + m_commsManager.InventoryService.UpdateFolder(baseFolder); } else { diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index f7a8857..8dc09bc 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -58,6 +58,13 @@ namespace OpenSim.Framework.Communications bool AddFolder(InventoryFolderBase folder); /// + /// Update a folder in the user's inventory + /// + /// + /// true if the folder was successfully updated + bool UpdateFolder(InventoryFolderBase folder); + + /// /// Move an inventory folder to a new location /// /// A folder containing the details of the new location diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index dffeed3..89ccf93 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -199,6 +199,21 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices + public bool UpdateFolder(InventoryFolderBase folder) + { + m_log.DebugFormat( + "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + + foreach (KeyValuePair plugin in m_plugins) + { + plugin.Value.updateInventoryFolder(folder); + } + + // FIXME: Should return false on failure + return true; + } + + // See IInventoryServices public bool MoveFolder(InventoryFolderBase folder) { m_log.DebugFormat( -- cgit v1.1 From 5219eb74209d83f1a240a75528fad9d302b84f0e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 12 Jun 2008 20:19:42 +0000 Subject: * Split the World Map code into a module. * Implemented a hack so regions beyond the 10,000m range will show the map without having to click on the map before they'll start to show. The hack shows regions around the one you're in, but it won't show the one you're in.. you still need to click on the map to get that (not sure why yet). Additionally, the map still only shows pictures for regions that are hosted on the same instance (no change). --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index c2b0046..2bfcaca 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -135,10 +135,10 @@ namespace OpenSim.Framework.Communications.Capabilities { // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); - m_capsHandlers["MapLayer"] = - new LLSDStreamhandler("POST", - capsBase + m_mapLayerPath, - GetMapLayer); + //m_capsHandlers["MapLayer"] = + // new LLSDStreamhandler("POST", + // capsBase + m_mapLayerPath, + // GetMapLayer); m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler("POST", capsBase + m_newInventory, @@ -420,6 +420,7 @@ namespace OpenSim.Framework.Communications.Capabilities mapLayer.Right = 5000; mapLayer.Top = 5000; mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); + return mapLayer; } -- cgit v1.1 From 520da0d9ff5721b05db89bed628d461b39f7fcb8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 13 Jun 2008 16:23:31 +0000 Subject: * minor: comment out confusing DefaultTimeout field in RestClient, which is currently not actually used --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e1b2b39..f6c33a8 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -110,7 +110,7 @@ namespace OpenSim.Framework.Communications /// /// Default time out period /// - private const int DefaultTimeout = 10*1000; // 10 seconds timeout + //private const int DefaultTimeout = 10*1000; // 10 seconds timeout /// /// Default Buffer size of a block requested from the web-server -- cgit v1.1 From d6519924ba096c569294aa6653e6720629002f8e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 13 Jun 2008 18:04:01 +0000 Subject: * refactor: catch asset service request exceptions at the AssetServerBase level rather than in the GridAssetClient * this is to enable logging of asset request exceptions soon --- .../Communications/Cache/AssetServerBase.cs | 23 +++++++++++-- .../Communications/Cache/GridAssetClient.cs | 38 +++++++++------------- 2 files changed, 35 insertions(+), 26 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index db71079..053cb0f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -57,6 +57,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// + /// + /// Thrown if the request failed for some other reason than that the + /// asset cannot be found. + /// protected abstract AssetBase GetAsset(AssetRequest req); /// @@ -66,17 +70,30 @@ namespace OpenSim.Framework.Communications.Cache /// protected virtual void ProcessRequest(AssetRequest req) { - AssetBase asset = GetAsset(req); + AssetBase asset; + + try + { + asset = GetAsset(req); + } + catch (Exception e) + { + m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1}", req.AssetID, e); + + m_receiver.AssetNotFound(req.AssetID, req.IsTexture); + + return; + } if (asset != null) { - //m_log.InfoFormat("[ASSETSERVER]: Asset {0} received from asset server", req.AssetID); + m_log.DebugFormat("[ASSET]: Asset {0} received from asset server", req.AssetID); m_receiver.AssetReceived(asset, req.IsTexture); } else { - //m_log.ErrorFormat("[ASSET SERVER]: Asset {0} not found by asset server", req.AssetID); + m_log.WarnFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID); m_receiver.AssetNotFound(req.AssetID, req.IsTexture); } diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 4b4ef17..7787805 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -49,38 +49,30 @@ namespace OpenSim.Framework.Communications.Cache protected override AssetBase GetAsset(AssetRequest req) { - Stream s = null; - try - { - #if DEBUG - //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); - #endif + #if DEBUG + //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); + #endif - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(req.AssetID.ToString()); - if (req.IsTexture) - rc.AddQueryParameter("texture"); + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); - rc.RequestMethod = "GET"; - s = rc.Request(); + rc.RequestMethod = "GET"; + + Stream s = rc.Request(); - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); - - return (AssetBase) xs.Deserialize(s); - } - } - catch (Exception e) + if (s.Length > 0) { - m_log.ErrorFormat("[GRID ASSET CLIENT]: Failed to get asset {0}, {1}", req.AssetID, e); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + + return (AssetBase) xs.Deserialize(s); } return null; } - public override void UpdateAsset(AssetBase asset) { throw new Exception("The method or operation is not implemented."); -- cgit v1.1 From b47dd079326ae55e23f60a3de8e5fb2d2e62ae30 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 13 Jun 2008 19:41:13 +0000 Subject: save_assets_to_file path shouldn't always assume uploaded content are images and use .jp2 for the file extension. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 2bfcaca..5249aa2 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -780,9 +780,16 @@ namespace OpenSim.Framework.Communications.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); + // TODO: probably make this a better set of extensions here + string extension = ".jp2"; + if (m_invType != "image") + { + extension = ".dat"; + } + if (m_dumpAssetsToFile) { - SaveAssetToFile(m_assetName + ".jp2", data); + SaveAssetToFile(m_assetName + extension, data); } handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) -- cgit v1.1 From 4af62865122121069638ed51f3c799a265800a4c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 14 Jun 2008 17:47:25 +0000 Subject: * Start recording asset request failures * This includes problems such as connection failures and timeouts. It does not include 'asset not found' replies from the asset service. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 053cb0f..74b1976 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -31,6 +31,7 @@ using System.Threading; using libsecondlife; using log4net; using OpenSim.Framework.AssetLoader.Filesystem; +using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications.Cache { @@ -80,6 +81,9 @@ namespace OpenSim.Framework.Communications.Cache { m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1}", req.AssetID, e); + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); + m_receiver.AssetNotFound(req.AssetID, req.IsTexture); return; @@ -87,13 +91,13 @@ namespace OpenSim.Framework.Communications.Cache if (asset != null) { - m_log.DebugFormat("[ASSET]: Asset {0} received from asset server", req.AssetID); + //m_log.DebugFormat("[ASSET]: Asset {0} received from asset server", req.AssetID); m_receiver.AssetReceived(asset, req.IsTexture); } else { - m_log.WarnFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID); + //m_log.WarnFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID); m_receiver.AssetNotFound(req.AssetID, req.IsTexture); } -- cgit v1.1 From 4c2171ec827aa426375ccecf4bd2d7e009719d74 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 16 Jun 2008 21:59:39 +0000 Subject: * Allow archiver to save and load objects within other objects to arbitrary levels * This currently has various bugs which are more to do with the way its been hacked together than the feature itself (e.g. on save-oar, ghost prims will appear of the saved contained items). These will be found and eliminated in subsequent patches. * Not yet ready for use --- .../Framework/Communications/Cache/AssetCache.cs | 23 ---------------------- 1 file changed, 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dd9015b..a1d9c73 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -270,7 +270,6 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); #endif - NewAssetRequest req = new NewAssetRequest(assetId, callback); AssetRequestsList requestList; @@ -291,28 +290,6 @@ namespace OpenSim.Framework.Communications.Cache m_assetServer.RequestAsset(assetId, isTexture); } } - - - /* Old code doesn't handle duplicate requests right - NewAssetRequest req = new NewAssetRequest(assetId, callback); - - // Make sure we always have a request list to which to add the asset - AssetRequestsList requestList; - lock (RequestLists) - { - // m_log.Info("AssetCache: Lock taken on requestLists (GetAsset)"); - if (!RequestLists.TryGetValue(assetId, out requestList)) - { - requestList = new AssetRequestsList(assetId); - RequestLists.Add(assetId, requestList); - } - } - // m_log.Info("AssetCache: Lock released on requestLists (GetAsset)"); - - requestList.Requests.Add(req); - - m_assetServer.RequestAsset(assetId, isTexture); - */ } } -- cgit v1.1 From cb29926e3cefedd9bea3c26b1b7f079c8209f6fa Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 18 Jun 2008 23:04:15 +0000 Subject: * Refactors call to OutPacket out of AssetCache and into LLClientView --- .../Framework/Communications/Cache/AssetCache.cs | 85 +++++----------------- 1 file changed, 17 insertions(+), 68 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index a1d9c73..2c51160 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -612,80 +612,29 @@ namespace OpenSim.Framework.Communications.Cache int num = Math.Min(5, AssetRequests.Count); AssetRequest req; + AssetRequestToClient req2 = null; for (int i = 0; i < num; i++) { req = (AssetRequest)AssetRequests[i]; - //Console.WriteLine("sending asset " + req.RequestAssetID); - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - if (req.AssetRequestSource == 2) + if (req2 == null) { - Transfer.TransferInfo.Params = new byte[20]; - Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; - Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); + req2 = new AssetRequestToClient(); } - else if (req.AssetRequestSource == 3) - { - Transfer.TransferInfo.Params = req.Params; - // Transfer.TransferInfo.Params = new byte[100]; - //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); - } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - Transfer.Header.Zerocoded = true; - req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); + // Trying to limit memory usage by only creating AssetRequestToClient if needed + //req2 = new AssetRequestToClient(); + req2.AssetInf = (AssetBase)req.AssetInf; + req2.AssetRequestSource = req.AssetRequestSource; + req2.DataPointer = req.DataPointer; + req2.DiscardLevel = req.DiscardLevel; + req2.ImageInfo = (AssetBase)req.ImageInfo; + req2.IsTextureRequest = req.IsTextureRequest; + req2.NumPackets = req.NumPackets; + req2.PacketCounter = req.PacketCounter; + req2.Params = req.Params; + req2.RequestAssetID = req.RequestAssetID; + req2.TransferRequestID = req.TransferRequestID; + req.RequestUser.SendAsset(req2); - 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; - TransferPacket.Header.Zerocoded = true; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - } - else - { - int processedLength = 0; - // libsecondlife hardcodes 1500 as the maximum data chunk size - int maxChunkSize = 1250; - int packetNumber = 0; - - while (processedLength < req.AssetInf.Data.Length) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = packetNumber; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); - byte[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - - TransferPacket.TransferData.Data = chunk; - - // 0 indicates more packets to come, 1 indicates last packet - if (req.AssetInf.Data.Length - processedLength > maxChunkSize) - { - TransferPacket.TransferData.Status = 0; - } - else - { - TransferPacket.TransferData.Status = 1; - } - TransferPacket.Header.Zerocoded = true; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - processedLength += chunkSize; - packetNumber++; - } - } } //remove requests that have been completed -- cgit v1.1 From 1cd6b71b60d093b451ba03881ee31efd3eb29a50 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 26 Jun 2008 02:46:29 +0000 Subject: Mantis#1594. Thank you, Melanie for a patch that: Fixes: - Wearable icon and name sreset to default on copy/paste - Cache is not updated when renaming/moving folders - Partial refactor to make inventory less dependen on AssetBase having a "Name" field - Add llGiveInventoryList() function --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d010bd5..3127bd6 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -380,6 +380,13 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Version = RootFolder.Version; m_commsManager.InventoryService.UpdateFolder(baseFolder); + + InventoryFolderImpl folder=RootFolder.FindFolder(folderID); + if(folder != null) + { + folder.Name = name; + folder.ParentID = parentID; + } } else { @@ -416,6 +423,10 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager.InventoryService.MoveFolder(baseFolder); + InventoryFolderImpl folder=RootFolder.FindFolder(folderID); + if(folder != null) + folder.ParentID = parentID; + return true; } else -- cgit v1.1 From cea6e03ae0aaea3acba6b844f173ee08259fe101 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 27 Jun 2008 16:18:56 +0000 Subject: dr scofield's warning safari: hunting down those little buggers --- OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs index b221459..fd4cd5f 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Communications.XMPP Text = message; } - public string ToString() + new public string ToString() { return Text; } -- cgit v1.1 From feb30217de48f4b3d869bf13453a945a04ee2524 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 27 Jun 2008 16:58:21 +0000 Subject: dr scofield's warning safari: * commented out [Obsolete(....)] attributes where no replacement feature was available: if we want to attribute code that we think needs to be reworked, we should define a new attribute and use that instead (together with a little tool to retrieve all the attributed code then) * commenting out unused variables --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 10 +++++----- OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 6 +++--- OpenSim/Framework/Communications/RestClient.cs | 9 +++++---- OpenSim/Framework/Communications/XMPP/XmppSerializer.cs | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 5249aa2..5aba086 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -79,17 +79,17 @@ namespace OpenSim.Framework.Communications.Capabilities private CapsHandlers m_capsHandlers; private static readonly string m_requestPath = "0000/"; - private static readonly string m_mapLayerPath = "0001/"; + // private static readonly string m_mapLayerPath = "0001/"; private static readonly string m_newInventory = "0002/"; //private static readonly string m_requestTexture = "0003/"; private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; - private static readonly string m_fetchInventoryPath = "0006/"; + // private static readonly string m_fetchInventoryPath = "0006/"; // The following two entries are in a module, however, there also here so that we don't re-assign // the path to another cap by mistake. - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. - private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. + // private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. + // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -246,7 +246,7 @@ namespace OpenSim.Framework.Communications.Capabilities // multiple fetch-folder maps are allowed within the larger folders map. public string FetchInventoryRequest(string request, string path, string param) { - string unmodifiedRequest = request.ToString(); + // string unmodifiedRequest = request.ToString(); //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e8353b4..5de0c71 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -282,7 +282,7 @@ namespace OpenSim.Framework.Communications if (profileData != null) { returnstring = new string[2]; - LLUUID profileId = profileData.ID; + // LLUUID profileId = profileData.ID; returnstring[0] = profileData.FirstName; returnstring[1] = profileData.SurName; lock (m_nameRequestCache) diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 6fdd06a..113e3f0 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -95,7 +95,7 @@ namespace OpenSim.Framework.Communications // Response private XmlRpcResponse xmlRpcResponse; - private XmlRpcResponse defaultXmlRpcResponse; + // private XmlRpcResponse defaultXmlRpcResponse; private string welcomeMessage; private string startLocation; @@ -117,7 +117,7 @@ namespace OpenSim.Framework.Communications loginError = new Hashtable(); uiConfigHash = new Hashtable(); - defaultXmlRpcResponse = new XmlRpcResponse(); + // defaultXmlRpcResponse = new XmlRpcResponse(); userProfile = new UserInfo(); inventoryRoot = new ArrayList(); initialOutfit = new ArrayList(); @@ -126,7 +126,7 @@ namespace OpenSim.Framework.Communications inventoryLibraryOwner = new ArrayList(); xmlRpcResponse = new XmlRpcResponse(); - defaultXmlRpcResponse = new XmlRpcResponse(); + // defaultXmlRpcResponse = new XmlRpcResponse(); SetDefaultValues(); } diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index f6c33a8..b71a590 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -58,7 +58,7 @@ namespace OpenSim.Framework.Communications { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string realuri; + // private string realuri; #region member variables @@ -229,7 +229,7 @@ namespace OpenSim.Framework.Communications sb.Append(kv.Value); } } - realuri = sb.ToString(); + // realuri = sb.ToString(); //m_log.InfoFormat("[REST CLIENT]: RestURL: {0}", realuri); return new Uri(sb.ToString()); } @@ -250,8 +250,9 @@ namespace OpenSim.Framework.Communications if (read > 0) { _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = - s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + // IAsyncResult asynchronousResult = + // s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); // TODO! Implement timeout, without killing the server //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs index 30a9eac..eb9dabe 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs @@ -38,8 +38,8 @@ namespace OpenSim.Framework.Communications.XMPP { public class XmppSerializer { - private static readonly ILog _log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // private static readonly ILog _log = + // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // need to do it this way, as XmlSerializer(type, extratypes) // does not work on mono (at least). -- cgit v1.1 From 86defd0a69d53df6d352b7d4b9a5b9d6621c19e8 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 15:13:17 +0000 Subject: plumbing for multiple inventory servers. Mostly done on the region server side. TODO next is to make the login server read/write a users inventory from the correct server (the inventory url set in a userprofile) On the region side, although not tested with multiple servers it should work if that inventory url was set, and the inventory servers urls have been added to the CommunicationsManager, using CommunicationsManager.AddInventoryService(string hostUrl) --- .../Communications/Cache/CachedUserInfo.cs | 116 +++++++++++++++++---- .../Cache/UserProfileCacheService.cs | 7 +- .../Communications/CommunicationsManager.cs | 72 +++++++++++-- OpenSim/Framework/Communications/IAvatarService.cs | 21 ++++ .../Framework/Communications/IInventoryServices.cs | 4 + OpenSim/Framework/Communications/IUserService.cs | 8 +- .../Communications/InventoryServiceBase.cs | 5 + 7 files changed, 198 insertions(+), 35 deletions(-) create mode 100644 OpenSim/Framework/Communications/IAvatarService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3127bd6..524f314 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -87,6 +87,24 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); + private string m_inventoryHost + { + get + { + if (m_userProfile != null) + { + if (m_userProfile.UserInventoryURI != String.Empty) + { + Uri uri = new Uri(m_userProfile.UserInventoryURI); + return uri.Host; + } + } + + return ""; + } + + } + /// /// Constructor /// @@ -325,9 +343,15 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddFolder(createdBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddFolder(createdBaseFolder); + return true; + } - return true; + return false; } else { @@ -379,14 +403,19 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short) type; baseFolder.Version = RootFolder.Version; - m_commsManager.InventoryService.UpdateFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - { - folder.Name = name; - folder.ParentID = parentID; - } + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService. + invService.UpdateFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.Name = name; + folder.ParentID = parentID; + } + } } else { @@ -421,13 +450,24 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.InventoryService.MoveFolder(baseFolder); - - InventoryFolderImpl folder=RootFolder.FindFolder(folderID); - if(folder != null) - folder.ParentID = parentID; - - return true; + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + // m_commsManager.InventoryService + invService.MoveFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.ParentID = parentID; + } + + return true; + } + else + { + return false; + } } else { @@ -468,11 +508,16 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.PurgeFolder(purgedBaseFolder); - purgedFolder.Purge(); + purgedFolder.Purge(); - return true; + return true; + } } } else @@ -505,7 +550,13 @@ namespace OpenSim.Framework.Communications.Cache item.Folder=RootFolder.ID; } ItemReceive(item); - m_commsManager.InventoryService.AddItem(item); + + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.AddItem(item); + } } else { @@ -525,7 +576,12 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - m_commsManager.InventoryService.UpdateItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //m_commsManager.InventoryService + invService.UpdateItem(item); + } } else { @@ -564,7 +620,14 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_commsManager.InventoryService.DeleteItem(item); + IInventoryServices invService = GetInventoryService(); + if (invService != null) + { + //return m_commsManager.InventoryService + return invService.DeleteItem(item); + } + + return false; } } else @@ -641,6 +704,13 @@ namespace OpenSim.Framework.Communications.Cache } return null; } + + public IInventoryServices GetInventoryService() + { + IInventoryServices invService; + m_commsManager.TryGetInventoryService(m_inventoryHost, out invService); + return invService; + } } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index fe61406..37451ab 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -119,7 +119,12 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + //m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + IInventoryServices invService = userInfo.GetInventoryService(); + if (invService != null) + { + invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + } } else { diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5de0c71..0410f0e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -55,12 +55,6 @@ namespace OpenSim.Framework.Communications get { return m_gridService; } } - protected IInventoryServices m_inventoryService; - - public IInventoryServices InventoryService - { - get { return m_inventoryService; } - } protected IInterRegionCommunications m_interRegion; @@ -106,6 +100,70 @@ namespace OpenSim.Framework.Communications // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } + #region Inventory + protected string m_defaultInventoryHost = "default"; + + protected List m_inventoryServices = new List(); + // protected IInventoryServices m_inventoryService; + + public IInventoryServices InventoryService + { + get + { + if (m_inventoryServices.Count > 0) + { + // return m_inventoryServices[0]; + IInventoryServices invService; + if (TryGetInventoryService(m_defaultInventoryHost, out invService)) + { + return invService; + } + + } + + return null; + } + } + + public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) + { + if ((host == string.Empty) | (host == "default")) + { + host = m_defaultInventoryHost; + } + + + lock (m_inventoryServices) + { + foreach (IInventoryServices service in m_inventoryServices) + { + if (service.Host == host) + { + inventoryService = service; + return true; + } + } + } + + inventoryService = null; + return false; + } + + public virtual void AddInventoryService(string hostUrl) + { + + } + + public virtual void AddInventoryService(IInventoryServices service) + { + lock (m_inventoryServices) + { + m_inventoryServices.Add(service); + } + } + + #endregion + public void doCreate(string[] cmmdParams) { switch (cmmdParams[0]) @@ -167,7 +225,7 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.ID); + InventoryService.CreateNewUserInventory(userProf.ID); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); return userProf.ID; } diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs new file mode 100644 index 0000000..fdac53f --- /dev/null +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + public interface IAvatarService + { + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + + void AddAttachment(LLUUID user, LLUUID attach); + + void RemoveAttachment(LLUUID user, LLUUID attach); + + List GetAttachments(LLUUID user); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 8dc09bc..3929a4e 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -42,6 +42,10 @@ namespace OpenSim.Framework.Communications /// public interface IInventoryServices { + string Host + { + get; + } /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index a7f19e7..f8ef358 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -112,16 +112,16 @@ namespace OpenSim.Framework.Communications List GetUserFriendList(LLUUID friendlistowner); /// - /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); - - /// /// Updates the current region the User is in /// /// User Region the Avatar is IN /// User Region the Avatar is IN void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle); + /// + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); void AddAttachment(LLUUID user, LLUUID attach); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 89ccf93..d26a3bb 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -81,6 +81,11 @@ namespace OpenSim.Framework.Communications #region IInventoryServices methods + public string Host + { + get { return "default"; } + } + // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { -- cgit v1.1 From a9347b6ceb194a352ad2a5796e7ed7e8fc598c26 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 17:43:20 +0000 Subject: Extracted the Avatar appearance functions out of the IUserService interface and moved them into a IAvatarService Although "out of the box", there is no actual functional change to behavior --- OpenSim/Framework/Communications/CommunicationsManager.cs | 7 +++++++ OpenSim/Framework/Communications/IUserService.cs | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 0410f0e..45f692b 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -77,6 +77,13 @@ namespace OpenSim.Framework.Communications // get { return m_transactionsManager; } // } + protected IAvatarService m_avatarService; + + public IAvatarService AvatarService + { + get { return m_avatarService; } + } + protected AssetCache m_assetCache; public AssetCache AssetCache diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index f8ef358..4bd2ad1 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -120,14 +120,14 @@ namespace OpenSim.Framework.Communications /// /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); + // AvatarAppearance GetUserAppearance(LLUUID user); - void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + // void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); - void AddAttachment(LLUUID user, LLUUID attach); + // void AddAttachment(LLUUID user, LLUUID attach); - void RemoveAttachment(LLUUID user, LLUUID attach); + // void RemoveAttachment(LLUUID user, LLUUID attach); - List GetAttachments(LLUUID user); + // List GetAttachments(LLUUID user); } } \ No newline at end of file -- cgit v1.1 From 5cfc468d959f1fcfa1fa8121154a70c6430df083 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 17:52:06 +0000 Subject: more work on the support for multiple inventory servers. The Login service should now read/create new inventory on the inventory server that is set in a users profile. Also added "Add-InventoryHost" console command to add a support for a new server to a region. So it would be good if someone could test this. Set up the grid as normal, but then also run extra inventory server on a different computer (well actually it just has to be on a different network hostname, so one using "http://localhost:8004" and one using "http://127.0.0.1:8005" should work) then you need to manually edit the user profile database to set the new servers url in a user's "userInventoryURI" field. Then on a region server, use the Add-InventoryHost to add the new server url (always include the full url, including http, but don't add a final /) Login with that account and see if the inventory works. Of course these needs to be made more user friendly. --- OpenSim/Framework/Communications/LoginService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 08b071f..8fcb4f5 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -94,7 +94,7 @@ namespace OpenSim.Framework.Communications /// /// /// This will be thrown if there is a problem with the inventory service - protected abstract InventoryData GetInventorySkeleton(LLUUID userID); + protected abstract InventoryData GetInventorySkeleton(LLUUID userID, string inventoryServerUrl); /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications try { - inventData = GetInventorySkeleton(agentID); + inventData = GetInventorySkeleton(agentID, userProfile.UserInventoryURI); } catch (Exception e) { @@ -386,7 +386,7 @@ namespace OpenSim.Framework.Communications LLUUID agentID = userProfile.ID; // Inventory Library Section - InventoryData inventData = GetInventorySkeleton(agentID); + InventoryData inventData = GetInventorySkeleton(agentID, userProfile.UserInventoryURI); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); -- cgit v1.1 From 1091f78e049943037f9fdd11fd6a98f4e7b846ac Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 28 Jun 2008 19:04:28 +0000 Subject: Mantis#1626. Thank you kindly, Melanie for a patch that: Fixes IAvatarService for grid and standalone modes --- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index fe09b03..1e059fe 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -41,7 +41,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService + public abstract class UserManagerBase : IUserService, IAvatarService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -703,4 +703,4 @@ namespace OpenSim.Framework.Communications return new List(); } } -} \ No newline at end of file +} -- cgit v1.1 From 85f893f0b38b85430e9e5a058af5c65993741bb5 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 22:19:48 +0000 Subject: more disabling multiple inventory server support in LoginService --- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8fcb4f5..9005cff 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications try { - inventData = GetInventorySkeleton(agentID, userProfile.UserInventoryURI); + inventData = GetInventorySkeleton(agentID, ""); } catch (Exception e) { @@ -386,7 +386,7 @@ namespace OpenSim.Framework.Communications LLUUID agentID = userProfile.ID; // Inventory Library Section - InventoryData inventData = GetInventorySkeleton(agentID, userProfile.UserInventoryURI); + InventoryData inventData = GetInventorySkeleton(agentID, ""); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); -- cgit v1.1 From 031b3d531437d4de85f2b89f33ab680acc9589cf Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 28 Jun 2008 23:05:08 +0000 Subject: small change to see if that helps with the inventory problems. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 524f314..46387ab 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Cache { if (m_userProfile != null) { - if (m_userProfile.UserInventoryURI != String.Empty) + if (! String.IsNullOrEmpty(m_userProfile.UserAssetURI)) { Uri uri = new Uri(m_userProfile.UserInventoryURI); return uri.Host; -- cgit v1.1 From 68bec3f69feb24a50b073e05d099f5c03d26a437 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jun 2008 10:27:22 +0000 Subject: couple of small fixes to try to fix support for multiple inventory servers in the loginservice --- OpenSim/Framework/Communications/LoginService.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 9005cff..3e1a885 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -230,7 +230,12 @@ namespace OpenSim.Framework.Communications try { - inventData = GetInventorySkeleton(agentID, ""); + string inventoryServerUrl = ""; + if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) + { + inventoryServerUrl = userProfile.UserInventoryURI; + } + inventData = GetInventorySkeleton(agentID, inventoryServerUrl); } catch (Exception e) { @@ -386,7 +391,14 @@ namespace OpenSim.Framework.Communications LLUUID agentID = userProfile.ID; // Inventory Library Section - InventoryData inventData = GetInventorySkeleton(agentID, ""); + + string inventoryServerUrl = ""; + if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) + { + inventoryServerUrl = userProfile.UserInventoryURI; + } + + InventoryData inventData = GetInventorySkeleton(agentID, inventoryServerUrl); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); -- cgit v1.1 From f3f31744abaf8a9df952a0d547faa59035b46ff3 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jun 2008 11:48:58 +0000 Subject: patch and files from mantis #1630, Thanks Melanie --- OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 45f692b..ccd6491 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -134,7 +134,7 @@ namespace OpenSim.Framework.Communications public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) { - if ((host == string.Empty) | (host == "default")) + if ((host == string.Empty) || (host == "default")) { host = m_defaultInventoryHost; } -- cgit v1.1 From b0330a0bb50a3b30dbaa526cdcafd4e0b9aa6c7b Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jun 2008 20:39:34 +0000 Subject: disabled the multiple inventory server support in login service again. And reverted CachedUserInfo back to revision 5262. I don't think most of the inventory problems that people are reporting are due to these, but its easier to deal with one set of potential problems at a time, and I'm not going to get any time in the week to work on this anyway. --- .../Communications/Cache/CachedUserInfo.cs | 170 ++++++--------------- .../Cache/UserProfileCacheService.cs | 12 +- OpenSim/Framework/Communications/LoginService.cs | 16 +- 3 files changed, 64 insertions(+), 134 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 46387ab..f38a109 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -87,24 +87,6 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); - private string m_inventoryHost - { - get - { - if (m_userProfile != null) - { - if (! String.IsNullOrEmpty(m_userProfile.UserAssetURI)) - { - Uri uri = new Uri(m_userProfile.UserInventoryURI); - return uri.Host; - } - } - - return ""; - } - - } - /// /// Constructor /// @@ -170,9 +152,9 @@ namespace OpenSim.Framework.Communications.Cache { foreach (InventoryFolderImpl folder in pendingCategorizationFolders[newFolder.ID]) { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", -// folder.name, folder.folderID, parent.name, parent.folderID); + // m_log.DebugFormat( + // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", + // folder.name, folder.folderID, parent.name, parent.folderID); lock (newFolder.SubFolders) { @@ -232,9 +214,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void FolderReceive(InventoryFolderImpl newFolder) { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", -// folderInfo.Name, folderInfo.ID, userID); + // m_log.DebugFormat( + // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", + // folderInfo.Name, folderInfo.ID, userID); if (RootFolder == null) { @@ -285,9 +267,9 @@ namespace OpenSim.Framework.Communications.Cache /// private void ItemReceive(InventoryItemBase itemInfo) { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Received item {0} {1} for user {2}", -// itemInfo.Name, itemInfo.ID, userID); + // m_log.DebugFormat( + // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", + // itemInfo.Name, itemInfo.ID, userID); InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); if (null == folder) @@ -315,8 +297,8 @@ namespace OpenSim.Framework.Communications.Cache /// public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); + // m_log.DebugFormat( + // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); if (HasInventory) { @@ -343,15 +325,9 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //m_commsManager.InventoryService - invService.AddFolder(createdBaseFolder); - return true; - } + m_commsManager.InventoryService.AddFolder(createdBaseFolder); - return false; + return true; } else { @@ -390,8 +366,8 @@ namespace OpenSim.Framework.Communications.Cache /// public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); + // m_log.DebugFormat( + // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); if (HasInventory) { @@ -400,22 +376,17 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.Name = name; baseFolder.ParentID = parentID; - baseFolder.Type = (short) type; + baseFolder.Type = (short)type; baseFolder.Version = RootFolder.Version; - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //m_commsManager.InventoryService. - invService.UpdateFolder(baseFolder); - - InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - if (folder != null) - { - folder.Name = name; - folder.ParentID = parentID; - } - } + m_commsManager.InventoryService.UpdateFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + { + folder.Name = name; + folder.ParentID = parentID; + } } else { @@ -439,9 +410,9 @@ namespace OpenSim.Framework.Communications.Cache /// public bool MoveFolder(LLUUID folderID, LLUUID parentID) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", -// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); + // m_log.DebugFormat( + // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", + // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); if (HasInventory) { @@ -450,24 +421,13 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - // m_commsManager.InventoryService - invService.MoveFolder(baseFolder); - - InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - if (folder != null) - { - folder.ParentID = parentID; - } - - return true; - } - else - { - return false; - } + m_commsManager.InventoryService.MoveFolder(baseFolder); + + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + if (folder != null) + folder.ParentID = parentID; + + return true; } else { @@ -490,8 +450,8 @@ namespace OpenSim.Framework.Communications.Cache /// public bool PurgeFolder(LLUUID folderID) { -// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", -// folderID, remoteClient.Name, remoteClient.AgentId); + // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", + // folderID, remoteClient.Name, remoteClient.AgentId); if (HasInventory) { @@ -508,16 +468,11 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //m_commsManager.InventoryService - invService.PurgeFolder(purgedBaseFolder); + m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); - purgedFolder.Purge(); + purgedFolder.Purge(); - return true; - } + return true; } } else @@ -543,20 +498,14 @@ namespace OpenSim.Framework.Communications.Cache { if (item.Folder == LLUUID.Zero) { - InventoryFolderImpl f=FindFolderForType(item.AssetType); + InventoryFolderImpl f = FindFolderForType(item.AssetType); if (f != null) - item.Folder=f.ID; + item.Folder = f.ID; else - item.Folder=RootFolder.ID; + item.Folder = RootFolder.ID; } ItemReceive(item); - - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //m_commsManager.InventoryService - invService.AddItem(item); - } + m_commsManager.InventoryService.AddItem(item); } else { @@ -576,12 +525,7 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //m_commsManager.InventoryService - invService.UpdateItem(item); - } + m_commsManager.InventoryService.UpdateItem(item); } else { @@ -620,14 +564,7 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - IInventoryServices invService = GetInventoryService(); - if (invService != null) - { - //return m_commsManager.InventoryService - return invService.DeleteItem(item); - } - - return false; + return m_commsManager.InventoryService.DeleteItem(item); } } else @@ -659,9 +596,9 @@ namespace OpenSim.Framework.Communications.Cache if ((folder = RootFolder.FindFolder(folderID)) != null) { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Found folder {0} for client {1}", -// folderID, remoteClient.AgentId); + // m_log.DebugFormat( + // "[AGENT INVENTORY]: Found folder {0} for client {1}", + // folderID, remoteClient.AgentId); client.SendInventoryFolderDetails( client.AgentId, folderID, folder.RequestListOfItems(), @@ -693,7 +630,7 @@ namespace OpenSim.Framework.Communications.Cache { if (RootFolder == null) return null; - + lock (RootFolder.SubFolders) { foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values) @@ -704,13 +641,6 @@ namespace OpenSim.Framework.Communications.Cache } return null; } - - public IInventoryServices GetInventoryService() - { - IInventoryServices invService; - m_commsManager.TryGetInventoryService(m_inventoryHost, out invService); - return invService; - } } /// @@ -743,4 +673,4 @@ namespace OpenSim.Framework.Communications.Cache m_delegate.DynamicInvoke(m_args); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 37451ab..0040718 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -119,12 +119,12 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - //m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - IInventoryServices invService = userInfo.GetInventoryService(); - if (invService != null) - { - invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - } + m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + //IInventoryServices invService = userInfo.GetInventoryService(); + //if (invService != null) + //{ + // invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + //} } else { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 3e1a885..e7124c9 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -231,10 +231,10 @@ namespace OpenSim.Framework.Communications try { string inventoryServerUrl = ""; - if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) - { - inventoryServerUrl = userProfile.UserInventoryURI; - } + //if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) + //{ + // inventoryServerUrl = userProfile.UserInventoryURI; + //} inventData = GetInventorySkeleton(agentID, inventoryServerUrl); } catch (Exception e) @@ -393,10 +393,10 @@ namespace OpenSim.Framework.Communications // Inventory Library Section string inventoryServerUrl = ""; - if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) - { - inventoryServerUrl = userProfile.UserInventoryURI; - } + //if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) + //{ + // inventoryServerUrl = userProfile.UserInventoryURI; + //} InventoryData inventData = GetInventorySkeleton(agentID, inventoryServerUrl); ArrayList AgentInventoryArray = inventData.InventoryArray; -- cgit v1.1 From 2dfaa3c5e489d48a58ce460011dc55e853b26e27 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 30 Jun 2008 12:41:32 +0000 Subject: Update svn properties. --- OpenSim/Framework/Communications/IAvatarService.cs | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index fdac53f..a3494cf 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -1,21 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Framework.Communications -{ - public interface IAvatarService - { - /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); - - void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); - - void AddAttachment(LLUUID user, LLUUID attach); - - void RemoveAttachment(LLUUID user, LLUUID attach); - - List GetAttachments(LLUUID user); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + public interface IAvatarService + { + /// Get's the User Appearance + AvatarAppearance GetUserAppearance(LLUUID user); + + void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + + void AddAttachment(LLUUID user, LLUUID attach); + + void RemoveAttachment(LLUUID user, LLUUID attach); + + List GetAttachments(LLUUID user); + } +} -- cgit v1.1 From 721988adcd5a38607cb0ff5495f2984e7efb9761 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 30 Jun 2008 15:05:30 +0000 Subject: add the ability to cherry pick expire something from the asset cache. Bandaid until we rethink the caches a bit more. --- .../Framework/Communications/Cache/AssetCache.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2c51160..95af28b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -382,6 +382,30 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Allows you to clear a specific asset by uuid out + /// of the asset cache. This is needed because the osdynamic + /// texture code grows the asset cache without bounds. The + /// real solution here is a much better cache archicture, but + /// this is a stop gap measure until we have such a thing. + /// + + public void ExpireAsset(LLUUID uuid) + { + // uuid is unique, so no need to worry about it showing up + // in the 2 caches differently. Also, locks are probably + // needed in all of this, or move to synchronized non + // generic forms for Dictionaries. + if (Textures.ContainsKey(uuid)) + { + Textures.Remove(uuid); + } + else if (Assets.ContainsKey(uuid)) + { + Assets.Remove(uuid); + } + } + // See IAssetReceiver public void AssetReceived(AssetBase asset, bool IsTexture) { -- cgit v1.1 From 9052c43319ab69f57b80e363d965780be625b0e2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 2 Jul 2008 16:20:54 +0000 Subject: * Drop InvType from the assets table since it is no longer used * Migration should be automatic on sqlite and mysql * Migration is not automatic on mssql, you will need to drop the invType column manually * Migration should be fine, but as for any db change, I would recommend making sure you have backups before moving past this revision --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 -- OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 - 2 files changed, 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 95af28b..f160ce4 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -701,7 +701,6 @@ namespace OpenSim.Framework.Communications.Cache Data = aBase.Data; FullID = aBase.FullID; Type = aBase.Type; - InvType = aBase.InvType; Name = aBase.Name; Description = aBase.Description; } @@ -718,7 +717,6 @@ namespace OpenSim.Framework.Communications.Cache Data = aBase.Data; FullID = aBase.FullID; Type = aBase.Type; - InvType = aBase.InvType; Name = aBase.Name; Description = aBase.Description; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 5aba086..7350d4d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -670,7 +670,6 @@ namespace OpenSim.Framework.Communications.Capabilities asset = new AssetBase(); asset.FullID = assetID; asset.Type = assType; - asset.InvType = inType; asset.Name = assetName; asset.Data = data; m_assetCache.AddAsset(asset); -- cgit v1.1 From 2dadbc2f70313899f517c8d1e1c7da443fd4324a Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 4 Jul 2008 10:19:58 +0000 Subject: mini-warnings-safari, plus cleanup of IUserServices method naming. --- OpenSim/Framework/Communications/IUserService.cs | 2 +- .../Framework/Communications/UserManagerBase.cs | 102 +++++++++++---------- 2 files changed, 53 insertions(+), 51 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 4bd2ad1..6ad72c0 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications UserAgentData GetAgentByUUID(LLUUID userId); - void clearUserAgent(LLUUID avatarID); + void ClearUserAgent(LLUUID avatarID); List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); UserProfileData SetupMasterUser(string firstName, string lastName); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1e059fe..d5b1e74 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.Communications if (profile != null) { - profile.CurrentAgent = getUserAgent(profile.ID); + profile.CurrentAgent = GetUserAgent(profile.ID); return profile; } } @@ -126,7 +126,7 @@ namespace OpenSim.Framework.Communications if (null != profile) { - profile.CurrentAgent = getUserAgent(profile.ID); + profile.CurrentAgent = GetUserAgent(profile.ID); return profile; } } @@ -157,7 +157,7 @@ namespace OpenSim.Framework.Communications /// /// /// - public bool setUserProfile(UserProfileData data) + public bool SetUserProfile(UserProfileData data) { foreach (KeyValuePair plugin in _plugins) { @@ -183,7 +183,7 @@ namespace OpenSim.Framework.Communications /// /// The agent's UUID /// Agent profiles - public UserAgentData getUserAgent(LLUUID uuid) + public UserAgentData GetUserAgent(LLUUID uuid) { foreach (KeyValuePair plugin in _plugins) { @@ -200,6 +200,51 @@ namespace OpenSim.Framework.Communications return null; } + /// + /// Loads a user agent by name (not called directly) + /// + /// The agent's name + /// A user agent + public UserAgentData GetUserAgent(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAgentByName(name); + } + catch (Exception e) + { + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user agent by name (not called directly) + /// + /// The agent's firstname + /// The agent's lastname + /// A user agent + public UserAgentData GetUserAgent(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.GetAgentByName(fname, lname); + } + catch (Exception e) + { + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { foreach (KeyValuePair plugin in _plugins) @@ -297,62 +342,19 @@ namespace OpenSim.Framework.Communications } } - /// - /// Loads a user agent by name (not called directly) - /// - /// The agent's name - /// A user agent - public UserAgentData getUserAgent(string name) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - return plugin.Value.GetAgentByName(name); - } - catch (Exception e) - { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } /// /// Resets the currentAgent in the user profile /// /// The agent's ID - public void clearUserAgent(LLUUID agentID) + public void ClearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); profile.CurrentAgent = null; - setUserProfile(profile); + SetUserProfile(profile); } - /// - /// Loads a user agent by name (not called directly) - /// - /// The agent's firstname - /// The agent's lastname - /// A user agent - public UserAgentData getUserAgent(string fname, string lname) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - return plugin.Value.GetAgentByName(fname, lname); - } - catch (Exception e) - { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } #endregion @@ -537,7 +539,7 @@ namespace OpenSim.Framework.Communications // TODO: what is the logic should be? bool ret = false; ret = AddUserAgent(profile.CurrentAgent); - ret = ret & setUserProfile(profile); + ret = ret & SetUserProfile(profile); return ret; } -- cgit v1.1 From 6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 4 Jul 2008 11:13:25 +0000 Subject: Renaming UserManagerBase.SetUserProfile(UserProfileData) to UserManager.UpdateUserProfile(UserProfileData). Adding UpdateUserProfile(UserProfileData) to IUserService interface. Adding RemoteAdminPlugin.XmlRpcUpdateUserAccountMethod(...) to provide a remote update capability. --- OpenSim/Framework/Communications/IUserService.cs | 7 +++++++ OpenSim/Framework/Communications/UserManagerBase.cs | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 6ad72c0..c1ae0e2 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -64,6 +64,13 @@ namespace OpenSim.Framework.Communications /// LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + /// + /// Update the user's profile. + /// + /// UserProfileData object with updated data. Should be obtained + /// via a call to GetUserProfile(). + /// true if the update could be applied, false if it could not be applied. + bool UpdateUserProfile(UserProfileData data); /// /// Adds a new friend to the database for XUser diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d5b1e74..1b73152 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -153,11 +153,11 @@ namespace OpenSim.Framework.Communications } /// - /// Set's user profile from data object + /// Updates a user profile from data object /// /// /// - public bool SetUserProfile(UserProfileData data) + public bool UpdateUserProfile(UserProfileData data) { foreach (KeyValuePair plugin in _plugins) { @@ -168,7 +168,8 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, + plugin.Key, e.ToString()); } } return false; @@ -352,7 +353,7 @@ namespace OpenSim.Framework.Communications UserProfileData profile = GetUserProfile(agentID); profile.CurrentAgent = null; - SetUserProfile(profile); + UpdateUserProfile(profile); } @@ -539,7 +540,7 @@ namespace OpenSim.Framework.Communications // TODO: what is the logic should be? bool ret = false; ret = AddUserAgent(profile.CurrentAgent); - ret = ret & SetUserProfile(profile); + ret = ret & UpdateUserProfile(profile); return ret; } -- cgit v1.1 From 8465f378ac09b948431f1ebf2e0e9ab345c8fb21 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sat, 5 Jul 2008 08:13:22 +0000 Subject: changes prompting of create user console command to only ask for unspecified parameters and avoid an exception if the wrong number of parameters are supplied --- .../Communications/CommunicationsManager.cs | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index ccd6491..a45e236 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -183,21 +183,25 @@ namespace OpenSim.Framework.Communications uint regY = 1000; if (cmmdParams.Length < 2) - { firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); + else firstName = cmmdParams[1]; + + if ( cmmdParams.Length < 3 ) lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); + else lastName = cmmdParams[2]; + + if ( cmmdParams.Length < 4 ) password = MainConsole.Instance.PasswdPrompt("Password"); - regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", "1000")); - regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", "1000")); - } - else - { - firstName = cmmdParams[1]; - lastName = cmmdParams[2]; - password = cmmdParams[3]; - regX = Convert.ToUInt32(cmmdParams[4]); - regY = Convert.ToUInt32(cmmdParams[5]); - } + else password = cmmdParams[3]; + + if ( cmmdParams.Length < 5 ) + regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); + else regX = Convert.ToUInt32(cmmdParams[4]); + + if ( cmmdParams.Length < 6 ) + regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); + else regY = Convert.ToUInt32(cmmdParams[5]); + if (null == m_userService.GetUserProfile(firstName, lastName)) { -- cgit v1.1 From d470d30c09fde202f708a9c8af763f5d16e18bfb Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 6 Jul 2008 14:02:22 +0000 Subject: Copyright notices and formatting cleanup. --- OpenSim/Framework/Communications/IAvatarService.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index a3494cf..0e4a349 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using libsecondlife; -- cgit v1.1 From 0b2fcbfec4ae06b3e3f278d9e42f84c88f556587 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 7 Jul 2008 18:54:11 +0000 Subject: * Start scripts loaded from an archive --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f160ce4..7099760 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -348,7 +348,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { - if (asset.Type == 0) + if (asset.Type == (int)AssetType.Texture) { if (!Textures.ContainsKey(asset.FullID)) { @@ -365,9 +365,9 @@ namespace OpenSim.Framework.Communications.Cache } } else - { + { if (!Assets.ContainsKey(asset.FullID)) - { + { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); -- cgit v1.1 From 1813946937267edde79cb471c357f6cd85efd8ec Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 7 Jul 2008 19:18:44 +0000 Subject: * remove unused CommitAssets() hook for now --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 5 ----- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 4 ---- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 7 ------- 3 files changed, 16 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 74b1976..f65b88f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -50,7 +50,6 @@ namespace OpenSim.Framework.Communications.Cache protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); protected abstract void StoreAsset(AssetBase asset); - protected abstract void CommitAssets(); /// /// This method must be implemented by a subclass to retrieve the asset named in the @@ -108,8 +107,6 @@ namespace OpenSim.Framework.Communications.Cache m_log.Info("[ASSET SERVER]: Setting up asset database"); assetLoader.ForEachDefaultXmlAsset(StoreAsset); - - CommitAssets(); } public AssetServerBase() @@ -167,7 +164,6 @@ namespace OpenSim.Framework.Communications.Cache lock (m_syncLock) { m_assetProvider.UpdateAsset(asset); - m_assetProvider.CommitAssets(); } } @@ -176,7 +172,6 @@ namespace OpenSim.Framework.Communications.Cache lock (m_syncLock) { StoreAsset(asset); - CommitAssets(); } } diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 7787805..6caabcd 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -106,10 +106,6 @@ namespace OpenSim.Framework.Communications.Cache } } - protected override void CommitAssets() - { - } - public override void Close() { throw new Exception("The method or operation is not implemented."); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 334c5bd..95696ee 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -74,8 +74,6 @@ namespace OpenSim.Framework.Communications.Cache public override void Close() { base.Close(); - - m_assetProvider.CommitAssets(); } protected override AssetBase GetAsset(AssetRequest req) @@ -93,10 +91,5 @@ namespace OpenSim.Framework.Communications.Cache { m_assetProvider.CreateAsset(asset); } - - protected override void CommitAssets() - { - m_assetProvider.CommitAssets(); - } } } -- cgit v1.1 From 7fa00f9ecdf2ec5d42ebaf411a619e54404e4800 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 7 Jul 2008 19:32:21 +0000 Subject: * remove redundant sync locking in AssetServerBase since this is already being done by the lower database layers --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- .../Framework/Communications/Cache/AssetServerBase.cs | 16 ++-------------- .../Framework/Communications/Cache/GridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 10 ++-------- 4 files changed, 7 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 7099760..d0bcc98 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -360,7 +360,7 @@ namespace OpenSim.Framework.Communications.Cache if (!asset.Temporary) { - m_assetServer.StoreAndCommitAsset(asset); + m_assetServer.StoreAsset(asset); } } } @@ -376,7 +376,7 @@ namespace OpenSim.Framework.Communications.Cache if (!asset.Temporary) { - m_assetServer.StoreAndCommitAsset(asset); + m_assetServer.StoreAsset(asset); } } } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f65b88f..f729d78 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -44,12 +44,11 @@ namespace OpenSim.Framework.Communications.Cache protected BlockingQueue m_assetRequests; protected Thread m_localAssetServerThread; protected IAssetProvider m_assetProvider; - protected object m_syncLock = new object(); // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); - protected abstract void StoreAsset(AssetBase asset); + public abstract void StoreAsset(AssetBase asset); /// /// This method must be implemented by a subclass to retrieve the asset named in the @@ -161,18 +160,7 @@ namespace OpenSim.Framework.Communications.Cache public virtual void UpdateAsset(AssetBase asset) { - lock (m_syncLock) - { - m_assetProvider.UpdateAsset(asset); - } - } - - public void StoreAndCommitAsset(AssetBase asset) - { - lock (m_syncLock) - { - StoreAsset(asset); - } + m_assetProvider.UpdateAsset(asset); } public virtual void Close() diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 6caabcd..4206cae 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - protected override void StoreAsset(AssetBase asset) + public override void StoreAsset(AssetBase asset) { try { diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 95696ee..94a8509 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -78,16 +78,10 @@ namespace OpenSim.Framework.Communications.Cache protected override AssetBase GetAsset(AssetRequest req) { - AssetBase asset; - lock (m_syncLock) - { - asset = m_assetProvider.FetchAsset(req.AssetID); - } - - return asset; + return m_assetProvider.FetchAsset(req.AssetID);; } - protected override void StoreAsset(AssetBase asset) + public override void StoreAsset(AssetBase asset) { m_assetProvider.CreateAsset(asset); } -- cgit v1.1 From f629fdb88d35d1c2f0a3ce97fdd7d9acdc25e11f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 12 Jul 2008 06:24:43 +0000 Subject: Patches #9143 and #9144 (Mantis #1723) Changes the permissions module to make scripts permissive only when intended Adds security checks to asset transfers to prevent hacked clients fron requesting script sources. Adds security checks to llClientView to verify all aspects of ownership and permissions for inventory based script retrieval. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d0bcc98..90b0a10 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -445,7 +445,10 @@ namespace OpenSim.Framework.Communications.Cache req.NumPackets = CalculateNumPackets(assetInf.Data); RequestedAssets.Remove(assetInf.FullID); - AssetRequests.Add(req); + // If it's a direct request for a script, drop it + // because it's a hacked client + if(req.AssetRequestSource != 2 || assetInf.Type != 10) + AssetRequests.Add(req); } } } @@ -609,6 +612,10 @@ namespace OpenSim.Framework.Communications.Cache return; } + // Scripts cannot be retrieved by direct request + if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) + return; + // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; -- cgit v1.1 From 4ff529bdaf50b84ee477212de95260c7b7b0867f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 12 Jul 2008 18:26:25 +0000 Subject: Patch #9146 (No Mantis) Prevent an exception caused by inventory server fetch requests --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f38a109..4e57ead 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -619,7 +619,7 @@ namespace OpenSim.Framework.Communications.Cache { AddRequest( new InventoryRequest( - Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents"), + Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents", false, false), new object[] { client, folderID, fetchFolders, fetchItems })); return true; @@ -670,7 +670,8 @@ namespace OpenSim.Framework.Communications.Cache public void Execute() { - m_delegate.DynamicInvoke(m_args); + if(m_delegate != null) + m_delegate.DynamicInvoke(m_args); } } -} \ No newline at end of file +} -- cgit v1.1 From fb096dfbd54cfbcfa60be872cee1680eb521dd14 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 21 Jul 2008 15:13:34 +0000 Subject: added experimental packet tracker (LLPacketTracker.cs), which can be told to track a packet and if it hasn't been acked within a set time, trigger a IClientAPI event, that the application/scene can handle. Currently only terrain packet tracking is finished, Tracking for initial Prim packets (first full update for a prim) is being worked on. Future improvements would be to make it a more generic packet tracker with callback delegates instead of events. Add a test event handler (which would fire after a minute if a terrain packet hadn't been acked) to scene to handle the OnUnackedTerrain event, which currently just resends the terrain patch. The idea of this packet tracking is for the region level application to be able to know if the client stack gave up on sending a packet. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index a45e236..5be7334 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -125,9 +125,7 @@ namespace OpenSim.Framework.Communications { return invService; } - } - return null; } } @@ -139,7 +137,6 @@ namespace OpenSim.Framework.Communications host = m_defaultInventoryHost; } - lock (m_inventoryServices) { foreach (IInventoryServices service in m_inventoryServices) -- cgit v1.1 From 344c9caeb671f3d9dab80f05d18a7dc9f3075bc1 Mon Sep 17 00:00:00 2001 From: Johan Berntsson Date: Wed, 23 Jul 2008 06:59:02 +0000 Subject: thanks lulurun for a security patch that blocks unathorized access to the inventory server (see http://opensimulator.org/wiki/Security_vulnerability_brought_by_non-check_inventory_service) --- .../Communications/Cache/CachedUserInfo.cs | 24 ++++++++++++------ .../Cache/UserProfileCacheService.cs | 29 +++++++++++++++++++++- .../Communications/CommunicationsManager.cs | 6 +++++ 3 files changed, 51 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 4e57ead..c125976 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -87,6 +87,9 @@ namespace OpenSim.Framework.Communications.Cache private IDictionary> pendingCategorizationFolders = new Dictionary>(); + private LLUUID m_session_id = LLUUID.Zero; + public LLUUID SessionID { get { return m_session_id; } } + /// /// Constructor /// @@ -98,6 +101,13 @@ namespace OpenSim.Framework.Communications.Cache m_userProfile = userProfile; } + public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile, IClientAPI remoteClient) + { + m_commsManager = commsManager; + m_userProfile = userProfile; + m_session_id = remoteClient.SessionId; + } + /// /// This allows a request to be added to be processed once we receive a user's inventory /// from the inventory service. If we already have the inventory, the request @@ -325,7 +335,7 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.InventoryService.AddFolder(createdBaseFolder); + m_commsManager.SecureInventoryService.AddFolder(createdBaseFolder, m_session_id); return true; } @@ -379,7 +389,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short)type; baseFolder.Version = RootFolder.Version; - m_commsManager.InventoryService.UpdateFolder(baseFolder); + m_commsManager.SecureInventoryService.UpdateFolder(baseFolder, m_session_id); InventoryFolderImpl folder = RootFolder.FindFolder(folderID); if (folder != null) @@ -421,7 +431,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.InventoryService.MoveFolder(baseFolder); + m_commsManager.SecureInventoryService.MoveFolder(baseFolder, m_session_id); InventoryFolderImpl folder = RootFolder.FindFolder(folderID); if (folder != null) @@ -468,7 +478,7 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + m_commsManager.SecureInventoryService.PurgeFolder(purgedBaseFolder, m_session_id); purgedFolder.Purge(); @@ -505,7 +515,7 @@ namespace OpenSim.Framework.Communications.Cache item.Folder = RootFolder.ID; } ItemReceive(item); - m_commsManager.InventoryService.AddItem(item); + m_commsManager.SecureInventoryService.AddItem(item, m_session_id); } else { @@ -525,7 +535,7 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - m_commsManager.InventoryService.UpdateItem(item); + m_commsManager.SecureInventoryService.UpdateItem(item, m_session_id); } else { @@ -564,7 +574,7 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_commsManager.InventoryService.DeleteItem(item); + return m_commsManager.SecureInventoryService.DeleteItem(item, m_session_id); } } else diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 0040718..e22dff6 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -63,6 +63,33 @@ namespace OpenSim.Framework.Communications.Cache /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// /// + public void AddNewUser(IClientAPI remoteClient) + { + // Potential fix - Multithreading issue. + lock (m_userProfiles) + { + if (!m_userProfiles.ContainsKey(remoteClient.AgentId)) + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(remoteClient.AgentId); + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile, remoteClient); + + if (userInfo.UserProfile != null) + { + // The inventory for the user will be populated when they actually enter the scene + m_userProfiles.Add(remoteClient.AgentId, userInfo); + } + else + { + m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", remoteClient.AgentId); + } + } + } + } + + /// + /// A new user has moved into a region in this instance so retrieve their profile from the user service. + /// + /// public void AddNewUser(LLUUID userID) { // Potential fix - Multithreading issue. @@ -119,7 +146,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + m_commsManager.SecureInventoryService.RequestInventoryForUser(userID, userInfo.SessionID, userInfo.InventoryReceive); //IInventoryServices invService = userInfo.GetInventoryService(); //if (invService != null) //{ diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5be7334..8caeeb3 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -112,7 +112,13 @@ namespace OpenSim.Framework.Communications protected List m_inventoryServices = new List(); // protected IInventoryServices m_inventoryService; + protected ISecureInventoryService m_secureinventoryServices; + public ISecureInventoryService SecureInventoryService + { + get { return m_secureinventoryServices; } + } + public IInventoryServices InventoryService { get -- cgit v1.1 From 3b35332957e0d122cdd063ad14d3795856bcd8e5 Mon Sep 17 00:00:00 2001 From: Johan Berntsson Date: Wed, 23 Jul 2008 07:27:11 +0000 Subject: adding files that were not included in r5589 --- .../Communications/ISecureInventoryService.cs | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 OpenSim/Framework/Communications/ISecureInventoryService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs new file mode 100644 index 0000000..0e7861a --- /dev/null +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -0,0 +1,125 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications.Cache; + +namespace OpenSim.Framework.Communications +{ + + /// + /// Defines all the operations one can perform on a user's inventory. + /// + public interface ISecureInventoryService + { + string Host + { + get; + } + /// + /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the + /// inventory has been received + /// + /// + /// + void RequestInventoryForUser(LLUUID userID, LLUUID session_id, InventoryReceiptCallback callback); + + /// + /// Add a new folder to the user's inventory + /// + /// + /// true if the folder was successfully added + bool AddFolder(InventoryFolderBase folder, LLUUID session_id); + + /// + /// Update a folder in the user's inventory + /// + /// + /// true if the folder was successfully updated + bool UpdateFolder(InventoryFolderBase folder, LLUUID session_id); + + /// + /// Move an inventory folder to a new location + /// + /// A folder containing the details of the new location + /// true if the folder was successfully moved + bool MoveFolder(InventoryFolderBase folder, LLUUID session_id); + + /// + /// Purge an inventory folder of all its items and subfolders. + /// + /// + /// true if the folder was successfully purged + bool PurgeFolder(InventoryFolderBase folder, LLUUID session_id); + + /// + /// Add a new item to the user's inventory + /// + /// + /// true if the item was successfully added + bool AddItem(InventoryItemBase item, LLUUID session_id); + + /// + /// Update an item in the user's inventory + /// + /// + /// true if the item was successfully updated + bool UpdateItem(InventoryItemBase item, LLUUID session_id); + + /// + /// Delete an item from the user's inventory + /// + /// + /// true if the item was successfully deleted + bool DeleteItem(InventoryItemBase item, LLUUID session_id); + + /// + /// Create a new inventory for the given user. + /// + /// + /// true if the inventory was successfully created, false otherwise + bool CreateNewUserInventory(LLUUID user); + + bool HasInventoryForUser(LLUUID userID); + + /// + /// Retrieve the root inventory folder for the given user. + /// + /// + /// null if no root folder was found + InventoryFolderBase RequestRootFolder(LLUUID userID); + + /// + /// Returns a list of all the folders in a given user's inventory. + /// + /// + /// A flat list of the user's inventory folder tree, + /// null if there is no inventory for this user + List GetInventorySkeleton(LLUUID userId); + } +} -- cgit v1.1 From ce4bcb50655e69277eac64a6d3ab520d669e6b70 Mon Sep 17 00:00:00 2001 From: Johan Berntsson Date: Wed, 23 Jul 2008 09:46:04 +0000 Subject: The new secure inventory server mode (in r5590) can now be disabled from OpenSim.ini. Default is to use the new mode. --- .../Communications/Cache/CachedUserInfo.cs | 64 +++++++++++++++++++--- .../Cache/UserProfileCacheService.cs | 9 ++- .../Communications/CommunicationsManager.cs | 52 +++++++++++++++++- 3 files changed, 114 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c125976..383c129 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -335,8 +335,14 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_commsManager.SecureInventoryService.AddFolder(createdBaseFolder, m_session_id); - + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.AddFolder(createdBaseFolder, m_session_id); + } + else + { + m_commsManager.InventoryService.AddFolder(createdBaseFolder); + } return true; } else @@ -389,7 +395,14 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short)type; baseFolder.Version = RootFolder.Version; - m_commsManager.SecureInventoryService.UpdateFolder(baseFolder, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.UpdateFolder(baseFolder, m_session_id); + } + else + { + m_commsManager.InventoryService.UpdateFolder(baseFolder); + } InventoryFolderImpl folder = RootFolder.FindFolder(folderID); if (folder != null) @@ -431,7 +444,14 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_commsManager.SecureInventoryService.MoveFolder(baseFolder, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.MoveFolder(baseFolder, m_session_id); + } + else + { + m_commsManager.InventoryService.MoveFolder(baseFolder); + } InventoryFolderImpl folder = RootFolder.FindFolder(folderID); if (folder != null) @@ -478,7 +498,14 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - m_commsManager.SecureInventoryService.PurgeFolder(purgedBaseFolder, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.PurgeFolder(purgedBaseFolder, m_session_id); + } + else + { + m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); + } purgedFolder.Purge(); @@ -515,7 +542,14 @@ namespace OpenSim.Framework.Communications.Cache item.Folder = RootFolder.ID; } ItemReceive(item); - m_commsManager.SecureInventoryService.AddItem(item, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.AddItem(item, m_session_id); + } + else + { + m_commsManager.InventoryService.AddItem(item); + } } else { @@ -535,7 +569,14 @@ namespace OpenSim.Framework.Communications.Cache { if (HasInventory) { - m_commsManager.SecureInventoryService.UpdateItem(item, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.UpdateItem(item, m_session_id); + } + else + { + m_commsManager.InventoryService.UpdateItem(item); + } } else { @@ -574,7 +615,14 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_commsManager.SecureInventoryService.DeleteItem(item, m_session_id); + if (m_commsManager.SecureInventoryService != null) + { + return m_commsManager.SecureInventoryService.DeleteItem(item, m_session_id); + } + else + { + return m_commsManager.InventoryService.DeleteItem(item); + } } } else diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index e22dff6..d6421b0 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -146,7 +146,14 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_commsManager.SecureInventoryService.RequestInventoryForUser(userID, userInfo.SessionID, userInfo.InventoryReceive); + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.RequestInventoryForUser(userID, userInfo.SessionID, userInfo.InventoryReceive); + } + else + { + m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); + } //IInventoryServices invService = userInfo.GetInventoryService(); //if (invService != null) //{ diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 8caeeb3..80dfa2c 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -112,11 +112,23 @@ namespace OpenSim.Framework.Communications protected List m_inventoryServices = new List(); // protected IInventoryServices m_inventoryService; - protected ISecureInventoryService m_secureinventoryServices; + protected List m_secureinventoryServices = new List(); public ISecureInventoryService SecureInventoryService { - get { return m_secureinventoryServices; } + get + { + if (m_secureinventoryServices.Count > 0) + { + // return m_inventoryServices[0]; + ISecureInventoryService invService; + if (TryGetSecureInventoryService(m_defaultInventoryHost, out invService)) + { + return invService; + } + } + return null; + } } public IInventoryServices InventoryService @@ -136,6 +148,29 @@ namespace OpenSim.Framework.Communications } } + public bool TryGetSecureInventoryService(string host, out ISecureInventoryService inventoryService) + { + if ((host == string.Empty) || (host == "default")) + { + host = m_defaultInventoryHost; + } + + lock (m_secureinventoryServices) + { + foreach (ISecureInventoryService service in m_secureinventoryServices) + { + if (service.Host == host) + { + inventoryService = service; + return true; + } + } + } + + inventoryService = null; + return false; + } + public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) { if ((host == string.Empty) || (host == "default")) @@ -164,6 +199,19 @@ namespace OpenSim.Framework.Communications } + public virtual void AddSecureInventoryService(string hostUrl) + { + + } + + public virtual void AddSecureInventoryService(ISecureInventoryService service) + { + lock (m_secureinventoryServices) + { + m_secureinventoryServices.Add(service); + } + } + public virtual void AddInventoryService(IInventoryServices service) { lock (m_inventoryServices) -- cgit v1.1 From 80d8e2889e62d8900837d37a800a4eeaae5ffc5a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 23 Jul 2008 13:24:25 +0000 Subject: Update svn properties. Formatting cleanup. Remove a compiler warning. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 90b0a10..6eff690 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -447,7 +447,7 @@ namespace OpenSim.Framework.Communications.Cache RequestedAssets.Remove(assetInf.FullID); // If it's a direct request for a script, drop it // because it's a hacked client - if(req.AssetRequestSource != 2 || assetInf.Type != 10) + if (req.AssetRequestSource != 2 || assetInf.Type != 10) AssetRequests.Add(req); } } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 383c129..11516f0 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -728,7 +728,7 @@ namespace OpenSim.Framework.Communications.Cache public void Execute() { - if(m_delegate != null) + if (m_delegate != null) m_delegate.DynamicInvoke(m_args); } } -- cgit v1.1 From 4452ed60f8b6956bcbb00353512bf7d7d89ad70c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Jul 2008 21:40:06 +0000 Subject: * refactor: split out inventory services which are only used between non-region services * more to follow --- .../Communications/IInterGridInventoryServices.cs | 58 ++++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 24 ++------- 2 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 OpenSim/Framework/Communications/IInterGridInventoryServices.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterGridInventoryServices.cs b/OpenSim/Framework/Communications/IInterGridInventoryServices.cs new file mode 100644 index 0000000..1ef1452 --- /dev/null +++ b/OpenSim/Framework/Communications/IInterGridInventoryServices.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + /// + /// Inventory operations used between grid services. + /// + public interface IInterGridInventoryServices + { + string Host + { + get; + } + + /// + /// Create a new inventory for the given user. + /// + /// + /// true if the inventory was successfully created, false otherwise + bool CreateNewUserInventory(LLUUID user); + + /// + /// Returns a list of all the folders in a given user's inventory. + /// + /// + /// A flat list of the user's inventory folder tree, + /// null if there is no inventory for this user + List GetInventorySkeleton(LLUUID userId); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 3929a4e..18e1a2d 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -40,12 +40,8 @@ namespace OpenSim.Framework.Communications /// /// Defines all the operations one can perform on a user's inventory. /// - public interface IInventoryServices - { - string Host - { - get; - } + public interface IInventoryServices : IInterGridInventoryServices + { /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received @@ -104,12 +100,10 @@ namespace OpenSim.Framework.Communications bool DeleteItem(InventoryItemBase item); /// - /// Create a new inventory for the given user. + /// Does the given user have an inventory structure? /// - /// - /// true if the inventory was successfully created, false otherwise - bool CreateNewUserInventory(LLUUID user); - + /// + /// bool HasInventoryForUser(LLUUID userID); /// @@ -118,13 +112,5 @@ namespace OpenSim.Framework.Communications /// /// null if no root folder was found InventoryFolderBase RequestRootFolder(LLUUID userID); - - /// - /// Returns a list of all the folders in a given user's inventory. - /// - /// - /// A flat list of the user's inventory folder tree, - /// null if there is no inventory for this user - List GetInventorySkeleton(LLUUID userId); } } -- cgit v1.1 From 9af05d0bc3253376cecb7cf6586c53e8067bb2a4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Jul 2008 22:18:09 +0000 Subject: * refactor: break out inter grid inventory services further * more to follow --- .../Communications/CommunicationsManager.cs | 43 +++++++++++++--------- .../Communications/IInterGridInventoryServices.cs | 7 +--- .../Framework/Communications/IInventoryServices.cs | 5 +++ .../Communications/ISecureInventoryService.cs | 18 ++------- .../Communications/InventoryServiceBase.cs | 2 +- 5 files changed, 37 insertions(+), 38 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 80dfa2c..6272872 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -36,68 +36,77 @@ using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications { + /// + /// This class manages references to OpenSim non-region services (asset, inventory, user, etc.) + /// public class CommunicationsManager { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected IUserService m_userService; + protected Dictionary m_nameRequestCache = new Dictionary(); public IUserService UserService { get { return m_userService; } } - - protected IGridServices m_gridService; + protected IUserService m_userService; public IGridServices GridService { get { return m_gridService; } } - - - protected IInterRegionCommunications m_interRegion; - + protected IGridServices m_gridService; + public IInterRegionCommunications InterRegion { get { return m_interRegion; } } - - protected UserProfileCacheService m_userProfileCacheService; + protected IInterRegionCommunications m_interRegion; public UserProfileCacheService UserProfileCacheService { get { return m_userProfileCacheService; } } + protected UserProfileCacheService m_userProfileCacheService; // protected AgentAssetTransactionsManager m_transactionsManager; // public AgentAssetTransactionsManager TransactionsManager // { // get { return m_transactionsManager; } - // } - - protected IAvatarService m_avatarService; + // } public IAvatarService AvatarService { get { return m_avatarService; } } - - protected AssetCache m_assetCache; + protected IAvatarService m_avatarService; public AssetCache AssetCache { get { return m_assetCache; } } - - protected NetworkServersInfo m_networkServersInfo; + protected AssetCache m_assetCache; + + public IInterGridInventoryServices InterGridInventoryService + { + get { return m_interGridInventoryService; } + } + protected IInterGridInventoryServices m_interGridInventoryService; public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } } + protected NetworkServersInfo m_networkServersInfo; + /// + /// Constructor + /// + /// + /// + /// + /// public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool dumpAssetsToFile) { diff --git a/OpenSim/Framework/Communications/IInterGridInventoryServices.cs b/OpenSim/Framework/Communications/IInterGridInventoryServices.cs index 1ef1452..e820c5e 100644 --- a/OpenSim/Framework/Communications/IInterGridInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInterGridInventoryServices.cs @@ -34,12 +34,7 @@ namespace OpenSim.Framework.Communications /// Inventory operations used between grid services. /// public interface IInterGridInventoryServices - { - string Host - { - get; - } - + { /// /// Create a new inventory for the given user. /// diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 18e1a2d..bb16a49 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -42,6 +42,11 @@ namespace OpenSim.Framework.Communications /// public interface IInventoryServices : IInterGridInventoryServices { + string Host + { + get; + } + /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index 0e7861a..1da3115 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -31,7 +31,6 @@ using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications { - /// /// Defines all the operations one can perform on a user's inventory. /// @@ -41,6 +40,7 @@ namespace OpenSim.Framework.Communications { get; } + /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received @@ -105,21 +105,11 @@ namespace OpenSim.Framework.Communications /// true if the inventory was successfully created, false otherwise bool CreateNewUserInventory(LLUUID user); - bool HasInventoryForUser(LLUUID userID); - /// - /// Retrieve the root inventory folder for the given user. + /// Does the given user have an inventory structure? /// /// - /// null if no root folder was found - InventoryFolderBase RequestRootFolder(LLUUID userID); - - /// - /// Returns a list of all the folders in a given user's inventory. - /// - /// - /// A flat list of the user's inventory folder tree, - /// null if there is no inventory for this user - List GetInventorySkeleton(LLUUID userId); + /// + bool HasInventoryForUser(LLUUID userID); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index d26a3bb..fd2e6b1 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications /// /// Abstract base class used by local and grid implementations of an inventory service. /// - public abstract class InventoryServiceBase : IInventoryServices + public abstract class InventoryServiceBase : IInventoryServices, IInterGridInventoryServices { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 29e8fcd13c99606813c916c4d464372572af230f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 24 Jul 2008 15:20:57 +0000 Subject: * minor: Rename IInterGridInventoryServices since it's inter service rather than inter grid --- .../Communications/CommunicationsManager.cs | 8 ++-- .../Communications/IInterGridInventoryServices.cs | 53 ---------------------- .../IInterServiceInventoryServices.cs | 53 ++++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 2 +- 5 files changed, 59 insertions(+), 59 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IInterGridInventoryServices.cs create mode 100644 OpenSim/Framework/Communications/IInterServiceInventoryServices.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 6272872..3659d86 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -88,11 +88,11 @@ namespace OpenSim.Framework.Communications } protected AssetCache m_assetCache; - public IInterGridInventoryServices InterGridInventoryService + public IInterServiceInventoryServices InterServiceInventoryService { - get { return m_interGridInventoryService; } + get { return m_interServiceInventoryService; } } - protected IInterGridInventoryServices m_interGridInventoryService; + protected IInterServiceInventoryServices m_interServiceInventoryService; public NetworkServersInfo NetworkServersInfo { @@ -296,7 +296,7 @@ namespace OpenSim.Framework.Communications } else { - InventoryService.CreateNewUserInventory(userProf.ID); + InterServiceInventoryService.CreateNewUserInventory(userProf.ID); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); return userProf.ID; } diff --git a/OpenSim/Framework/Communications/IInterGridInventoryServices.cs b/OpenSim/Framework/Communications/IInterGridInventoryServices.cs deleted file mode 100644 index e820c5e..0000000 --- a/OpenSim/Framework/Communications/IInterGridInventoryServices.cs +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using libsecondlife; - -namespace OpenSim.Framework.Communications -{ - /// - /// Inventory operations used between grid services. - /// - public interface IInterGridInventoryServices - { - /// - /// Create a new inventory for the given user. - /// - /// - /// true if the inventory was successfully created, false otherwise - bool CreateNewUserInventory(LLUUID user); - - /// - /// Returns a list of all the folders in a given user's inventory. - /// - /// - /// A flat list of the user's inventory folder tree, - /// null if there is no inventory for this user - List GetInventorySkeleton(LLUUID userId); - } -} diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs new file mode 100644 index 0000000..24213f2 --- /dev/null +++ b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Communications +{ + /// + /// Inventory operations used between grid services. + /// + public interface IInterServiceInventoryServices + { + /// + /// Create a new inventory for the given user. + /// + /// + /// true if the inventory was successfully created, false otherwise + bool CreateNewUserInventory(LLUUID user); + + /// + /// Returns a list of all the folders in a given user's inventory. + /// + /// + /// A flat list of the user's inventory folder tree, + /// null if there is no inventory for this user + List GetInventorySkeleton(LLUUID userId); + } +} diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index bb16a49..08a2c5f 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications /// /// Defines all the operations one can perform on a user's inventory. /// - public interface IInventoryServices : IInterGridInventoryServices + public interface IInventoryServices { string Host { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index fd2e6b1..06b707b 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications /// /// Abstract base class used by local and grid implementations of an inventory service. /// - public abstract class InventoryServiceBase : IInventoryServices, IInterGridInventoryServices + public abstract class InventoryServiceBase : IInventoryServices, IInterServiceInventoryServices { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 77297ed6cce787c662d67880e15ecaff5f1b4ca1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 24 Jul 2008 15:56:50 +0000 Subject: * Separate out OGS1 calls used between services (rather than from region to services) into a separate assembly to parallel OpenSim.Region.Communications.OGS1 --- .../Framework/Communications/ISecureInventoryService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index 1da3115..3608c56 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -99,17 +99,17 @@ namespace OpenSim.Framework.Communications bool DeleteItem(InventoryItemBase item, LLUUID session_id); /// - /// Create a new inventory for the given user. - /// - /// - /// true if the inventory was successfully created, false otherwise - bool CreateNewUserInventory(LLUUID user); - - /// /// Does the given user have an inventory structure? /// /// /// bool HasInventoryForUser(LLUUID userID); + + /// + /// Retrieve the root inventory folder for the given user. + /// + /// + /// null if no root folder was found + InventoryFolderBase RequestRootFolder(LLUUID userID); } } -- cgit v1.1 From cdd353770691cb3c6bfcb452fc0fe2c2dffa454e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 24 Jul 2008 17:19:33 +0000 Subject: * refactor: Remove now redundant inventory server url being passed to GetInventorySkeleton --- OpenSim/Framework/Communications/LoginService.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e7124c9..e95dd21 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -94,7 +94,7 @@ namespace OpenSim.Framework.Communications /// /// /// This will be thrown if there is a problem with the inventory service - protected abstract InventoryData GetInventorySkeleton(LLUUID userID, string inventoryServerUrl); + protected abstract InventoryData GetInventorySkeleton(LLUUID userID); /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message @@ -230,12 +230,7 @@ namespace OpenSim.Framework.Communications try { - string inventoryServerUrl = ""; - //if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) - //{ - // inventoryServerUrl = userProfile.UserInventoryURI; - //} - inventData = GetInventorySkeleton(agentID, inventoryServerUrl); + inventData = GetInventorySkeleton(agentID); } catch (Exception e) { @@ -390,15 +385,7 @@ namespace OpenSim.Framework.Communications { LLUUID agentID = userProfile.ID; - // Inventory Library Section - - string inventoryServerUrl = ""; - //if (!String.IsNullOrEmpty(userProfile.UserInventoryURI)) - //{ - // inventoryServerUrl = userProfile.UserInventoryURI; - //} - - InventoryData inventData = GetInventorySkeleton(agentID, inventoryServerUrl); + InventoryData inventData = GetInventorySkeleton(agentID); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -817,4 +804,4 @@ namespace OpenSim.Framework.Communications } } } -} \ No newline at end of file +} -- cgit v1.1 From 84cc69573bb522122606c3bc29c8ab188d4ccf70 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Fri, 25 Jul 2008 07:16:27 +0000 Subject: Thanks, lulurun, for a patch that adds an authenticated session cache to reduce "check_auth_session" requests from inventory server to user server. --- .../Communications/Cache/AuthedSessionCache.cs | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs new file mode 100644 index 0000000..b989997 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Communications.Cache +{ + public class AuthedSessionCache + { + public class CacheData + { + private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); + private string m_session_id; + private string m_agent_id; + private int m_expire; + + private int get_current_unix_time() + { + return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; + } + + public CacheData(string sid, string aid) + { + m_session_id = sid; + m_agent_id = aid; + m_expire = get_current_unix_time() + DEFAULT_LIFETIME; + } + + public CacheData(string sid, string aid, int time_now) + { + m_session_id = sid; + m_agent_id = aid; + m_expire = time_now + DEFAULT_LIFETIME; + } + + public string SessionID + { + get { return m_session_id; } + set { m_session_id = value; } + } + + public string AgentID + { + get { return m_agent_id; } + set { m_agent_id = value; } + } + + public bool isExpired + { + get { return m_expire < get_current_unix_time(); } + } + + public void Renew() + { + m_expire = get_current_unix_time() + DEFAULT_LIFETIME; + } + } + + private static readonly int DEFAULT_LIFETIME = 30; + private Dictionary m_authed_sessions = new Dictionary(); + private int m_session_lifetime = DEFAULT_LIFETIME; + + public AuthedSessionCache() + { + m_session_lifetime = DEFAULT_LIFETIME; + } + + public AuthedSessionCache(int timeout) + { + m_session_lifetime = timeout; + } + + public CacheData getCachedSession(string session_id, string agent_id) + { + CacheData ret = null; + lock (m_authed_sessions) + { + if (m_authed_sessions.ContainsKey(session_id)) + { + CacheData cached_session = m_authed_sessions[session_id]; + if (!cached_session.isExpired && cached_session.AgentID == agent_id) + { + ret = m_authed_sessions[session_id]; + // auto renew + m_authed_sessions[session_id].Renew(); + } + } + } + return ret; + } + + public void Add(string session_id, string agent_id) + { + CacheData data = new CacheData(session_id, agent_id); + lock (m_authed_sessions) + { + if (m_authed_sessions.ContainsKey(session_id)) + { + m_authed_sessions[session_id] = data; + } + else + { + m_authed_sessions.Add(session_id, data); + } + } + } + } +} -- cgit v1.1 From f2bc404e70aa41cb82e11203c741499c0091acc6 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 25 Jul 2008 12:59:41 +0000 Subject: squasing warning. --- OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs index b989997..625c42b 100644 --- a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs +++ b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs @@ -57,16 +57,16 @@ namespace OpenSim.Framework.Communications.Cache private static readonly int DEFAULT_LIFETIME = 30; private Dictionary m_authed_sessions = new Dictionary(); - private int m_session_lifetime = DEFAULT_LIFETIME; + // private int m_session_lifetime = DEFAULT_LIFETIME; public AuthedSessionCache() { - m_session_lifetime = DEFAULT_LIFETIME; + // m_session_lifetime = DEFAULT_LIFETIME; } public AuthedSessionCache(int timeout) { - m_session_lifetime = timeout; + // m_session_lifetime = timeout; } public CacheData getCachedSession(string session_id, string agent_id) -- cgit v1.1 From bfa1fd768b2c6bbd49542c2873a8fbf31747fcea Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 29 Jul 2008 03:43:31 +0000 Subject: Mantis#1849. Thank you kindly, Kinoc for a patch that: - LLSDLoginMethod should error out in similar way to XMLRPC login for already logged in condition - Have LLSDLoginMethod mirror the sequence of the XMLRPC for easier side by side compare - Log messages report which process XML or LLSD generated them for easier debugging --- OpenSim/Framework/Communications/LoginResponse.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 93 ++++++++++++++++------- 2 files changed, 66 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 113e3f0..686d1bb 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -475,7 +475,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); + m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); } @@ -777,4 +777,4 @@ namespace OpenSim.Framework.Communications } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e95dd21..d603052 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -130,7 +130,7 @@ namespace OpenSim.Framework.Communications lastname = (string) requestData["last"]; m_log.InfoFormat( - "[LOGIN BEGIN]: Received login request message from user {0} {1}", + "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", firstname, lastname); string clientVersion = "Unknown"; @@ -146,12 +146,12 @@ namespace OpenSim.Framework.Communications } m_log.DebugFormat( - "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); + "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - m_log.Info("[LOGIN END]: Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); return logResponse.CreateLoginFailedResponse(); } @@ -171,7 +171,7 @@ namespace OpenSim.Framework.Communications catch (Exception e) { m_log.InfoFormat( - "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", requestData["web_login_key"], firstname, lastname, e); return logResponse.CreateFailedResponse(); @@ -183,14 +183,14 @@ namespace OpenSim.Framework.Communications else { m_log.Info( - "[LOGIN END]: login_to_simulator login message did not contain all the required data"); + "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { - m_log.InfoFormat("[LOGIN END]: User {0} {1} failed authentication", firstname, lastname); + m_log.InfoFormat("[LOGIN END]: XMLRPC User {0} {1} failed authentication", firstname, lastname); return logResponse.CreateLoginFailedResponse(); } @@ -208,13 +208,13 @@ namespace OpenSim.Framework.Communications m_userManager.CommitAgent(ref userProfile); // try to tell the region that their user is dead. - LogOffUser(userProfile, "You were logged off because you logged in from another location"); + LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); // Reject the login m_log.InfoFormat( - "[LOGIN END]: Notifying user {0} {1} that they are already logged in", + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", firstname, lastname); return logResponse.CreateAlreadyLoggedInResponse(); @@ -235,7 +235,7 @@ namespace OpenSim.Framework.Communications catch (Exception e) { m_log.ErrorFormat( - "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", + "[LOGIN END]: XMLRPC Error retrieving inventory skeleton of agent {0}, {1} - {2}", agentID, e.GetType(), e.Message); return logResponse.CreateLoginInventoryFailedResponse(); @@ -288,7 +288,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[LOGIN END]: " + e.ToString()); + m_log.Info("[LOGIN END]: XMLRPC " + e.ToString()); return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } @@ -299,18 +299,18 @@ namespace OpenSim.Framework.Communications StatsManager.UserStats.AddSuccessfulLogin(); m_log.DebugFormat( - "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", firstname, lastname); return logResponse.ToXmlRpcResponse(); } catch (Exception e) { - m_log.Info("[LOGIN END]: Login failed, " + e.ToString()); + m_log.Info("[LOGIN END]: XMLRPC Login failed, " + e.ToString()); } } - m_log.Info("[LOGIN END]: Login failed. Sending back blank XMLRPC response"); + m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); return response; } finally @@ -345,14 +345,15 @@ namespace OpenSim.Framework.Communications if (map.ContainsKey("start")) { - m_log.Info("[LOGIN]: StartLocation Requested: " + map["start"].AsString()); + m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); startLocationRequest = map["start"].AsString(); } + m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname+"' '"+lastname+"' / "+passwd); userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - m_log.Info("[LOGIN]: Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); return logResponse.CreateLoginFailedResponseLLSD(); } @@ -370,10 +371,19 @@ namespace OpenSim.Framework.Communications // If we already have a session... if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) { - userProfile.CurrentAgent = null; + userProfile.CurrentAgent.AgentOnline = false; + m_userManager.CommitAgent(ref userProfile); + // try to tell the region that their user is dead. + LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); // Reject the login + + m_log.InfoFormat( + "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", + userProfile.FirstName, userProfile.SurName); + + userProfile.CurrentAgent = null; return logResponse.CreateAlreadyLoggedInResponseLLSD(); } @@ -385,7 +395,23 @@ namespace OpenSim.Framework.Communications { LLUUID agentID = userProfile.ID; - InventoryData inventData = GetInventorySkeleton(agentID); + //InventoryData inventData = GetInventorySkeleton(agentID); + InventoryData inventData = null; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", + agentID, e.GetType(), e.Message); + + return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); + } + + ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -394,6 +420,20 @@ namespace OpenSim.Framework.Communications InventoryRoot.Add(InventoryRootHash); userProfile.RootInventoryFolderID = inventData.RootFolderID; + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + logResponse.InventoryLibRoot = InventoryLibRoot; + + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); @@ -402,17 +442,7 @@ namespace OpenSim.Framework.Communications logResponse.AgentID = agentID.ToString(); logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); logResponse.CircuitCode = (Int32)circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten @@ -422,6 +452,7 @@ namespace OpenSim.Framework.Communications //logResponse.SimPort = 0; //overwritten logResponse.Message = GetMessage(); logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; try { @@ -429,7 +460,7 @@ namespace OpenSim.Framework.Communications } catch (Exception ex) { - m_log.Info("[LOGIN]: " + ex.ToString()); + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); return logResponse.CreateDeadRegionResponseLLSD(); } @@ -439,11 +470,15 @@ namespace OpenSim.Framework.Communications if (StatsManager.UserStats != null) StatsManager.UserStats.AddSuccessfulLogin(); + m_log.DebugFormat( + "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", + userProfile.FirstName, userProfile.SurName); + return logResponse.ToLLSDResponse(); } catch (Exception ex) { - m_log.Info("[LOGIN]: " + ex.ToString()); + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); return logResponse.CreateFailedResponseLLSD(); } } -- cgit v1.1 From e595959d97f35bf866801fff8b9ceb1ed35b3825 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 29 Jul 2008 17:39:15 +0000 Subject: * refactor: move create user console command parsing down to OpenSim.cs from CommunicationsManager --- .../Communications/CommunicationsManager.cs | 47 +--------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 3659d86..2bfe045 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -31,7 +31,6 @@ using System.Reflection; using libsecondlife; using log4net; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using OpenSim.Framework.Servers; namespace OpenSim.Framework.Communications @@ -231,50 +230,6 @@ namespace OpenSim.Framework.Communications #endregion - public void doCreate(string[] cmmdParams) - { - switch (cmmdParams[0]) - { - case "user": - string firstName; - string lastName; - string password; - uint regX = 1000; - uint regY = 1000; - - if (cmmdParams.Length < 2) - firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); - else firstName = cmmdParams[1]; - - if ( cmmdParams.Length < 3 ) - lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); - else lastName = cmmdParams[2]; - - if ( cmmdParams.Length < 4 ) - password = MainConsole.Instance.PasswdPrompt("Password"); - else password = cmmdParams[3]; - - if ( cmmdParams.Length < 5 ) - regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); - else regX = Convert.ToUInt32(cmmdParams[4]); - - if ( cmmdParams.Length < 6 ) - regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); - else regY = Convert.ToUInt32(cmmdParams[5]); - - - if (null == m_userService.GetUserProfile(firstName, lastName)) - { - AddUser(firstName, lastName, password, regX, regY); - } - else - { - m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName); - } - break; - } - } - /// /// Persistently adds a user to OpenSim. /// @@ -283,7 +238,7 @@ namespace OpenSim.Framework.Communications /// /// /// - /// The UUID of the added user. Returns null if the add was unsuccessful + /// The UUID of the added user. Returns LLUUID.Zero if the add was unsuccessful public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); -- cgit v1.1 From 2270b252656146d9d74b84665a7ace6c3139db30 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 09:24:28 +0000 Subject: Thanks, sempuki, for a patch that moves all Grid Server's plugins to PluginLoader. Fix issue 1871. --- .../Communications/Cache/AssetServerBase.cs | 2 +- .../Communications/Cache/SQLAssetServer.cs | 8 +- .../Communications/InventoryServiceBase.cs | 81 +++++----- .../Framework/Communications/UserManagerBase.cs | 169 +++++++++------------ 4 files changed, 114 insertions(+), 146 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index f729d78..ed5b896 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache protected IAssetReceiver m_receiver; protected BlockingQueue m_assetRequests; protected Thread m_localAssetServerThread; - protected IAssetProvider m_assetProvider; + protected IAssetProviderPlugin m_assetProvider; // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 94a8509..2f72e11 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache AddPlugin(pluginName, connect); } - public SQLAssetServer(IAssetProvider assetProvider) + public SQLAssetServer(IAssetProviderPlugin assetProvider) { m_assetProvider = assetProvider; } @@ -54,12 +54,12 @@ namespace OpenSim.Framework.Communications.Cache { if (!pluginType.IsAbstract) { - Type typeInterface = pluginType.GetInterface("IAssetProvider", true); + Type typeInterface = pluginType.GetInterface("IAssetProviderPlugin", true); if (typeInterface != null) { - IAssetProvider plug = - (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetProviderPlugin plug = + (IAssetProviderPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProvider = plug; m_assetProvider.Initialise(connect); diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 06b707b..40701f0 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -43,38 +43,25 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Dictionary m_plugins = new Dictionary(); + protected List m_plugins = new List(); #region Plugin methods /// /// 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, string connect) + /// The filename to the user server plugin DLL + public void AddPlugin(string provider, string connect) { - if (!String.IsNullOrEmpty(FileName)) - { - m_log.Info("[AGENT INVENTORY]: Inventory storage: 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(connect); - m_plugins.Add(plug.getName(), plug); - m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface"); - } - } - } - } + PluginLoader loader = + new PluginLoader (new InventoryDataInitialiser (connect)); + + // loader will try to load all providers (MySQL, MSSQL, etc) + // unless it is constrainted to the correct "Provider" entry in the addin.xml + loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); + loader.Load(); + + m_plugins = loader.Plugins; } #endregion @@ -103,9 +90,9 @@ namespace OpenSim.Framework.Communications userFolders.Add(rootFolder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.ID); + IList folders = plugin.getFolderHierarchy(rootFolder.ID); userFolders.AddRange(folders); } @@ -127,9 +114,9 @@ namespace OpenSim.Framework.Communications public InventoryFolderBase RequestRootFolder(LLUUID userID) { // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.Value.getUserRootFolder(userID); + return plugin.getUserRootFolder(userID); } return null; } @@ -168,9 +155,9 @@ namespace OpenSim.Framework.Communications public List RequestSubFolders(LLUUID parentFolderID) { List inventoryList = new List(); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.Value.getInventoryFolders(parentFolderID); + return plugin.getInventoryFolders(parentFolderID); } return inventoryList; } @@ -178,9 +165,9 @@ namespace OpenSim.Framework.Communications public List RequestFolderItems(LLUUID folderID) { List itemsList = new List(); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - itemsList = plugin.Value.getInventoryInFolder(folderID); + itemsList = plugin.getInventoryInFolder(folderID); return itemsList; } return itemsList; @@ -194,9 +181,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.addInventoryFolder(folder); + plugin.addInventoryFolder(folder); } // FIXME: Should return false on failure @@ -209,9 +196,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.updateInventoryFolder(folder); + plugin.updateInventoryFolder(folder); } // FIXME: Should return false on failure @@ -224,9 +211,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.moveInventoryFolder(folder); + plugin.moveInventoryFolder(folder); } // FIXME: Should return false on failure @@ -239,9 +226,9 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.addInventoryItem(item); + plugin.addInventoryItem(item); } // FIXME: Should return false on failure @@ -254,9 +241,9 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat( "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.updateInventoryItem(item); + plugin.updateInventoryItem(item); } // FIXME: Should return false on failure @@ -269,9 +256,9 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat( "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.deleteInventoryItem(item.ID); + plugin.deleteInventoryItem(item.ID); } // FIXME: Should return false on failure @@ -296,9 +283,9 @@ namespace OpenSim.Framework.Communications { // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); - foreach (KeyValuePair plugin in m_plugins) + foreach (IInventoryDataPlugin plugin in m_plugins) { - plugin.Value.deleteInventoryFolder(subFolder.ID); + plugin.deleteInventoryFolder(subFolder.ID); } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1b73152..f8e77df 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -47,42 +47,23 @@ namespace OpenSim.Framework.Communications = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; - private Dictionary _plugins = new Dictionary(); + private List _plugins = new List(); /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// - /// The filename to the user server plugin DLL - public void AddPlugin(string FileName, string connect) + /// The filename to the user server plugin DLL + public void AddPlugin(string provider, string connect) { - if (!String.IsNullOrEmpty(FileName)) - { - m_log.Info("[USERSTORAGE]: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - m_log.Info("[USERSTORAGE]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IUserData", true); - - if (typeInterface != null) - { - IUserData plug = - (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - AddPlugin(plug, connect); - } - } - } - } - } - - public void AddPlugin(IUserData plug, string connect) - { - plug.Initialise(connect); - _plugins.Add(plug.Name, plug); - m_log.Info("[USERSTORAGE]: Added IUserData Interface"); + PluginLoader loader = + new PluginLoader (new UserDataInitialiser (connect)); + + // loader will try to load all providers (MySQL, MSSQL, etc) + // unless it is constrainted to the correct "Provider" entry in the addin.xml + loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); + loader.Load(); + + _plugins = loader.Plugins; } #region Get UserProfile @@ -90,9 +71,9 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(string fname, string lname) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + UserProfileData profile = plugin.GetUserByName(fname, lname); if (profile != null) { @@ -105,9 +86,9 @@ namespace OpenSim.Framework.Communications } public UserAgentData GetAgentByUUID(LLUUID userId) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserAgentData agent = plugin.Value.GetAgentByUUID(userId); + UserAgentData agent = plugin.GetAgentByUUID(userId); if (agent != null) { @@ -120,9 +101,9 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(LLUUID uuid) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { - UserProfileData profile = plugin.Value.GetUserByUUID(uuid); + UserProfileData profile = plugin.GetUserByUUID(uuid); if (null != profile) { @@ -137,15 +118,15 @@ namespace OpenSim.Framework.Communications public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { List pickerlist = new List(); - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - pickerlist = plugin.Value.GeneratePickerResults(queryID, query); + pickerlist = plugin.GeneratePickerResults(queryID, query); } catch (Exception) { - m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); return new List(); } } @@ -159,17 +140,17 @@ namespace OpenSim.Framework.Communications /// public bool UpdateUserProfile(UserProfileData data) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserProfile(data); + plugin.UpdateUserProfile(data); return true; } catch (Exception e) { m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, - plugin.Key, e.ToString()); + plugin.Name, e.ToString()); } } return false; @@ -186,15 +167,15 @@ namespace OpenSim.Framework.Communications /// Agent profiles public UserAgentData GetUserAgent(LLUUID uuid) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByUUID(uuid); + return plugin.GetAgentByUUID(uuid); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -208,15 +189,15 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string name) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByName(name); + return plugin.GetAgentByName(name); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -231,15 +212,15 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string fname, string lname) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAgentByName(fname, lname); + return plugin.GetAgentByName(fname, lname); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -248,15 +229,15 @@ namespace OpenSim.Framework.Communications public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); + plugin.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -268,15 +249,15 @@ namespace OpenSim.Framework.Communications /// A List of FriendListItems that contains info about the user's friends public List GetUserFriendList(LLUUID ownerID) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetUserFriendList(ownerID); + return plugin.GetUserFriendList(ownerID); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -285,60 +266,60 @@ namespace OpenSim.Framework.Communications public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.StoreWebLoginKey(agentID, webLoginKey); + plugin.StoreWebLoginKey(agentID, webLoginKey); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserFriend(friendlistowner,friend,perms); + plugin.AddNewUserFriend(friendlistowner,friend,perms); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.RemoveUserFriend(friendlistowner, friend); + plugin.RemoveUserFriend(friendlistowner, friend); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserFriendPerms(friendlistowner, friend, perms); + plugin.UpdateUserFriendPerms(friendlistowner, friend, perms); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -564,15 +545,15 @@ namespace OpenSim.Framework.Communications user.HomeRegionX = regX; user.HomeRegionY = regY; - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserProfile(user); + plugin.AddNewUserProfile(user); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -586,16 +567,16 @@ namespace OpenSim.Framework.Communications m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString()); return false; } - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserProfile(UserProfile); + plugin.UpdateUserProfile(UserProfile); } catch (Exception e) { m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() - + " via " + plugin.Key + "(" + e.ToString() + ")"); + + " via " + plugin.Name + "(" + e.ToString() + ")"); return false; } } @@ -612,16 +593,16 @@ namespace OpenSim.Framework.Communications /// The agent data to be added public bool AddUserAgent(UserAgentData agentdata) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddNewUserAgent(agentdata); + plugin.AddNewUserAgent(agentdata); return true; } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Key + "(" + e.ToString() + ")"); + m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); } } return false; @@ -631,15 +612,15 @@ namespace OpenSim.Framework.Communications /// TODO: stubs for now to get us to a compiling state gently public AvatarAppearance GetUserAppearance(LLUUID user) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetUserAppearance(user); + return plugin.GetUserAppearance(user); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } return null; @@ -647,60 +628,60 @@ namespace OpenSim.Framework.Communications public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.UpdateUserAppearance(user, appearance); + plugin.UpdateUserAppearance(user, appearance); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } } public void AddAttachment(LLUUID user, LLUUID item) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.AddAttachment(user, item); + plugin.AddAttachment(user, item); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); } } } public void RemoveAttachment(LLUUID user, LLUUID item) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - plugin.Value.RemoveAttachment(user, item); + plugin.RemoveAttachment(user, item); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); } } } public List GetAttachments(LLUUID user) { - foreach (KeyValuePair plugin in _plugins) + foreach (IUserData plugin in _plugins) { try { - return plugin.Value.GetAttachments(user); + return plugin.GetAttachments(user); } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); + m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } return new List(); -- cgit v1.1 From 58af0fabeb909452e1db615afd05a1bb78678191 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 15:53:07 +0000 Subject: * minor: reduce coupling by passing in only session id to CachedUserInfo --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 12 ++++++++++-- .../Communications/Cache/UserProfileCacheService.cs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 11516f0..4c0aaa2 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -101,11 +101,19 @@ namespace OpenSim.Framework.Communications.Cache m_userProfile = userProfile; } - public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile, IClientAPI remoteClient) + /// + /// Constructor + /// + /// + /// + /// + /// Session id of the user. This is used in subsequent security checks. + /// + public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile, LLUUID sessionId) { m_commsManager = commsManager; m_userProfile = userProfile; - m_session_id = remoteClient.SessionId; + m_session_id = sessionId; } /// diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index d6421b0..5f98c08 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -71,7 +71,7 @@ namespace OpenSim.Framework.Communications.Cache if (!m_userProfiles.ContainsKey(remoteClient.AgentId)) { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(remoteClient.AgentId); - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile, remoteClient); + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile, remoteClient.SessionId); if (userInfo.UserProfile != null) { -- cgit v1.1 From 078643a017cd94dce2d16e4c8db3cc18fd95ed9d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 16:05:50 +0000 Subject: * refactor: Change CachedUserInfo.HasInventory to HasReceivedInventory to make actual function clearer --- .../Communications/Cache/CachedUserInfo.cs | 29 +++++++++++----------- .../Cache/UserProfileCacheService.cs | 8 +++--- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 4c0aaa2..d6e1715 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -66,7 +66,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// Has we received the user's inventory from the inventory service? /// - private bool m_hasInventory; + public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } + private bool m_hasReceivedInventory; /// /// Inventory requests waiting for receipt of this user's inventory from the inventory service. @@ -74,12 +75,10 @@ namespace OpenSim.Framework.Communications.Cache private readonly IList m_pendingRequests = new List(); /// - /// Has this user info object yet received its inventory information from the invetnroy service? + /// The root folder of this user's inventory. Returns null if the inventory has not yet been received. /// - public bool HasInventory { get { return m_hasInventory; } } - - private InventoryFolderImpl m_rootFolder; public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } + private InventoryFolderImpl m_rootFolder; /// /// FIXME: This could be contained within a local variable - it doesn't need to be a field @@ -126,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache { lock (m_pendingRequests) { - if (m_hasInventory) + if (HasReceivedInventory) { request.Execute(); } @@ -216,7 +215,7 @@ namespace OpenSim.Framework.Communications.Cache { // We're going to change inventory status within the lock to avoid a race condition // where requests are processed after the AddRequest() method has been called. - m_hasInventory = true; + m_hasReceivedInventory = true; foreach (IInventoryRequest request in m_pendingRequests) { @@ -318,7 +317,7 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat( // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); - if (HasInventory) + if (m_hasReceivedInventory) { InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); @@ -393,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat( // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); - if (HasInventory) + if (m_hasReceivedInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = m_userProfile.ID; @@ -445,7 +444,7 @@ namespace OpenSim.Framework.Communications.Cache // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); - if (HasInventory) + if (m_hasReceivedInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = m_userProfile.ID; @@ -491,7 +490,7 @@ namespace OpenSim.Framework.Communications.Cache // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", // folderID, remoteClient.Name, remoteClient.AgentId); - if (HasInventory) + if (m_hasReceivedInventory) { InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID); @@ -539,7 +538,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddItem(InventoryItemBase item) { - if (HasInventory) + if (m_hasReceivedInventory) { if (item.Folder == LLUUID.Zero) { @@ -575,7 +574,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void UpdateItem(InventoryItemBase item) { - if (HasInventory) + if (m_hasReceivedInventory) { if (m_commsManager.SecureInventoryService != null) { @@ -608,7 +607,7 @@ namespace OpenSim.Framework.Communications.Cache /// public bool DeleteItem(LLUUID itemID) { - if (HasInventory) + if (m_hasReceivedInventory) { // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though // really only the item id is required. @@ -656,7 +655,7 @@ namespace OpenSim.Framework.Communications.Cache /// true if the request was queued or successfully processed, false otherwise public bool SendInventoryDecendents(IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems) { - if (HasInventory) + if (m_hasReceivedInventory) { InventoryFolderImpl folder; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 5f98c08..ac52535 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -348,7 +348,7 @@ namespace OpenSim.Framework.Communications.Cache // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad // in CAPS as doing this with the udp request, since here it won't hold up other packets. // In fact, here we'll be generous and try for longer. - if (!userProfile.HasInventory) + if (!userProfile.HasReceivedInventory) { int attempts = 0; while (attempts++ < 30) @@ -359,14 +359,14 @@ namespace OpenSim.Framework.Communications.Cache Thread.Sleep(2000); - if (userProfile.HasInventory) + if (userProfile.HasReceivedInventory) { break; } } } - if (userProfile.HasInventory) + if (userProfile.HasReceivedInventory) { if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) { @@ -434,7 +434,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) + if (userProfile.HasReceivedInventory) { InventoryItemBase item = userProfile.RootFolder.FindItem(itemID); if (item != null) -- cgit v1.1 From a62b906a7b77340c61c4d3b084c3d950cf5172ba Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 17:32:13 +0000 Subject: * allow inventory folders to be located by path * first pass method impl --- .../Communications/Cache/CachedUserInfo.cs | 6 +-- .../Communications/Cache/InventoryFolderImpl.cs | 58 +++++++++++++++++++--- 2 files changed, 55 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d6e1715..025b934 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache private readonly UserProfileData m_userProfile; /// - /// Has we received the user's inventory from the inventory service? + /// Have we received the user's inventory from the inventory service? /// public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } private bool m_hasReceivedInventory; @@ -85,9 +85,9 @@ namespace OpenSim.Framework.Communications.Cache /// private IDictionary> pendingCategorizationFolders = new Dictionary>(); - - private LLUUID m_session_id = LLUUID.Zero; + public LLUUID SessionID { get { return m_session_id; } } + private LLUUID m_session_id = LLUUID.Zero; /// /// Constructor diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 0fbc427..b1fdf76 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using libsecondlife; //using System.Reflection; @@ -36,12 +37,22 @@ namespace OpenSim.Framework.Communications.Cache public class InventoryFolderImpl : InventoryFolderBase { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public static readonly string PATH_DELIMITER = "/"; - // Fields + /// + /// Items that are contained in this folder + /// public Dictionary Items = new Dictionary(); + + /// + /// Child folders that are contained in this folder + /// public Dictionary SubFolders = new Dictionary(); - // Accessors + /// + /// The number of child folders + /// public int SubFoldersCount { get { return SubFolders.Count; } @@ -177,9 +188,7 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl FindFolder(LLUUID folderID) { if (folderID == ID) - { return this; - } lock (SubFolders) { @@ -188,14 +197,51 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl returnFolder = folder.FindFolder(folderID); if (returnFolder != null) - { return returnFolder; - } } } return null; } + + /// + /// Find a folder given a PATH_DELIMITOR delimited path. + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// The path to the required folder. It this is empty then this folder itself is returned. + /// If a folder for the given path is not found, then null is returned. + /// + /// + public InventoryFolderImpl FindFolderByPath(string path) + { + if (path == string.Empty) + return this; + + int delimitorIndex = path.IndexOf(PATH_DELIMITER); + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + + lock (SubFolders) + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + if (folder.Name == components[0]) + if (components.Length > 1) + return folder.FindFolderByPath(components[1]); + else + return folder; + } + } + + // We didn't find a folder with the given name + return null; + } /// /// Return the list of child items in this folder -- cgit v1.1 From 465e77b61883c52cf0ab01079e6cc509cfc9fda1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 17:35:47 +0000 Subject: * refactor: eliminate unused SubFoldersCount --- .../Framework/Communications/Cache/InventoryFolderImpl.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index b1fdf76..ee3fc55 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -49,15 +49,7 @@ namespace OpenSim.Framework.Communications.Cache /// Child folders that are contained in this folder /// public Dictionary SubFolders = new Dictionary(); - - /// - /// The number of child folders - /// - public int SubFoldersCount - { - get { return SubFolders.Count; } - } - + // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) { @@ -244,7 +236,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return the list of child items in this folder + /// Return a copy of the list of child items in this folder /// public List RequestListOfItems() { @@ -264,7 +256,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return the list of immediate child folders in this folder. + /// Return a copy of the list of immediate child folders in this folder. /// public List RequestListOfFolders() { -- cgit v1.1 From 900a6564203b69851cf43fc87eb7190c82acec38 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 18:23:17 +0000 Subject: * refactor: rearrange path inventory manipulation so that input tidying can be used for item paths as well --- .../Communications/Cache/InventoryFolderImpl.cs | 55 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index ee3fc55..96853f0 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Returns the item if it exists in this folder or any of this folder's subfolders? + /// Returns the item if it exists in this folder or in any of this folder's descendant folders /// /// /// null if the item is not found @@ -197,7 +197,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Find a folder given a PATH_DELIMITOR delimited path. + /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder /// /// This method does not handle paths that contain multiple delimitors /// @@ -208,9 +208,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// The path to the required folder. It this is empty then this folder itself is returned. - /// If a folder for the given path is not found, then null is returned. /// - /// + /// null if the folder is not found public InventoryFolderImpl FindFolderByPath(string path) { if (path == string.Empty) @@ -234,6 +233,52 @@ namespace OpenSim.Framework.Communications.Cache // We didn't find a folder with the given name return null; } + + /// + /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. + /// + /// This method does not handle paths that contain multiple delimitors + /// + /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some + /// XPath like expression + /// + /// FIXME: Delimitors which occur in names themselves are not currently escapable. + /// + /// + /// The path to the required item. + /// + /// null if the item is not found + public InventoryItemBase FindItemByPath(string path) + { + int delimitorIndex = path.IndexOf(PATH_DELIMITER); + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + + if (components.Length == 1) + { + lock (Items) + { + foreach (InventoryItemBase item in Items.Values) + { + if (item.Name == components[0]) + return item; + } + } + } + else + { + lock (SubFolders) + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + if (folder.Name == components[0]) + return folder.FindItemByPath(components[1]); + } + } + } + + // We didn't find an item or intermediate folder with the given name + return null; + } /// /// Return a copy of the list of child items in this folder @@ -256,7 +301,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return a copy of the list of immediate child folders in this folder. + /// Return a copy of the list of child folders in this folder. /// public List RequestListOfFolders() { -- cgit v1.1 From 15669281faab727cdf79ec1cee24d9b20fae8cbd Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 31 Jul 2008 23:53:24 +0000 Subject: Apply updated patch from issue 1871. Thanks sempuki. --- .../Framework/Communications/UserManagerBase.cs | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f8e77df..05077b6 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public UserConfig _config; - private List _plugins = new List(); + private List _plugins = new List(); /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. @@ -55,8 +55,8 @@ namespace OpenSim.Framework.Communications /// The filename to the user server plugin DLL public void AddPlugin(string provider, string connect) { - PluginLoader loader = - new PluginLoader (new UserDataInitialiser (connect)); + PluginLoader loader = + new PluginLoader (new UserDataInitialiser (connect)); // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml @@ -71,7 +71,7 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(string fname, string lname) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { UserProfileData profile = plugin.GetUserByName(fname, lname); @@ -86,7 +86,7 @@ namespace OpenSim.Framework.Communications } public UserAgentData GetAgentByUUID(LLUUID userId) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { UserAgentData agent = plugin.GetAgentByUUID(userId); @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Communications // see IUserService public UserProfileData GetUserProfile(LLUUID uuid) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { UserProfileData profile = plugin.GetUserByUUID(uuid); @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Communications public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { List pickerlist = new List(); - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -140,7 +140,7 @@ namespace OpenSim.Framework.Communications /// public bool UpdateUserProfile(UserProfileData data) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -167,7 +167,7 @@ namespace OpenSim.Framework.Communications /// Agent profiles public UserAgentData GetUserAgent(LLUUID uuid) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -189,7 +189,7 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string name) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -212,7 +212,7 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string fname, string lname) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -229,7 +229,7 @@ namespace OpenSim.Framework.Communications public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -249,7 +249,7 @@ namespace OpenSim.Framework.Communications /// A List of FriendListItems that contains info about the user's friends public List GetUserFriendList(LLUUID ownerID) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -266,7 +266,7 @@ namespace OpenSim.Framework.Communications public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -281,7 +281,7 @@ namespace OpenSim.Framework.Communications public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -296,7 +296,7 @@ namespace OpenSim.Framework.Communications public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -311,7 +311,7 @@ namespace OpenSim.Framework.Communications public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications user.HomeRegionX = regX; user.HomeRegionY = regY; - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -567,7 +567,7 @@ namespace OpenSim.Framework.Communications m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString()); return false; } - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -593,7 +593,7 @@ namespace OpenSim.Framework.Communications /// The agent data to be added public bool AddUserAgent(UserAgentData agentdata) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -612,7 +612,7 @@ namespace OpenSim.Framework.Communications /// TODO: stubs for now to get us to a compiling state gently public AvatarAppearance GetUserAppearance(LLUUID user) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -628,7 +628,7 @@ namespace OpenSim.Framework.Communications public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -643,7 +643,7 @@ namespace OpenSim.Framework.Communications public void AddAttachment(LLUUID user, LLUUID item) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -658,7 +658,7 @@ namespace OpenSim.Framework.Communications public void RemoveAttachment(LLUUID user, LLUUID item) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { @@ -673,7 +673,7 @@ namespace OpenSim.Framework.Communications public List GetAttachments(LLUUID user) { - foreach (IUserData plugin in _plugins) + foreach (IUserDataPlugin plugin in _plugins) { try { -- cgit v1.1 From de4e3bfede11250a17283fa0821ceb6aa338e3b3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 1 Aug 2008 16:22:26 +0000 Subject: * minor: eliminate some unused variables in InventoryFolderImpl --- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 96853f0..d7de9d6 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -215,7 +215,6 @@ namespace OpenSim.Framework.Communications.Cache if (path == string.Empty) return this; - int delimitorIndex = path.IndexOf(PATH_DELIMITER); string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); lock (SubFolders) @@ -250,7 +249,6 @@ namespace OpenSim.Framework.Communications.Cache /// null if the item is not found public InventoryItemBase FindItemByPath(string path) { - int delimitorIndex = path.IndexOf(PATH_DELIMITER); string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); if (components.Length == 1) -- cgit v1.1 From 43b2ff1d112174c36bb18caf353945afc6390840 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 1 Aug 2008 18:49:48 +0000 Subject: * Drop cached inventory from the local region when a user crosses out into a remote region * May resolves inventory problems that occur when the user moves between two regions` * e.g. if the user moves to a second region, adds an inventory item, moves back to the original region then tries to manipulate that item * Not yet implemented for teleport --- .../Framework/Communications/Cache/CachedUserInfo.cs | 17 ++++++++++++++++- .../Communications/Cache/UserProfileCacheService.cs | 12 +++++------- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 025b934..d85eda0 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Cache private readonly IList m_pendingRequests = new List(); /// - /// The root folder of this user's inventory. Returns null if the inventory has not yet been received. + /// The root folder of this user's inventory. Returns null if the root folder has not yet been received. /// public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } private InventoryFolderImpl m_rootFolder; @@ -183,6 +183,21 @@ namespace OpenSim.Framework.Communications.Cache } } } + + /// + /// Drop all cached inventory. + /// + public void DropInventory() + { + // Make sure there aren't pending requests around when we do this + // FIXME: There is still a race condition where an inventory operation can be requested (since these aren't being locked). + // Will have to extend locking to exclude this very soon. + lock (m_pendingRequests) + { + m_hasReceivedInventory = false; + m_rootFolder = null; + } + } /// /// Callback invoked when the inventory is received from an async request to the inventory service diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index ac52535..5045c97 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -118,21 +118,19 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the user was successfully removed, false otherwise - public bool RemoveUser(LLUUID userID) + public bool RemoveUser(LLUUID userId) { lock (m_userProfiles) { - if (m_userProfiles.ContainsKey(userID)) + if (m_userProfiles.ContainsKey(userId)) { - m_userProfiles.Remove(userID); + m_log.DebugFormat("[USER CACHE]: Removing user {0}", userId); + m_userProfiles.Remove(userId); return true; } - else - { - m_log.ErrorFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userID); - } } + m_log.ErrorFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); return false; } -- cgit v1.1 From 10e0df0a2d757fbdfe76b6c60d8939fd17c42451 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 1 Aug 2008 19:24:48 +0000 Subject: * correct bug from last commit - for now don't drop cached user profile when an agent is downgraded to a child agent * since upgrading to a root agent doesn't currently re-retrieve the user profile --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 5045c97..c4a6b31 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -65,6 +65,8 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddNewUser(IClientAPI remoteClient) { + m_log.DebugFormat("[USER CACHE]: Adding user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); + // Potential fix - Multithreading issue. lock (m_userProfiles) { @@ -92,6 +94,8 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddNewUser(LLUUID userID) { + m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); + // Potential fix - Multithreading issue. lock (m_userProfiles) { -- cgit v1.1 From 22f09fbd213ffd414514756b4a7ee0e86325d733 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 8 Aug 2008 10:59:32 +0000 Subject: * All CheckRegion within an instance would use the same, global, bool for 'Available', which would lead to intermittent failures on parallell teleport requests. * Solidified CheckRegion somewhat, adding a second try if the first failed. --- OpenSim/Framework/Communications/IInterRegionCommunications.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 28b0e12..57fb82d 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -32,8 +32,8 @@ namespace OpenSim.Framework.Communications public interface IInterRegionCommunications { string rdebugRegionName { get; set; } - bool Available { get; } - void CheckRegion(string address, uint port); + + bool CheckRegion(string address, uint port); bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData, int XMLMethod); bool RegionUp(SerializableRegionInfo region, ulong regionhandle); -- cgit v1.1 From 0fd2bde111eed6169f81c8459560d4746c51ca47 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 9 Aug 2008 20:41:18 +0000 Subject: * minor: remove unused grid send/receive keys from user server configuration --- OpenSim/Framework/Communications/UserManagerBase.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 05077b6..f477df4 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -46,7 +46,6 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public UserConfig _config; private List _plugins = new List(); /// -- cgit v1.1 From 8ea92c0669de17f4967540ecc1350860aa346f06 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 12 Aug 2008 06:21:02 +0000 Subject: Thanks, lulurun, for a patch that addresses inventory problems that occur occasionally, but are fixed on restart (issue 1919). This patch introduces the following changes: 1. when a user teleports out of Region A, remove that user's profile from the Region A user profile cache 2. when a user crosses between regions out of Region A, remove that user's profile from the Region A user profile cache 3. the user profile cache's session ID member can now be set (written), and is updated each time a connection with a new avatar is established (ie: a new avatar enters the region) 4. when a region server looks up a user profile and a cache miss occurs, fetch the user profile from the user server first instead of immediately returning null --- .../Communications/Cache/CachedUserInfo.cs | 23 ++----- .../Cache/UserProfileCacheService.cs | 78 +++++++--------------- 2 files changed, 30 insertions(+), 71 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d85eda0..57f5e76 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -85,8 +85,12 @@ namespace OpenSim.Framework.Communications.Cache /// private IDictionary> pendingCategorizationFolders = new Dictionary>(); - - public LLUUID SessionID { get { return m_session_id; } } + + public LLUUID SessionID + { + get { return m_session_id; } + set { m_session_id = value; } + } private LLUUID m_session_id = LLUUID.Zero; /// @@ -101,21 +105,6 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Constructor - /// - /// - /// - /// - /// Session id of the user. This is used in subsequent security checks. - /// - public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile, LLUUID sessionId) - { - m_commsManager = commsManager; - m_userProfile = userProfile; - m_session_id = sessionId; - } - - /// /// This allows a request to be added to be processed once we receive a user's inventory /// from the inventory service. If we already have the inventory, the request /// is executed immediately instead. diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index c4a6b31..db58738 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -63,58 +63,10 @@ namespace OpenSim.Framework.Communications.Cache /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// /// - public void AddNewUser(IClientAPI remoteClient) - { - m_log.DebugFormat("[USER CACHE]: Adding user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); - - // Potential fix - Multithreading issue. - lock (m_userProfiles) - { - if (!m_userProfiles.ContainsKey(remoteClient.AgentId)) - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(remoteClient.AgentId); - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile, remoteClient.SessionId); - - if (userInfo.UserProfile != null) - { - // The inventory for the user will be populated when they actually enter the scene - m_userProfiles.Add(remoteClient.AgentId, userInfo); - } - else - { - m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", remoteClient.AgentId); - } - } - } - } - - /// - /// A new user has moved into a region in this instance so retrieve their profile from the user service. - /// - /// public void AddNewUser(LLUUID userID) { - m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); - - // Potential fix - Multithreading issue. - lock (m_userProfiles) - { - if (!m_userProfiles.ContainsKey(userID)) - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userProfile); - - if (userInfo.UserProfile != null) - { - // The inventory for the user will be populated when they actually enter the scene - m_userProfiles.Add(userID, userInfo); - } - else - { - m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", userID); - } - } - } + m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); + GetUserDetails(userID); } /// @@ -176,10 +128,28 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(LLUUID userID) { - if (m_userProfiles.ContainsKey(userID)) - return m_userProfiles[userID]; - else - return null; + lock (m_userProfiles) + { + if (m_userProfiles.ContainsKey(userID)) + { + return m_userProfiles[userID]; + } + else + { + UserProfileData userprofile = m_commsManager.UserService.GetUserProfile(userID); + if (userprofile != null) + { + CachedUserInfo userinfo = new CachedUserInfo(m_commsManager, userprofile); + m_userProfiles.Add(userID, userinfo); + return userinfo; + } + else + { + m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", userID); + return null; + } + } + } } /// -- cgit v1.1 From 4e555b87f31c0e82b6120564cd6d8e2b41a3b8bf Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 12 Aug 2008 19:00:13 +0000 Subject: * Stop warnings about non existent scene presences/entities being removed on client log off * This is being done by preventing close from being called twice on child agent closure (nres which would have been thrown are being swallowed). * However, it should be possible to do much better cleanup on this code in the future --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index db58738..2bc8dcd 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -86,7 +86,9 @@ namespace OpenSim.Framework.Communications.Cache } } - m_log.ErrorFormat("[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); + m_log.WarnFormat( + "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); + return false; } -- cgit v1.1 From e3157e61aa50d057b4345cb9d49c973afeb26b15 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 00:04:37 +0000 Subject: Mantis #1946 Thank you, HomerHorwitz, for a patch that corrects and improves TP to landmark and home position handling. --- OpenSim/Framework/Communications/IGridServices.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 39f04c3..3ecda68 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -26,6 +26,7 @@ */ using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework.Communications { @@ -52,6 +53,7 @@ namespace OpenSim.Framework.Communications List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); + RegionInfo RequestNeighbourInfo(LLUUID regionID); RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); -- cgit v1.1 From e5a7ba5df4098aa0e7c24487736b07d7ede0d7e6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 16 Aug 2008 03:18:21 +0000 Subject: Guard against the null UUID being queried from the userserver repeatedly. --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 2bc8dcd..f96b15e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -65,6 +65,8 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddNewUser(LLUUID userID) { + if(userID == LLUUID.Zero) + return; m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); GetUserDetails(userID); } @@ -130,6 +132,9 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(LLUUID userID) { + if(userID == LLUUID.Zero) + return null; + lock (m_userProfiles) { if (m_userProfiles.ContainsKey(userID)) -- cgit v1.1 From 6fa26f5b41ab1a455783342c200fe68aeae515aa Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 16 Aug 2008 17:26:25 +0000 Subject: Update svn properties, minor formatting cleanup. --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index f96b15e..1360aa3 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddNewUser(LLUUID userID) { - if(userID == LLUUID.Zero) + if (userID == LLUUID.Zero) return; m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); GetUserDetails(userID); @@ -132,7 +132,7 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(LLUUID userID) { - if(userID == LLUUID.Zero) + if (userID == LLUUID.Zero) return null; lock (m_userProfiles) -- cgit v1.1 From d9cc908471922a1239bb8a757e07084072852982 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 16 Aug 2008 19:20:14 +0000 Subject: Mantis#1965. Thank you kindly, HomerHorwitz for a patch that: Places touched: - Added two events for in-packets to LLCLientView: RegionHandleRequest and ParcelInfoRequest - Added sending of two out-packets to LLCLientView: RegionIDAndHandleReply and ParcelInfoReply. - Scene handles the RegionHandleRequest, LandManagementModule the ParcelInfoRequest - Added inter-region request for LandData by RegionHandle and local position. This was implemented as XML-RPC request. The returned LandData isn't complete, it only contains the data necessary for answering the ParcelInfoRequest - Added new CAPS (0009) for RemoteParcelRequest and some methods for LandData handling to LandManagementModule - Added methods for fake parcelID creation and parsing to Util - Fixed missing implementation of interface methods. - Added new file: OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs NOTE: This is part of the patch, too. Due to the many places touched, I would consider this patch as experimental. --- .../Framework/Communications/Capabilities/Caps.cs | 4 ++- .../Capabilities/LLSDRemoteParcelResponse.cs | 42 ++++++++++++++++++++++ OpenSim/Framework/Communications/IGridServices.cs | 2 ++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 7350d4d..1aa8eb0 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -86,11 +86,13 @@ namespace OpenSim.Framework.Communications.Capabilities private static readonly string m_notecardTaskUpdatePath = "0005/"; // private static readonly string m_fetchInventoryPath = "0006/"; - // The following two entries are in a module, however, there also here so that we don't re-assign + // The following entries are in a module, however, they are also here so that we don't re-assign // the path to another cap by mistake. // private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. + // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. + //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; private LLUUID m_agentID; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs new file mode 100644 index 0000000..27adea0 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs @@ -0,0 +1,42 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; + +namespace OpenSim.Framework.Communications.Capabilities +{ + [LLSDType("MAP")] + public class LLSDRemoteParcelResponse + { + public LLUUID parcel_id; + + public LLSDRemoteParcelResponse() + { + } + } +} diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 3ecda68..509f408 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -57,5 +57,7 @@ namespace OpenSim.Framework.Communications RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); + // not complete yet, only contains the fields needed for ParcelInfoReqeust + LandData RequestLandData(ulong regionHandle, uint x, uint y); } } -- cgit v1.1 From 701ee43e4626db815b87d51ead81d9c8ac426b4b Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 16 Aug 2008 20:02:51 +0000 Subject: Mantis#1960. Thank you kindly, Tyre for a patch that: This small patch enables updates to the lastLogin information in the `users` table --- OpenSim/Framework/Communications/LoginService.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d603052..fd5f139 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -292,6 +292,8 @@ namespace OpenSim.Framework.Communications return logResponse.CreateDeadRegionResponse(); //return logResponse.ToXmlRpcResponse(); } + + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; CommitAgent(ref userProfile); // If we reach this point, then the login has successfully logged onto the grid @@ -464,6 +466,7 @@ namespace OpenSim.Framework.Communications return logResponse.CreateDeadRegionResponseLLSD(); } + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; CommitAgent(ref userProfile); // If we reach this point, then the login has successfully logged onto the grid -- cgit v1.1 From 992b04a23e19d3e5a4f88169ce33c9b2ddb4f4de Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 16 Aug 2008 20:42:43 +0000 Subject: * Move GridInfoService into Framework.Communications and eliminate Common.Communications for now (since this was the only class in that project) --- .../Framework/Communications/GridInfoService.cs | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 OpenSim/Framework/Communications/GridInfoService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs new file mode 100644 index 0000000..d51bc59 --- /dev/null +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -0,0 +1,155 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework.Servers; +using OpenSim.Framework; + +namespace OpenSim.Framework.Communications +{ + public class GridInfoService + { + private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable _info = new Hashtable(); + + /// + /// Instantiate a GridInfoService object. + /// + /// path to config path containing + /// grid information + /// + /// GridInfoService uses the [GridInfo] section of the + /// standard OpenSim.ini file --- which is not optimal, but + /// anything else requires a general redesign of the config + /// system. + /// + public GridInfoService(string configPath) + { + _info["platform"] = "OpenSim"; + if (File.Exists(configPath)) + { + try + { + IConfigSource _configSource = new IniConfigSource(configPath); + IConfig startupCfg = _configSource.Configs["Startup"]; + IConfig gridCfg = _configSource.Configs["GridInfo"]; + IConfig netCfg = _configSource.Configs["Network"]; + + bool grid = startupCfg.GetBoolean("gridmode", false); + + if (grid) + _info["mode"] = "grid"; + else + _info["mode"] = "standalone"; + + + if (null != gridCfg) + { + foreach (string k in gridCfg.GetKeys()) + { + _info[k] = gridCfg.GetString(k); + } + } + else if (null != netCfg) + { + if (grid) + _info["login"] = netCfg.GetString("user_server_url"); + else + _info["login"] = String.Format("http://127.0.0.1:{0}/", netCfg.GetString("http_listener_port")); + IssueWarning(); + } + else + { + _info["login"] = "http://127.0.0.1:9000/"; + IssueWarning(); + } + } + catch (Exception) + { + _log.DebugFormat("[GridInfoService] cannot get grid info from {0}, using minimal defaults", configPath); + } + } + _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); + } + + /// + /// Default constructor, uses OpenSim.ini. + /// + public GridInfoService() : this(Path.Combine(Util.configDir(), "OpenSim.ini")) + { + } + + private void IssueWarning() + { + _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); + _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); + foreach (string k in _info.Keys) + { + _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); + } + } + + public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + _log.Info("[GridInfo]: Request for grid info"); + + foreach (string k in _info.Keys) + { + responseData[k] = _info[k]; + } + response.Value = responseData; + + return response; + } + + public string RestGetGridInfoMethod(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StringBuilder sb = new StringBuilder(); + + sb.Append("\n"); + foreach (string k in _info.Keys) + { + sb.AppendFormat("<{0}>{1}\n", k, _info[k]); + } + sb.Append("\n"); + + return sb.ToString(); + } + } +} -- cgit v1.1 From 796ccd3d37cb132c4c4f12c791fcdf76513c5cf0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 17 Aug 2008 02:31:45 +0000 Subject: Update svn properties, minor formatting cleanup. --- .../Capabilities/LLSDRemoteParcelResponse.cs | 84 +++++++++++----------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs index 27adea0..1c8f27f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs @@ -1,42 +1,42 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using libsecondlife; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDRemoteParcelResponse - { - public LLUUID parcel_id; - - public LLSDRemoteParcelResponse() - { - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; + +namespace OpenSim.Framework.Communications.Capabilities +{ + [LLSDType("MAP")] + public class LLSDRemoteParcelResponse + { + public LLUUID parcel_id; + + public LLSDRemoteParcelResponse() + { + } + } +} -- cgit v1.1 From 6ef9d4da901a346c232458317cca6268da888e2e Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 18 Aug 2008 00:39:10 +0000 Subject: Formatting cleanup. --- .../Framework/Communications/Cache/AssetCache.cs | 14 ++++----- .../Communications/Cache/AssetServerBase.cs | 10 +++---- .../Communications/Cache/CachedUserInfo.cs | 6 ++-- .../Communications/Cache/GridAssetClient.cs | 2 +- .../Communications/Cache/InventoryFolderImpl.cs | 34 +++++++++++----------- .../Cache/UserProfileCacheService.cs | 2 +- .../Framework/Communications/Capabilities/Caps.cs | 4 +-- .../Capabilities/LLSDRemoteParcelResponse.cs | 2 +- .../Communications/CommunicationsManager.cs | 32 ++++++++++---------- OpenSim/Framework/Communications/IGridServices.cs | 6 ++-- .../IInterServiceInventoryServices.cs | 8 ++--- .../Framework/Communications/IInventoryServices.cs | 4 +-- .../Communications/ISecureInventoryService.cs | 8 ++--- .../Communications/InventoryServiceBase.cs | 6 ++-- OpenSim/Framework/Communications/LoginService.cs | 9 +++--- .../Framework/Communications/UserManagerBase.cs | 4 +-- 16 files changed, 75 insertions(+), 76 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 6eff690..e924b3f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -143,10 +143,10 @@ namespace OpenSim.Framework.Communications.Cache public void Clear() { m_log.Info("[ASSET CACHE]: Clearing Asset cache"); - + if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.ClearAssetCacheStatistics(); - + Initialize(); } @@ -365,9 +365,9 @@ namespace OpenSim.Framework.Communications.Cache } } else - { + { if (!Assets.ContainsKey(asset.FullID)) - { + { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); @@ -382,7 +382,7 @@ namespace OpenSim.Framework.Communications.Cache } } - /// + /// /// Allows you to clear a specific asset by uuid out /// of the asset cache. This is needed because the osdynamic /// texture code grows the asset cache without bounds. The @@ -399,8 +399,8 @@ namespace OpenSim.Framework.Communications.Cache if (Textures.ContainsKey(uuid)) { Textures.Remove(uuid); - } - else if (Assets.ContainsKey(uuid)) + } + else if (Assets.ContainsKey(uuid)) { Assets.Remove(uuid); } diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index ed5b896..2c8e685 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - /// Thrown if the request failed for some other reason than that the + /// Thrown if the request failed for some other reason than that the /// asset cannot be found. /// protected abstract AssetBase GetAsset(AssetRequest req); @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications.Cache protected virtual void ProcessRequest(AssetRequest req) { AssetBase asset; - + try { asset = GetAsset(req); @@ -78,12 +78,12 @@ namespace OpenSim.Framework.Communications.Cache catch (Exception e) { m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1}", req.AssetID, e); - + if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); - + m_receiver.AssetNotFound(req.AssetID, req.IsTexture); - + return; } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 57f5e76..c337907 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -91,8 +91,8 @@ namespace OpenSim.Framework.Communications.Cache get { return m_session_id; } set { m_session_id = value; } } - private LLUUID m_session_id = LLUUID.Zero; - + private LLUUID m_session_id = LLUUID.Zero; + /// /// Constructor /// @@ -172,7 +172,7 @@ namespace OpenSim.Framework.Communications.Cache } } } - + /// /// Drop all cached inventory. /// diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 4206cae..9cccf66 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache rc.AddQueryParameter("texture"); rc.RequestMethod = "GET"; - + Stream s = rc.Request(); if (s.Length > 0) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index d7de9d6..61cfc1a 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -37,19 +37,19 @@ namespace OpenSim.Framework.Communications.Cache public class InventoryFolderImpl : InventoryFolderBase { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + public static readonly string PATH_DELIMITER = "/"; /// /// Items that are contained in this folder /// public Dictionary Items = new Dictionary(); - + /// /// Child folders that are contained in this folder /// public Dictionary SubFolders = new Dictionary(); - + // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) { @@ -195,15 +195,15 @@ namespace OpenSim.Framework.Communications.Cache return null; } - + /// /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder - /// + /// /// This method does not handle paths that contain multiple delimitors - /// + /// /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some /// XPath like expression - /// + /// /// FIXME: Delimitors which occur in names themselves are not currently escapable. /// /// @@ -214,7 +214,7 @@ namespace OpenSim.Framework.Communications.Cache { if (path == string.Empty) return this; - + string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); lock (SubFolders) @@ -228,19 +228,19 @@ namespace OpenSim.Framework.Communications.Cache return folder; } } - + // We didn't find a folder with the given name return null; } - + /// /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. - /// + /// /// This method does not handle paths that contain multiple delimitors - /// + /// /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some /// XPath like expression - /// + /// /// FIXME: Delimitors which occur in names themselves are not currently escapable. /// /// @@ -248,7 +248,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// null if the item is not found public InventoryItemBase FindItemByPath(string path) - { + { string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); if (components.Length == 1) @@ -263,7 +263,7 @@ namespace OpenSim.Framework.Communications.Cache } } else - { + { lock (SubFolders) { foreach (InventoryFolderImpl folder in SubFolders.Values) @@ -273,10 +273,10 @@ namespace OpenSim.Framework.Communications.Cache } } } - + // We didn't find an item or intermediate folder with the given name return null; - } + } /// /// Return a copy of the list of child items in this folder diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 1360aa3..4e3840b 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications.Cache m_log.WarnFormat( "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); - + return false; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 1aa8eb0..24fe0f4 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -422,7 +422,7 @@ namespace OpenSim.Framework.Communications.Capabilities mapLayer.Right = 5000; mapLayer.Top = 5000; mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); - + return mapLayer; } @@ -783,7 +783,7 @@ namespace OpenSim.Framework.Communications.Capabilities // TODO: probably make this a better set of extensions here string extension = ".jp2"; - if (m_invType != "image") + if (m_invType != "image") { extension = ".dat"; } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs index 1c8f27f..b0e2b8f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs @@ -34,7 +34,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDRemoteParcelResponse { public LLUUID parcel_id; - + public LLSDRemoteParcelResponse() { } diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2bfe045..08dbc80 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -41,26 +41,26 @@ namespace OpenSim.Framework.Communications public class CommunicationsManager { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + protected Dictionary m_nameRequestCache = new Dictionary(); public IUserService UserService { get { return m_userService; } } - protected IUserService m_userService; + protected IUserService m_userService; public IGridServices GridService { get { return m_gridService; } } - protected IGridServices m_gridService; - + protected IGridServices m_gridService; + public IInterRegionCommunications InterRegion { get { return m_interRegion; } } - protected IInterRegionCommunications m_interRegion; + protected IInterRegionCommunications m_interRegion; public UserProfileCacheService UserProfileCacheService { @@ -68,36 +68,36 @@ namespace OpenSim.Framework.Communications } protected UserProfileCacheService m_userProfileCacheService; - // protected AgentAssetTransactionsManager m_transactionsManager; + // protected AgentAssetTransactionsManager m_transactionsManager; - // public AgentAssetTransactionsManager TransactionsManager - // { - // get { return m_transactionsManager; } - // } + // public AgentAssetTransactionsManager TransactionsManager + // { + // get { return m_transactionsManager; } + // } public IAvatarService AvatarService { get { return m_avatarService; } } - protected IAvatarService m_avatarService; + protected IAvatarService m_avatarService; public AssetCache AssetCache { get { return m_assetCache; } } - protected AssetCache m_assetCache; - + protected AssetCache m_assetCache; + public IInterServiceInventoryServices InterServiceInventoryService { get { return m_interServiceInventoryService; } - } + } protected IInterServiceInventoryServices m_interServiceInventoryService; public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } } - protected NetworkServersInfo m_networkServersInfo; + protected NetworkServersInfo m_networkServersInfo; /// /// Constructor @@ -138,7 +138,7 @@ namespace OpenSim.Framework.Communications return null; } } - + public IInventoryServices InventoryService { get diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 509f408..fcc0db5 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -33,7 +33,7 @@ namespace OpenSim.Framework.Communications public interface IGridServices { string gdebugRegionName { get; set; } - + /// /// Register a region with the grid service. /// @@ -41,7 +41,7 @@ namespace OpenSim.Framework.Communications /// /// Thrown if region registration failed RegionCommsListener RegisterRegion(RegionInfo regionInfos); - + bool DeregisterRegion(RegionInfo regionInfo); /// @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications /// /// List RequestNeighbours(uint x, uint y); - + RegionInfo RequestNeighbourInfo(ulong regionHandle); RegionInfo RequestNeighbourInfo(LLUUID regionID); RegionInfo RequestClosestRegion(string regionName); diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs index 24213f2..a1f4c2e 100644 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs @@ -32,22 +32,22 @@ namespace OpenSim.Framework.Communications { /// /// Inventory operations used between grid services. - /// + /// public interface IInterServiceInventoryServices - { + { /// /// Create a new inventory for the given user. /// /// /// true if the inventory was successfully created, false otherwise bool CreateNewUserInventory(LLUUID user); - + /// /// Returns a list of all the folders in a given user's inventory. /// /// /// A flat list of the user's inventory folder tree, /// null if there is no inventory for this user - List GetInventorySkeleton(LLUUID userId); + List GetInventorySkeleton(LLUUID userId); } } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 08a2c5f..b00b1bf 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -41,12 +41,12 @@ namespace OpenSim.Framework.Communications /// Defines all the operations one can perform on a user's inventory. /// public interface IInventoryServices - { + { string Host { get; } - + /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index 3608c56..bd962d1 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications { get; } - + /// /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the /// inventory has been received @@ -102,14 +102,14 @@ namespace OpenSim.Framework.Communications /// Does the given user have an inventory structure? /// /// - /// + /// bool HasInventoryForUser(LLUUID userID); - + /// /// Retrieve the root inventory folder for the given user. /// /// /// null if no root folder was found - InventoryFolderBase RequestRootFolder(LLUUID userID); + InventoryFolderBase RequestRootFolder(LLUUID userID); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 40701f0..c76c078 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -53,14 +53,14 @@ namespace OpenSim.Framework.Communications /// The filename to the user server plugin DLL public void AddPlugin(string provider, string connect) { - PluginLoader loader = + PluginLoader loader = new PluginLoader (new InventoryDataInitialiser (connect)); - // loader will try to load all providers (MySQL, MSSQL, etc) + // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); loader.Load(); - + m_plugins = loader.Plugins; } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index fd5f139..40064d3 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -79,7 +79,7 @@ namespace OpenSim.Framework.Communications /// The existing response /// The user profile public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); - + /// /// If the user is already logged in, try to notify the region that the user they've got is dead. /// @@ -206,12 +206,11 @@ namespace OpenSim.Framework.Communications userProfile.CurrentAgent.AgentOnline = false; m_userManager.CommitAgent(ref userProfile); - + // try to tell the region that their user is dead. LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); - + // Reject the login - m_log.InfoFormat( "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", @@ -293,7 +292,7 @@ namespace OpenSim.Framework.Communications //return logResponse.ToXmlRpcResponse(); } - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; CommitAgent(ref userProfile); // If we reach this point, then the login has successfully logged onto the grid diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f477df4..feeb666 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -57,11 +57,11 @@ namespace OpenSim.Framework.Communications PluginLoader loader = new PluginLoader (new UserDataInitialiser (connect)); - // loader will try to load all providers (MySQL, MSSQL, etc) + // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); loader.Load(); - + _plugins = loader.Plugins; } -- cgit v1.1 From 6d2e1ad6ba73fb0eba51b3885ff0a4d7d1b5d611 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 02:12:40 +0000 Subject: Attachment persistence!!! Patch #9169 (Mantis #1171) Attachments now save to MySQL. No reattach on login yet. --- OpenSim/Framework/Communications/IAvatarService.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 0e4a349..6c033e1 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -39,10 +39,5 @@ namespace OpenSim.Framework.Communications void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); - void AddAttachment(LLUUID user, LLUUID attach); - - void RemoveAttachment(LLUUID user, LLUUID attach); - - List GetAttachments(LLUUID user); } } -- cgit v1.1 From 29530f30296271f2d5641091e45d5f396a7d4dec Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 07:11:58 +0000 Subject: Attachment persistence!!! Patch #9170 (Mantis #1171) Attachments now persist across logouts. Mostly untested. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c337907..a7d6349 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -47,11 +47,15 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void SendInventoryDescendentsDelegate( IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); + public delegate void OnItemReceivedDelegate(LLUUID itemID); + /// /// Stores user profile and inventory data received from backend services for a particular user. /// public class CachedUserInfo { + public event OnItemReceivedDelegate OnItemReceived; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -306,6 +310,9 @@ namespace OpenSim.Framework.Communications.Cache { folder.Items[itemInfo.ID] = itemInfo; } + + if (OnItemReceived != null) + OnItemReceived(itemInfo.ID); } /// -- cgit v1.1 From 41440e184b1c12f1b83d894b2cd5b7b801b4ca38 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 18:34:46 +0000 Subject: Attachment persistence (Mantis #1711) Change user server to handle attachment assets record properly. Ensure that attachments are not re-rezzed on region crossing. Persistence will NOT WORK with earliser UGAI!! Change region server to match. --- OpenSim/Framework/Communications/LoginService.cs | 6 +++ .../Framework/Communications/UserManagerBase.cs | 53 +++------------------- 2 files changed, 13 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 40064d3..73fba1e 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -220,6 +220,9 @@ namespace OpenSim.Framework.Communications } // Otherwise... // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + CreateAgent(userProfile, request); try @@ -390,6 +393,9 @@ namespace OpenSim.Framework.Communications // Otherwise... // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + CreateAgent(userProfile, request); try diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index feeb666..ef900ea 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -83,6 +83,13 @@ namespace OpenSim.Framework.Communications return null; } + public void ResetAttachments(LLUUID userID) + { + foreach (IUserDataPlugin plugin in _plugins) + { + plugin.ResetAttachments(userID); + } + } public UserAgentData GetAgentByUUID(LLUUID userId) { foreach (IUserDataPlugin plugin in _plugins) @@ -639,51 +646,5 @@ namespace OpenSim.Framework.Communications } } } - - public void AddAttachment(LLUUID user, LLUUID item) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.AddAttachment(user, item); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); - } - } - } - - public void RemoveAttachment(LLUUID user, LLUUID item) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.RemoveAttachment(user, item); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); - } - } - } - - public List GetAttachments(LLUUID user) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - return plugin.GetAttachments(user); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); - } - } - return new List(); - } } } -- cgit v1.1 From d972d227889beb3b12b937be55fdecab9bdea2e7 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 22 Aug 2008 11:09:38 +0000 Subject: bug fixes: - GridInfoServices was not paying attention to location of ini file - typo in RemoteAdminPlugin --- .../Framework/Communications/GridInfoService.cs | 66 ++++++++++------------ 1 file changed, 31 insertions(+), 35 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index d51bc59..ad60638 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -55,59 +55,55 @@ namespace OpenSim.Framework.Communications /// anything else requires a general redesign of the config /// system. /// - public GridInfoService(string configPath) + public GridInfoService(IConfigSource configSource) { _info["platform"] = "OpenSim"; - if (File.Exists(configPath)) + try { - try + IConfig startupCfg = configSource.Configs["Startup"]; + IConfig gridCfg = configSource.Configs["GridInfo"]; + IConfig netCfg = configSource.Configs["Network"]; + + bool grid = startupCfg.GetBoolean("gridmode", false); + + if (grid) + _info["mode"] = "grid"; + else + _info["mode"] = "standalone"; + + + if (null != gridCfg) { - IConfigSource _configSource = new IniConfigSource(configPath); - IConfig startupCfg = _configSource.Configs["Startup"]; - IConfig gridCfg = _configSource.Configs["GridInfo"]; - IConfig netCfg = _configSource.Configs["Network"]; - - bool grid = startupCfg.GetBoolean("gridmode", false); - - if (grid) - _info["mode"] = "grid"; - else - _info["mode"] = "standalone"; - - - if (null != gridCfg) + foreach (string k in gridCfg.GetKeys()) { - foreach (string k in gridCfg.GetKeys()) - { - _info[k] = gridCfg.GetString(k); - } + _info[k] = gridCfg.GetString(k); } - else if (null != netCfg) - { - if (grid) - _info["login"] = netCfg.GetString("user_server_url"); + } + else if (null != netCfg) + { + if (grid) + _info["login"] = netCfg.GetString("user_server_url"); else _info["login"] = String.Format("http://127.0.0.1:{0}/", netCfg.GetString("http_listener_port")); - IssueWarning(); - } - else - { - _info["login"] = "http://127.0.0.1:9000/"; - IssueWarning(); - } + IssueWarning(); } - catch (Exception) + else { - _log.DebugFormat("[GridInfoService] cannot get grid info from {0}, using minimal defaults", configPath); + _info["login"] = "http://127.0.0.1:9000/"; + IssueWarning(); } } + catch (Exception) + { + _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); + } _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); } /// /// Default constructor, uses OpenSim.ini. /// - public GridInfoService() : this(Path.Combine(Util.configDir(), "OpenSim.ini")) + public GridInfoService() : this(new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini"))) { } -- cgit v1.1 From 5d6f92fb9697dc09d26bba236846809c737fc5c0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 23 Aug 2008 00:44:06 +0000 Subject: Patch #9171 Disallow bulk uploads if money module is present and upload cost is set and the user hasn't got sufficient funds. --- .../Framework/Communications/Capabilities/Caps.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 24fe0f4..338604d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -34,6 +34,9 @@ using libsecondlife; using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Framework.Communications.Capabilities { @@ -606,6 +609,29 @@ namespace OpenSim.Framework.Communications.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { + if (llsdRequest.asset_type == "texture" || + llsdRequest.asset_type == "animation" || + llsdRequest.asset_type == "sound") + { + IClientAPI client = GetClient(m_agentID); + Scene scene = (Scene)client.Scene; + + IMoneyModule mm = scene.RequestModuleInterface(); + + if(mm != null) + { + if(!mm.UploadCovered(client)) + { + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + } + //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; -- cgit v1.1 From ccd74f888bcb2fe60d14d45bfc9506a2c005aa82 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 23 Aug 2008 02:30:07 +0000 Subject: Some complex re-ordering to make prebuild do what needed to be done. It is now possible to use module interfaces without referencing Scene. Place those interfaces in OpenSim/Region/Interfaces. They may not use any refs from OpenSim.Region.Environment as parameters. This resolves a circular library ref introduced in r5949 --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 338604d..6946561 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -35,8 +35,7 @@ using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Interfaces; namespace OpenSim.Framework.Communications.Capabilities { @@ -614,7 +613,7 @@ namespace OpenSim.Framework.Communications.Capabilities llsdRequest.asset_type == "sound") { IClientAPI client = GetClient(m_agentID); - Scene scene = (Scene)client.Scene; + IScene scene = client.Scene; IMoneyModule mm = scene.RequestModuleInterface(); -- cgit v1.1 From d2d9808742c0ffe47fb7aa6464faf1b2dfb216bf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 23 Aug 2008 16:15:17 +0000 Subject: Thank you, salahzar, for a patch that adds llGetNumberOfSides and will also enable LSLconformance on some texture functions as well. Applied the part of the patch in Shared/. The part for Common/ needs to be reworked to remove the reference into Shared/ --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6946561..18ddd9e 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -631,7 +631,7 @@ namespace OpenSim.Framework.Communications.Capabilities } } - //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); + //System.Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; -- cgit v1.1 From 4c40a680fac28255fd51c4cef62d48caab8bd4db Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 23 Aug 2008 18:40:07 +0000 Subject: Mantis#2032. Thank you kindly, Tyre for a patch that: This small patch provides the required changes to populate the columns agentIP and agentPort in table "agents" Tested with mysql (but should work for all supported db engines) --- OpenSim/Framework/Communications/UserManagerBase.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index ef900ea..fd02382 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Net; using System.Reflection; using System.Security.Cryptography; using libsecondlife; @@ -362,6 +363,13 @@ namespace OpenSim.Framework.Communications // User connection agent.AgentOnline = true; + if (request.Params.Count > 1) + { + IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; + agent.AgentIP = RemoteIPEndPoint.Address.ToString(); + agent.AgentPort = (uint)RemoteIPEndPoint.Port; + } + // Generate sessions RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); byte[] randDataS = new byte[16]; -- cgit v1.1 From 2912aafe259727351eb9405532e45aa3501b7e9a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 25 Aug 2008 07:35:17 +0000 Subject: * This commit incorporates the heart of the OpenGridProtocol patch that is currently on Forge in a nice, friendly modular format. * There are a lot of changes and this is quite experimental. It's off by default, but you can turn it on by examining the bottom of the opensim.ini.example for the proper OpenSim.ini settings. Remember, you still need an agent domain.. * Furthermore, it isn't quite right when it comes to teleporting to remote regions (place_avatar) --- .../Cache/UserProfileCacheService.cs | 25 +++++++++++++++++ .../Capabilities/LLSDMethodString.cs | 31 ++++++++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 5 ++++ 3 files changed, 61 insertions(+) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 4e3840b..3b02c88 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -160,6 +160,31 @@ namespace OpenSim.Framework.Communications.Cache } /// + /// Preloads User data into the region cache. Modules may use this service to add non-standard clients + /// + /// + /// + public void PreloadUserCache(LLUUID userID, UserProfileData userData) + { + if (userID == LLUUID.Zero) + return; + + lock (m_userProfiles) + { + if (m_userProfiles.ContainsKey(userID)) + { + return; + } + else + { + + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData); + m_userProfiles.Add(userID, userInfo); + } + } + } + + /// /// Handle an inventory folder creation request from the client. /// /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs new file mode 100644 index 0000000..31325d8 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Framework.Communications.Capabilities +{ + public delegate TResponse LLSDMethodString(TRequest request, string path); +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index fd02382..a35ed72 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -339,6 +339,11 @@ namespace OpenSim.Framework.Communications public void ClearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); + + if (profile == null) + { + return; + } profile.CurrentAgent = null; UpdateUserProfile(profile); -- cgit v1.1 From 41f616627f4658df8157c340f0d74393a852e7e6 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 25 Aug 2008 14:40:10 +0000 Subject: Update svn properties. --- .../Capabilities/LLSDMethodString.cs | 62 +++++++++++----------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs index 31325d8..c68dd96 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs @@ -1,31 +1,31 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -namespace OpenSim.Framework.Communications.Capabilities -{ - public delegate TResponse LLSDMethodString(TRequest request, string path); -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Framework.Communications.Capabilities +{ + public delegate TResponse LLSDMethodString(TRequest request, string path); +} -- cgit v1.1 From 670719cb76cdf2b624ec84d631cc14f507e5840b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 27 Aug 2008 00:40:36 +0000 Subject: Mantis #1903 Thank you, cmickeyb, for a patch that prevents the loss of folders received out of sequence, and the items within. --- .../Communications/Cache/CachedUserInfo.cs | 31 +++++++++++++++------- .../Cache/UserProfileCacheService.cs | 8 +++++- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index a7d6349..17f927d 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -150,6 +150,7 @@ namespace OpenSim.Framework.Communications.Cache } } + /// /// Add any pending folders which were received before the given folder /// @@ -160,20 +161,24 @@ namespace OpenSim.Framework.Communications.Cache { if (pendingCategorizationFolders.ContainsKey(newFolder.ID)) { + List resolvedFolders = new List(); // Folders we've resolved with this invocation foreach (InventoryFolderImpl folder in pendingCategorizationFolders[newFolder.ID]) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", // folder.name, folder.folderID, parent.name, parent.folderID); - lock (newFolder.SubFolders) { if (!newFolder.SubFolders.ContainsKey(folder.ID)) { + resolvedFolders.Add(folder); newFolder.SubFolders.Add(folder.ID, folder); } } } + pendingCategorizationFolders.Remove(newFolder.ID); + foreach (InventoryFolderImpl folder in resolvedFolders) + ResolvePendingFolders(folder); } } @@ -201,13 +206,19 @@ namespace OpenSim.Framework.Communications.Cache { // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed + try { foreach (InventoryFolderImpl folder in folders) { FolderReceive(folder); } - + // Generate a warning for folders that are not part of the heirarchy + foreach ( KeyValuePair> folderList in pendingCategorizationFolders) + { + foreach (InventoryFolderImpl folder in folderList.Value) + m_log.WarnFormat("[INVENTORY CACHE]: Malformed Database: Unresolved Pending Folder {0}", folder.Name); + } foreach (InventoryItemBase item in items) { ItemReceive(item); @@ -258,7 +269,11 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl parentFolder = RootFolder.FindFolder(newFolder.ParentID); - if (parentFolder != null) + if (parentFolder == null) + { + AddPendingFolder(newFolder); + } + else { lock (parentFolder.SubFolders) { @@ -274,12 +289,7 @@ namespace OpenSim.Framework.Communications.Cache } } } - else - { - AddPendingFolder(newFolder); - } } - ResolvePendingFolders(newFolder); } @@ -295,7 +305,10 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat( // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); - InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); + InventoryFolderImpl folder = null; + + if ( RootFolder != null ) + folder = RootFolder.FindFolder(itemInfo.Folder); if (null == folder) { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 3b02c88..017cb29 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -440,7 +440,13 @@ namespace OpenSim.Framework.Communications.Cache { if (userProfile.HasReceivedInventory) { - InventoryItemBase item = userProfile.RootFolder.FindItem(itemID); + InventoryItemBase item = null; + if ( userProfile.RootFolder == null ) + m_log.ErrorFormat( + "[AGENT INVENTORY]: User {0} {1} does not have a root folder.", + remoteClient.Name, remoteClient.AgentId); + else + item = userProfile.RootFolder.FindItem(itemID); if (item != null) { remoteClient.SendInventoryItemDetails(ownerID, item); -- cgit v1.1 From 4a3523bc67d16e9f5e07c65ab8fba88f49423171 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 28 Aug 2008 07:37:16 +0000 Subject: this fixes the crash reported by mantis #2046: user server crashing if no OpenSim.ini file found by GridInfoService. GridInfoService now will just issue a warning that GridInfo will NOT be available to your users if no OpenSim.ini file is available. due to the static nature of UserConfig (configuration options hardcoded) i don't think it's currently an option to move GridInfo into user_server.xml but if anyone wants to look into this i'd be delighted... --- .../Framework/Communications/GridInfoService.cs | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index ad60638..ce66c82 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -57,6 +57,27 @@ namespace OpenSim.Framework.Communications /// public GridInfoService(IConfigSource configSource) { + loadGridInfo(configSource); + } + + /// + /// Default constructor, uses OpenSim.ini. + /// + public GridInfoService() + { + try + { + IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); + loadGridInfo(configSource); + } + catch (FileNotFoundException) + { + _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); + } + } + + private void loadGridInfo(IConfigSource configSource) + { _info["platform"] = "OpenSim"; try { @@ -98,13 +119,7 @@ namespace OpenSim.Framework.Communications _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); } _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); - } - /// - /// Default constructor, uses OpenSim.ini. - /// - public GridInfoService() : this(new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini"))) - { } private void IssueWarning() -- cgit v1.1 From 3bf88587277b83c0b6f058fabba7d46a3b5a6a00 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 28 Aug 2008 14:41:54 +0000 Subject: Update svn properties, formatting cleanup. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- .../Communications/Cache/UserProfileCacheService.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- OpenSim/Framework/Communications/GridInfoService.cs | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 17f927d..3a20b9e 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -306,7 +306,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); InventoryFolderImpl folder = null; - + if ( RootFolder != null ) folder = RootFolder.FindFolder(itemInfo.Folder); diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 017cb29..45f6c7e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -168,7 +168,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userID == LLUUID.Zero) return; - + lock (m_userProfiles) { if (m_userProfiles.ContainsKey(userID)) diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 18ddd9e..a7486d6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -617,9 +617,9 @@ namespace OpenSim.Framework.Communications.Capabilities IMoneyModule mm = scene.RequestModuleInterface(); - if(mm != null) + if (mm != null) { - if(!mm.UploadCovered(client)) + if (!mm.UploadCovered(client)) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index ce66c82..bd108c1 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications /// GridInfoService uses the [GridInfo] section of the /// standard OpenSim.ini file --- which is not optimal, but /// anything else requires a general redesign of the config - /// system. + /// system. /// public GridInfoService(IConfigSource configSource) { @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications /// public GridInfoService() { - try + try { IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); loadGridInfo(configSource); @@ -84,15 +84,15 @@ namespace OpenSim.Framework.Communications IConfig startupCfg = configSource.Configs["Startup"]; IConfig gridCfg = configSource.Configs["GridInfo"]; IConfig netCfg = configSource.Configs["Network"]; - + bool grid = startupCfg.GetBoolean("gridmode", false); - + if (grid) _info["mode"] = "grid"; - else + else _info["mode"] = "standalone"; - - + + if (null != gridCfg) { foreach (string k in gridCfg.GetKeys()) -- cgit v1.1 From 10b2a4597abb4b51ba3584daf3c837f6c5033ded Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 28 Aug 2008 20:56:53 +0000 Subject: Mantis #1903 Thank you, cmickeyb, for a patch that fixes inventory folder retrieval. --- .../Communications/Cache/CachedUserInfo.cs | 140 +++++++++------------ 1 file changed, 59 insertions(+), 81 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 3a20b9e..8e3be81 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -84,12 +84,6 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } private InventoryFolderImpl m_rootFolder; - /// - /// FIXME: This could be contained within a local variable - it doesn't need to be a field - /// - private IDictionary> pendingCategorizationFolders - = new Dictionary>(); - public LLUUID SessionID { get { return m_session_id; } @@ -130,55 +124,58 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Store a folder pending arrival of its parent + /// Helper function for InventoryReceive() - Store a folder temporarily until we've received entire folder list /// /// - private void AddPendingFolder(InventoryFolderImpl folder) + private void AddFolderToDictionary(InventoryFolderImpl folder, IDictionary> dictionary) { LLUUID parentFolderId = folder.ParentID; - if (pendingCategorizationFolders.ContainsKey(parentFolderId)) - { - pendingCategorizationFolders[parentFolderId].Add(folder); - } + if (dictionary.ContainsKey(parentFolderId)) + dictionary[parentFolderId].Add(folder); else { IList folders = new List(); folders.Add(folder); - - pendingCategorizationFolders[parentFolderId] = folders; + dictionary[parentFolderId] = folders; } } /// - /// Add any pending folders which were received before the given folder + /// Recursively, in depth-first order, add all the folders we've received (stored + /// in a dictionary indexed by parent ID) into the tree that describes user folder + /// heirarchy /// /// /// A /// - private void ResolvePendingFolders(InventoryFolderImpl newFolder) + private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, IDictionary> folderDictionary) { - if (pendingCategorizationFolders.ContainsKey(newFolder.ID)) + if (folderDictionary.ContainsKey(parentFolder.ID)) { List resolvedFolders = new List(); // Folders we've resolved with this invocation - foreach (InventoryFolderImpl folder in pendingCategorizationFolders[newFolder.ID]) + foreach (InventoryFolderImpl folder in folderDictionary[parentFolder.ID]) { - // m_log.DebugFormat( - // "[INVENTORY CACHE]: Resolving pending received folder {0} {1} into {2} {3}", - // folder.name, folder.folderID, parent.name, parent.folderID); - lock (newFolder.SubFolders) + lock (parentFolder.SubFolders) { - if (!newFolder.SubFolders.ContainsKey(folder.ID)) + if (parentFolder.SubFolders.ContainsKey(folder.ID)) + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", + folder.Name, folder.ID); + } + else { resolvedFolders.Add(folder); - newFolder.SubFolders.Add(folder.ID, folder); + parentFolder.SubFolders.Add(folder.ID, folder); } } - } - pendingCategorizationFolders.Remove(newFolder.ID); + } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) + + folderDictionary.Remove(parentFolder.ID); foreach (InventoryFolderImpl folder in resolvedFolders) - ResolvePendingFolders(folder); + ResolveReceivedFolders(folder, folderDictionary); } } @@ -204,25 +201,56 @@ namespace OpenSim.Framework.Communications.Cache /// public void InventoryReceive(ICollection folders, ICollection items) { + // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed try { + // collection of all received folders, indexed by their parent ID + IDictionary> receivedFolders = + new Dictionary>(); + + // Take all received folders, find the root folder, and put ther rest into + // the pendingCategorizationFolders collection foreach (InventoryFolderImpl folder in folders) + AddFolderToDictionary(folder, receivedFolders); + + if (!receivedFolders.ContainsKey(LLUUID.Zero)) + throw new Exception("Database did not return a root inventory folder"); + else { - FolderReceive(folder); + IList rootFolderList = receivedFolders[LLUUID.Zero]; + m_rootFolder = rootFolderList[0]; + if (rootFolderList.Count > 1) + { + for (int i = 1; i < rootFolderList.Count; i++) + { + m_log.WarnFormat( + "[INVENTORY CACHE]: Discarding extra root folder {0}. Using previously received root folder {1}", + rootFolderList[i].ID, RootFolder.ID); + } + } + receivedFolders.Remove(LLUUID.Zero); } + + // Now take the pendingCategorizationFolders collection, and turn that into a tree, + // with the root being RootFolder + if (RootFolder != null) + ResolveReceivedFolders(RootFolder, receivedFolders); + // Generate a warning for folders that are not part of the heirarchy - foreach ( KeyValuePair> folderList in pendingCategorizationFolders) + foreach (KeyValuePair> folderList in receivedFolders) { foreach (InventoryFolderImpl folder in folderList.Value) m_log.WarnFormat("[INVENTORY CACHE]: Malformed Database: Unresolved Pending Folder {0}", folder.Name); } + + // Take all ther received items and put them into the folder tree heirarchy + // TBD: This operation is O(n^2), if we made a dictionary of all folders indexed by their ID, we could make + // this O(n) foreach (InventoryItemBase item in items) - { ItemReceive(item); - } } catch (Exception e) { @@ -244,56 +272,6 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Callback invoked when a folder is received from an async request to the inventory service. - /// - /// - /// - private void FolderReceive(InventoryFolderImpl newFolder) - { - // m_log.DebugFormat( - // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", - // folderInfo.Name, folderInfo.ID, userID); - - if (RootFolder == null) - { - if (newFolder.ParentID == LLUUID.Zero) - { - m_rootFolder = newFolder; - } - else - { - AddPendingFolder(newFolder); - } - } - else - { - InventoryFolderImpl parentFolder = RootFolder.FindFolder(newFolder.ParentID); - - if (parentFolder == null) - { - AddPendingFolder(newFolder); - } - else - { - lock (parentFolder.SubFolders) - { - if (!parentFolder.SubFolders.ContainsKey(newFolder.ID)) - { - parentFolder.SubFolders.Add(newFolder.ID, newFolder); - } - else - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", - newFolder.Name, newFolder.ID); - } - } - } - } - ResolvePendingFolders(newFolder); - } - - /// /// Callback invoked when an item is received from an async request to the inventory service. /// /// We're assuming here that items are always received after all the folders -- cgit v1.1 From f57f4d1ab878eef5c75347a1f49690993cf98561 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 30 Aug 2008 04:42:23 +0000 Subject: * Added "File Asset Client" to OpenSim Asset Server-types. * You can replace "grid" as the asset system with "file" to save and load all your assets from a directory on your hard disk. Files are serialised to XML and saved in the format "//0x/0x/0x/0000-0000-000000-0000-0000.xml" * Directory is sharing the Asset Server URL path, use a normal path here instead (ie C:\xyz or /var/assets/). * This probably wont work well in grid mode unless every sim has access to the same directory. This is mostly intended for standalone usage where quick and convenient access to assets is required. --- .../Communications/Cache/FileAssetClient.cs | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 OpenSim/Framework/Communications/Cache/FileAssetClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs new file mode 100644 index 0000000..fcab349 --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -0,0 +1,56 @@ +using System.IO; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.Cache +{ + public class FileAssetClient : AssetServerBase + { + private readonly string m_dir; + private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); + + public FileAssetClient(string dir) + { + if(!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + m_dir = dir; + } + public override void StoreAsset(AssetBase asset) + { + string cdir = m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0] + + Path.DirectorySeparatorChar + asset.FullID.Data[1]; + + if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0])) + Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0]); + + if (!Directory.Exists(cdir)) + Directory.CreateDirectory(cdir); + + FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); + m_xs.Serialize(x, asset); + + x.Flush(); + x.Close(); + } + + public override void UpdateAsset(AssetBase asset) + { + StoreAsset(asset); + } + + protected override AssetBase GetAsset(AssetRequest req) + { + string cdir = m_dir + Path.DirectorySeparatorChar + req.AssetID.Data[0] + + Path.DirectorySeparatorChar + req.AssetID.Data[1]; + if (File.Exists(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml")) + { + FileStream x = File.OpenRead(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml"); + AssetBase ret = (AssetBase) m_xs.Deserialize(x); + x.Close(); + return ret; + } + return null; + } + } +} -- cgit v1.1 From 805deb5a9ba51307393dc5e11b100c86ee7c1b79 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 31 Aug 2008 10:42:35 +0000 Subject: Attempt to fix an issue I havebeen seeing, where asset server failure results in a memory leak which will make the region crash and burn after a while. --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 3 +++ OpenSim/Framework/Communications/RestClient.cs | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 9cccf66..1c947dc 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -63,6 +63,9 @@ namespace OpenSim.Framework.Communications.Cache Stream s = rc.Request(); + if (s == null) + return null; + if (s.Length > 0) { XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index b71a590..7d45186 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -286,7 +286,18 @@ namespace OpenSim.Framework.Communications _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse) _request.GetResponse(); + try + { + _response = (HttpWebResponse) _request.GetResponse(); + } + catch (System.Net.WebException e) + { + m_log.ErrorFormat("[ASSET] Error fetching asset from asset server"); + m_log.Debug(e.ToString()); + + return null; + } + Stream src = _response.GetResponseStream(); int length = src.Read(_readbuf, 0, BufferSize); while (length > 0) -- cgit v1.1 From 9053e8510c5e829c4e641cc51bab9387894b5e3b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 3 Sep 2008 14:05:49 +0000 Subject: Update svn properties. --- .../Communications/Cache/FileAssetClient.cs | 112 ++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index fcab349..3c74d4d 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -1,56 +1,56 @@ -using System.IO; -using System.Xml.Serialization; - -namespace OpenSim.Framework.Communications.Cache -{ - public class FileAssetClient : AssetServerBase - { - private readonly string m_dir; - private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); - - public FileAssetClient(string dir) - { - if(!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - m_dir = dir; - } - public override void StoreAsset(AssetBase asset) - { - string cdir = m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0] - + Path.DirectorySeparatorChar + asset.FullID.Data[1]; - - if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0])) - Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0]); - - if (!Directory.Exists(cdir)) - Directory.CreateDirectory(cdir); - - FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); - m_xs.Serialize(x, asset); - - x.Flush(); - x.Close(); - } - - public override void UpdateAsset(AssetBase asset) - { - StoreAsset(asset); - } - - protected override AssetBase GetAsset(AssetRequest req) - { - string cdir = m_dir + Path.DirectorySeparatorChar + req.AssetID.Data[0] - + Path.DirectorySeparatorChar + req.AssetID.Data[1]; - if (File.Exists(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml")) - { - FileStream x = File.OpenRead(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml"); - AssetBase ret = (AssetBase) m_xs.Deserialize(x); - x.Close(); - return ret; - } - return null; - } - } -} +using System.IO; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Communications.Cache +{ + public class FileAssetClient : AssetServerBase + { + private readonly string m_dir; + private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); + + public FileAssetClient(string dir) + { + if(!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + m_dir = dir; + } + public override void StoreAsset(AssetBase asset) + { + string cdir = m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0] + + Path.DirectorySeparatorChar + asset.FullID.Data[1]; + + if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0])) + Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0]); + + if (!Directory.Exists(cdir)) + Directory.CreateDirectory(cdir); + + FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); + m_xs.Serialize(x, asset); + + x.Flush(); + x.Close(); + } + + public override void UpdateAsset(AssetBase asset) + { + StoreAsset(asset); + } + + protected override AssetBase GetAsset(AssetRequest req) + { + string cdir = m_dir + Path.DirectorySeparatorChar + req.AssetID.Data[0] + + Path.DirectorySeparatorChar + req.AssetID.Data[1]; + if (File.Exists(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml")) + { + FileStream x = File.OpenRead(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml"); + AssetBase ret = (AssetBase) m_xs.Deserialize(x); + x.Close(); + return ret; + } + return null; + } + } +} -- cgit v1.1 From 7d89e122930be39e84a6d174548fa2d12ac0484a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 6 Sep 2008 07:52:41 +0000 Subject: * This is the fabled LibOMV update with all of the libOMV types from JHurliman * This is a HUGE OMG update and will definitely have unknown side effects.. so this is really only for the strong hearted at this point. Regular people should let the dust settle. * This has been tested to work with most basic functions. However.. make sure you back up 'everything' before using this. It's that big! * Essentially we're back at square 1 in the testing phase.. so lets identify things that broke. --- .../Framework/Communications/Cache/AssetCache.cs | 52 +++++++-------- .../Communications/Cache/AssetServerBase.cs | 4 +- .../Communications/Cache/CachedUserInfo.cs | 54 +++++++-------- .../Communications/Cache/FileAssetClient.cs | 16 +++-- .../Communications/Cache/InventoryFolderImpl.cs | 14 ++-- .../Communications/Cache/LibraryRootFolder.cs | 46 ++++++------- .../Cache/UserProfileCacheService.cs | 38 +++++------ .../Framework/Communications/Capabilities/Caps.cs | 76 +++++++++++----------- .../Framework/Communications/Capabilities/LLSD.cs | 24 +++---- .../Capabilities/LLSDAssetUploadComplete.cs | 6 +- .../Capabilities/LLSDAssetUploadRequest.cs | 6 +- .../Communications/Capabilities/LLSDHelpers.cs | 14 ++-- .../Capabilities/LLSDInventoryItem.cs | 26 ++++---- .../Communications/Capabilities/LLSDItemUpdate.cs | 6 +- .../Communications/Capabilities/LLSDMapLayer.cs | 6 +- .../Capabilities/LLSDRemoteParcelResponse.cs | 4 +- .../Capabilities/LLSDStreamHandler.cs | 6 +- .../LLSDTaskInventoryUploadComplete.cs | 8 +-- .../Capabilities/LLSDTaskScriptUpdate.cs | 8 +-- .../Communications/CommunicationsManager.cs | 34 +++++----- OpenSim/Framework/Communications/IAvatarService.cs | 6 +- OpenSim/Framework/Communications/IGridServices.cs | 4 +- .../Communications/IInterRegionCommunications.cs | 14 ++-- .../IInterServiceInventoryServices.cs | 6 +- .../Framework/Communications/IInventoryServices.cs | 8 +-- .../Communications/ISecureInventoryService.cs | 22 +++---- OpenSim/Framework/Communications/IUserService.cs | 40 ++++++------ .../Communications/InventoryServiceBase.cs | 58 ++++++++--------- OpenSim/Framework/Communications/LoginResponse.cs | 32 ++++----- OpenSim/Framework/Communications/LoginService.cs | 28 ++++---- .../Framework/Communications/UserManagerBase.cs | 68 +++++++++---------- 31 files changed, 369 insertions(+), 365 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e924b3f..3e88eba 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -29,14 +29,14 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Threading; -using libsecondlife; -using libsecondlife.Packets; +using OpenMetaverse; +using OpenMetaverse.Packets; using log4net; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications.Cache { - public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); + public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); /// /// Manages local cache of assets and their sending to viewers. @@ -58,17 +58,17 @@ namespace OpenSim.Framework.Communications.Cache /// /// The cache of assets. This does not include textures. /// - private Dictionary Assets; + private Dictionary Assets; /// /// The cache of textures. /// - private Dictionary Textures; + private Dictionary Textures; /// /// Assets requests which are waiting for asset server data. This includes texture requests /// - private Dictionary RequestedAssets; + private Dictionary RequestedAssets; /// /// Asset requests with data which are ready to be sent back to requesters. This includes textures. @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Until the asset request is fulfilled, each asset request is associated with a list of requesters /// - private Dictionary RequestLists; + private Dictionary RequestLists; private readonly IAssetServer m_assetServer; @@ -155,12 +155,12 @@ namespace OpenSim.Framework.Communications.Cache /// private void Initialize() { - Assets = new Dictionary(); - Textures = new Dictionary(); + Assets = new Dictionary(); + Textures = new Dictionary(); AssetRequests = new List(); - RequestedAssets = new Dictionary(); - RequestLists = new Dictionary(); + RequestedAssets = new Dictionary(); + RequestLists = new Dictionary(); } /// @@ -207,7 +207,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - //private AssetBase GetCachedAsset(LLUUID assetId) + //private AssetBase GetCachedAsset(UUID assetId) //{ // AssetBase asset = null; @@ -223,7 +223,7 @@ namespace OpenSim.Framework.Communications.Cache // return asset; //} - private bool TryGetCachedAsset(LLUUID assetId, out AssetBase asset) + private bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { if (Textures.ContainsKey(assetId)) { @@ -248,7 +248,7 @@ namespace OpenSim.Framework.Communications.Cache /// A callback invoked when the asset has either been found or not found. /// If the asset was found this is called with the asset UUID and the asset data /// If the asset was not found this is still called with the asset UUID but with a null asset data reference - public void GetAsset(LLUUID assetId, AssetRequestCallback callback, bool isTexture) + public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture) { //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); @@ -308,7 +308,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// null if the asset could not be retrieved - public AssetBase GetAsset(LLUUID assetID, bool isTexture) + public AssetBase GetAsset(UUID assetID, bool isTexture) { // I'm not going over 3 seconds since this will be blocking processing of all the other inbound // packets from the client. @@ -390,7 +390,7 @@ namespace OpenSim.Framework.Communications.Cache /// this is a stop gap measure until we have such a thing. /// - public void ExpireAsset(LLUUID uuid) + public void ExpireAsset(UUID uuid) { // uuid is unique, so no need to worry about it showing up // in the 2 caches differently. Also, locks are probably @@ -495,7 +495,7 @@ namespace OpenSim.Framework.Communications.Cache } // See IAssetReceiver - public void AssetNotFound(LLUUID assetID, bool IsTexture) + public void AssetNotFound(UUID assetID, bool IsTexture) { //m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); @@ -567,17 +567,17 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { - LLUUID requestID = null; + UUID requestID = null; byte source = 2; if (transferRequest.TransferInfo.SourceType == 2) { //direct asset request - requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); + requestID = new UUID(transferRequest.TransferInfo.Params, 0); } else if (transferRequest.TransferInfo.SourceType == 3) { //inventory asset request - requestID = new LLUUID(transferRequest.TransferInfo.Params, 80); + requestID = new UUID(transferRequest.TransferInfo.Params, 80); source = 3; //Console.WriteLine("asset request " + requestID); } @@ -678,10 +678,10 @@ namespace OpenSim.Framework.Communications.Cache public class AssetRequest { public IClientAPI RequestUser; - public LLUUID RequestAssetID; + public UUID RequestAssetID; public AssetInfo AssetInf; public TextureImage ImageInfo; - public LLUUID TransferRequestID; + public UUID TransferRequestID; public long DataPointer = 0; public int NumPackets = 0; public int PacketCounter = 0; @@ -731,10 +731,10 @@ namespace OpenSim.Framework.Communications.Cache public class AssetRequestsList { - public LLUUID AssetID; + public UUID AssetID; public List Requests = new List(); - public AssetRequestsList(LLUUID assetID) + public AssetRequestsList(UUID assetID) { AssetID = assetID; } @@ -742,10 +742,10 @@ namespace OpenSim.Framework.Communications.Cache public class NewAssetRequest { - public LLUUID AssetID; + public UUID AssetID; public AssetRequestCallback Callback; - public NewAssetRequest(LLUUID assetID, AssetRequestCallback callback) + public NewAssetRequest(UUID assetID, AssetRequestCallback callback) { AssetID = assetID; Callback = callback; diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 2c8e685..9f4f480 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -28,7 +28,7 @@ using System; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; using OpenSim.Framework.AssetLoader.Filesystem; using OpenSim.Framework.Statistics; @@ -146,7 +146,7 @@ namespace OpenSim.Framework.Communications.Cache m_receiver = receiver; } - public void RequestAsset(LLUUID assetID, bool isTexture) + public void RequestAsset(UUID assetID, bool isTexture) { AssetRequest req = new AssetRequest(); req.AssetID = assetID; diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 8e3be81..339bb31 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -30,24 +30,24 @@ using System.Collections.Generic; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; namespace OpenSim.Framework.Communications.Cache { internal delegate void AddItemDelegate(InventoryItemBase itemInfo); internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); - internal delegate void DeleteItemDelegate(LLUUID itemID); + internal delegate void DeleteItemDelegate(UUID itemID); - internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); - internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); - internal delegate void PurgeFolderDelegate(LLUUID folderID); - internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); + internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); + internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); + internal delegate void PurgeFolderDelegate(UUID folderID); + internal delegate void UpdateFolderDelegate(string name, UUID folderID, ushort type, UUID parentID); internal delegate void SendInventoryDescendentsDelegate( - IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); + IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); - public delegate void OnItemReceivedDelegate(LLUUID itemID); + public delegate void OnItemReceivedDelegate(UUID itemID); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -84,12 +84,12 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } private InventoryFolderImpl m_rootFolder; - public LLUUID SessionID + public UUID SessionID { get { return m_session_id; } set { m_session_id = value; } } - private LLUUID m_session_id = LLUUID.Zero; + private UUID m_session_id = UUID.Zero; /// /// Constructor @@ -127,9 +127,9 @@ namespace OpenSim.Framework.Communications.Cache /// Helper function for InventoryReceive() - Store a folder temporarily until we've received entire folder list /// /// - private void AddFolderToDictionary(InventoryFolderImpl folder, IDictionary> dictionary) + private void AddFolderToDictionary(InventoryFolderImpl folder, IDictionary> dictionary) { - LLUUID parentFolderId = folder.ParentID; + UUID parentFolderId = folder.ParentID; if (dictionary.ContainsKey(parentFolderId)) dictionary[parentFolderId].Add(folder); @@ -148,9 +148,9 @@ namespace OpenSim.Framework.Communications.Cache /// heirarchy /// /// - /// A + /// A /// - private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, IDictionary> folderDictionary) + private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, IDictionary> folderDictionary) { if (folderDictionary.ContainsKey(parentFolder.ID)) { @@ -208,19 +208,19 @@ namespace OpenSim.Framework.Communications.Cache try { // collection of all received folders, indexed by their parent ID - IDictionary> receivedFolders = - new Dictionary>(); + IDictionary> receivedFolders = + new Dictionary>(); // Take all received folders, find the root folder, and put ther rest into // the pendingCategorizationFolders collection foreach (InventoryFolderImpl folder in folders) AddFolderToDictionary(folder, receivedFolders); - if (!receivedFolders.ContainsKey(LLUUID.Zero)) + if (!receivedFolders.ContainsKey(UUID.Zero)) throw new Exception("Database did not return a root inventory folder"); else { - IList rootFolderList = receivedFolders[LLUUID.Zero]; + IList rootFolderList = receivedFolders[UUID.Zero]; m_rootFolder = rootFolderList[0]; if (rootFolderList.Count > 1) { @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Cache rootFolderList[i].ID, RootFolder.ID); } } - receivedFolders.Remove(LLUUID.Zero); + receivedFolders.Remove(UUID.Zero); } // Now take the pendingCategorizationFolders collection, and turn that into a tree, @@ -240,7 +240,7 @@ namespace OpenSim.Framework.Communications.Cache ResolveReceivedFolders(RootFolder, receivedFolders); // Generate a warning for folders that are not part of the heirarchy - foreach (KeyValuePair> folderList in receivedFolders) + foreach (KeyValuePair> folderList in receivedFolders) { foreach (InventoryFolderImpl folder in folderList.Value) m_log.WarnFormat("[INVENTORY CACHE]: Malformed Database: Unresolved Pending Folder {0}", folder.Name); @@ -314,7 +314,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID) + public bool CreateFolder(string folderName, UUID folderID, ushort folderType, UUID parentID) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); @@ -389,7 +389,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID) + public bool UpdateFolder(string name, UUID folderID, ushort type, UUID parentID) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); @@ -440,7 +440,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool MoveFolder(LLUUID folderID, LLUUID parentID) + public bool MoveFolder(UUID folderID, UUID parentID) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", @@ -487,7 +487,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool PurgeFolder(LLUUID folderID) + public bool PurgeFolder(UUID folderID) { // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", // folderID, remoteClient.Name, remoteClient.AgentId); @@ -542,7 +542,7 @@ namespace OpenSim.Framework.Communications.Cache { if (m_hasReceivedInventory) { - if (item.Folder == LLUUID.Zero) + if (item.Folder == UUID.Zero) { InventoryFolderImpl f = FindFolderForType(item.AssetType); if (f != null) @@ -607,7 +607,7 @@ namespace OpenSim.Framework.Communications.Cache /// true on a successful delete or a if the request is queued. /// Returns false on an immediate failure /// - public bool DeleteItem(LLUUID itemID) + public bool DeleteItem(UUID itemID) { if (m_hasReceivedInventory) { @@ -655,7 +655,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the request was queued or successfully processed, false otherwise - public bool SendInventoryDecendents(IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems) + public bool SendInventoryDecendents(IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems) { if (m_hasReceivedInventory) { diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index 3c74d4d..e793feb 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -18,11 +18,13 @@ namespace OpenSim.Framework.Communications.Cache } public override void StoreAsset(AssetBase asset) { - string cdir = m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0] - + Path.DirectorySeparatorChar + asset.FullID.Data[1]; + byte[] idBytes = asset.FullID.Guid.ToByteArray(); - if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0])) - Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + asset.FullID.Data[0]); + string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] + + Path.DirectorySeparatorChar + idBytes[1]; + + if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + idBytes[0])) + Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + idBytes[0]); if (!Directory.Exists(cdir)) Directory.CreateDirectory(cdir); @@ -41,8 +43,10 @@ namespace OpenSim.Framework.Communications.Cache protected override AssetBase GetAsset(AssetRequest req) { - string cdir = m_dir + Path.DirectorySeparatorChar + req.AssetID.Data[0] - + Path.DirectorySeparatorChar + req.AssetID.Data[1]; + byte[] idBytes = req.AssetID.Guid.ToByteArray(); + + string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] + + Path.DirectorySeparatorChar + idBytes[1]; if (File.Exists(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml")) { FileStream x = File.OpenRead(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml"); diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 61cfc1a..debcbfb 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -27,7 +27,7 @@ using System; using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; //using System.Reflection; //using log4net; @@ -43,12 +43,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Items that are contained in this folder /// - public Dictionary Items = new Dictionary(); + public Dictionary Items = new Dictionary(); /// /// Child folders that are contained in this folder /// - public Dictionary SubFolders = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// The newly created subfolder. Returns null if the folder already exists - public InventoryFolderImpl CreateChildFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) { lock (SubFolders) { @@ -112,7 +112,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// null if the item is not found - public InventoryItemBase FindItem(LLUUID itemID) + public InventoryItemBase FindItem(UUID itemID) { lock (Items) { @@ -143,7 +143,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public bool DeleteItem(LLUUID itemID) + public bool DeleteItem(UUID itemID) { bool found = false; @@ -177,7 +177,7 @@ namespace OpenSim.Framework.Communications.Cache /// first. /// /// The requested folder if it exists, null if it does not. - public InventoryFolderImpl FindFolder(LLUUID folderID) + public InventoryFolderImpl FindFolder(UUID folderID) { if (folderID == ID) return this; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 1ff6350..7e561b5 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Xml; -using libsecondlife; +using OpenMetaverse; using log4net; using Nini.Config; @@ -44,29 +44,29 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); /// /// Holds the root library folder and all its descendents. This is really only used during inventory /// setup so that we don't have to repeatedly search the tree of library folders. /// - protected Dictionary libraryFolders - = new Dictionary(); + protected Dictionary libraryFolders + = new Dictionary(); public LibraryRootFolder() { m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); Owner = libOwner; - ID = new LLUUID("00000112-000f-0000-0000-000100bba000"); + ID = new UUID("00000112-000f-0000-0000-000100bba000"); Name = "OpenSim Library"; - ParentID = LLUUID.Zero; + ParentID = UUID.Zero; Type = (short) 8; Version = (ushort) 1; libraryFolders.Add(ID, this); - LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); + LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.Xml")); // CreateLibraryItems(); } @@ -81,40 +81,40 @@ namespace OpenSim.Framework.Communications.Cache //private void CreateLibraryItems() //{ // InventoryItemBase item = - // CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), - // new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", + // CreateItem(new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"), + // new UUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); // item.inventoryCurrentPermissions = 0; // item.inventoryNextPermissions = 0; // Items.Add(item.inventoryID, item); // item = - // CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), - // new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", + // CreateItem(new UUID("77c41e39-38f9-f75a-024e-585989bfabc9"), + // new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); // item.inventoryCurrentPermissions = 0; // item.inventoryNextPermissions = 0; // Items.Add(item.inventoryID, item); // item = - // CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), - // new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", + // CreateItem(new UUID("77c41e39-38f9-f75a-0000-585989bf0000"), + // new UUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); // item.inventoryCurrentPermissions = 0; // item.inventoryNextPermissions = 0; // Items.Add(item.inventoryID, item); // item = - // CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), - // new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", + // CreateItem(new UUID("77c41e39-38f9-f75a-0000-5859892f1111"), + // new UUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); // item.inventoryCurrentPermissions = 0; // item.inventoryNextPermissions = 0; // Items.Add(item.inventoryID, item); //} - public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, - int assetType, int invType, LLUUID parentFolderID) + public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, + int assetType, int invType, UUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; @@ -173,9 +173,9 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - folderInfo.ID = new LLUUID(config.GetString("folderID", ID.ToString())); + folderInfo.ID = new UUID(config.GetString("folderID", ID.ToString())); folderInfo.Name = config.GetString("name", "unknown"); - folderInfo.ParentID = new LLUUID(config.GetString("parentFolderID", ID.ToString())); + folderInfo.ParentID = new UUID(config.GetString("parentFolderID", ID.ToString())); folderInfo.Type = (short)config.GetInt("type", 8); folderInfo.Owner = libOwner; @@ -207,9 +207,9 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; item.Creator = libOwner; - item.ID = new LLUUID(config.GetString("inventoryID", ID.ToString())); - item.AssetID = new LLUUID(config.GetString("assetID", item.ID.ToString())); - item.Folder = new LLUUID(config.GetString("folderID", ID.ToString())); + item.ID = new UUID(config.GetString("inventoryID", ID.ToString())); + item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); + item.Folder = new UUID(config.GetString("folderID", ID.ToString())); item.Name = config.GetString("name", String.Empty); item.Description = config.GetString("description", item.Name); item.InvType = config.GetInt("inventoryType", 0); @@ -270,7 +270,7 @@ namespace OpenSim.Framework.Communications.Cache /// methods in the superclass /// /// - public Dictionary RequestSelfAndDescendentFolders() + public Dictionary RequestSelfAndDescendentFolders() { return libraryFolders; } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 45f6c7e..3675053 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -29,7 +29,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; namespace OpenSim.Framework.Communications.Cache @@ -49,7 +49,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Each user has a cached profile. /// - private readonly Dictionary m_userProfiles = new Dictionary(); + private readonly Dictionary m_userProfiles = new Dictionary(); public readonly LibraryRootFolder libraryRoot = new LibraryRootFolder(); @@ -63,9 +63,9 @@ namespace OpenSim.Framework.Communications.Cache /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// /// - public void AddNewUser(LLUUID userID) + public void AddNewUser(UUID userID) { - if (userID == LLUUID.Zero) + if (userID == UUID.Zero) return; m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); GetUserDetails(userID); @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the user was successfully removed, false otherwise - public bool RemoveUser(LLUUID userId) + public bool RemoveUser(UUID userId) { lock (m_userProfiles) { @@ -99,7 +99,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void RequestInventoryForUser(LLUUID userID) + public void RequestInventoryForUser(UUID userID) { CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) @@ -130,9 +130,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// null if no user details are found - public CachedUserInfo GetUserDetails(LLUUID userID) + public CachedUserInfo GetUserDetails(UUID userID) { - if (userID == LLUUID.Zero) + if (userID == UUID.Zero) return null; lock (m_userProfiles) @@ -164,9 +164,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void PreloadUserCache(LLUUID userID, UserProfileData userData) + public void PreloadUserCache(UUID userID, UserProfileData userData) { - if (userID == LLUUID.Zero) + if (userID == UUID.Zero) return; lock (m_userProfiles) @@ -192,8 +192,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, - string folderName, LLUUID parentID) + public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, + string folderName, UUID parentID) { CachedUserInfo userProfile; @@ -226,8 +226,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, - LLUUID parentID) + public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name, + UUID parentID) { // m_log.DebugFormat( // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); @@ -257,7 +257,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) + public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) { CachedUserInfo userProfile; @@ -287,7 +287,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, + public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // FIXME MAYBE: We're not handling sortOrder! @@ -327,7 +327,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// null if the inventory look up failed - public List HandleFetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, + public List HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // m_log.DebugFormat( @@ -405,7 +405,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) + public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) { CachedUserInfo userProfile; @@ -426,7 +426,7 @@ namespace OpenSim.Framework.Communications.Cache } } - public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID) + public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) { if (ownerID == libraryRoot.Owner) { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a7486d6..e82a5e9 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -30,7 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; @@ -40,21 +40,21 @@ using OpenSim.Region.Interfaces; namespace OpenSim.Framework.Communications.Capabilities { public delegate void UpLoadedAsset( - string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, + string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType); - public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); + public delegate UUID UpdateItem(UUID itemID, byte[] data); - public delegate void UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); + public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data); - public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); + public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); - public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); + public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); - public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, + public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, bool isScriptRunning, byte[] data); - public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, + public delegate List FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); /// @@ -62,7 +62,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want /// to just pass the whole Scene into CAPS. /// - public delegate IClientAPI GetClientDelegate(LLUUID agentID); + public delegate IClientAPI GetClientDelegate(UUID agentID); public class Caps { @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Capabilities //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; - private LLUUID m_agentID; + private UUID m_agentID; private AssetCache m_assetCache; private int m_eventQueueCount = 1; private Queue m_capsEventQueue = new Queue(); @@ -113,7 +113,7 @@ namespace OpenSim.Framework.Communications.Capabilities public GetClientDelegate GetClient = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, - LLUUID agent, bool dumpAssetsToFile, string regionName) + UUID agent, bool dumpAssetsToFile, string regionName) { m_assetCache = assetCache; m_capsObjectPath = capsPath; @@ -258,7 +258,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable hash = new Hashtable(); try { - hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); } catch (LLSD.LLSDParseException pe) { @@ -388,7 +388,7 @@ namespace OpenSim.Framework.Communications.Capabilities llsdItem.permissions.creator_id = invItem.Creator; llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; - llsdItem.permissions.group_id = LLUUID.Zero; + llsdItem.permissions.group_id = UUID.Zero; llsdItem.permissions.group_mask = 0; llsdItem.permissions.is_owner_group = false; llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; @@ -423,7 +423,7 @@ namespace OpenSim.Framework.Communications.Capabilities LLSDMapLayer mapLayer = new LLSDMapLayer(); mapLayer.Right = 5000; mapLayer.Top = 5000; - mapLayer.ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); + mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); return mapLayer; } @@ -522,7 +522,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName); //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); @@ -573,8 +573,8 @@ namespace OpenSim.Framework.Communications.Capabilities OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); - //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); + //OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -636,9 +636,9 @@ namespace OpenSim.Framework.Communications.Capabilities string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; - LLUUID newAsset = LLUUID.Random(); - LLUUID newInvItem = LLUUID.Random(); - LLUUID parentFolder = llsdRequest.folder_id; + UUID newAsset = UUID.Random(); + UUID newInvItem = UUID.Random(); + UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = @@ -662,8 +662,8 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, - LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, + public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType) { sbyte assType = 0; @@ -728,14 +728,14 @@ namespace OpenSim.Framework.Communications.Capabilities /// Item to update /// New asset data /// - public LLUUID ItemUpdated(LLUUID itemID, byte[] data) + public UUID ItemUpdated(UUID itemID, byte[] data) { if (ItemUpdatedCall != null) { return ItemUpdatedCall(m_agentID, itemID, data); } - return LLUUID.Zero; + return UUID.Zero; } /// @@ -745,7 +745,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// Prim containing item to update /// Signals whether the script to update is currently running /// New asset data - public void TaskScriptUpdated(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data) + public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data) { if (TaskScriptUpdatedCall != null) { @@ -759,9 +759,9 @@ namespace OpenSim.Framework.Communications.Capabilities private UpLoadedAsset handlerUpLoad = null; private string uploaderPath = String.Empty; - private LLUUID newAssetID; - private LLUUID inventoryItemID; - private LLUUID parentFolder; + private UUID newAssetID; + private UUID inventoryItemID; + private UUID parentFolder; private BaseHttpServer httpListener; private bool m_dumpAssetsToFile; private string m_assetName = String.Empty; @@ -770,8 +770,8 @@ namespace OpenSim.Framework.Communications.Capabilities private string m_invType = String.Empty; private string m_assetType = String.Empty; - public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, - LLUUID parentFolderID, string invType, string assetType, string path, + public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, + UUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile) { m_assetName = assetName; @@ -795,7 +795,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = inventoryItemID; + UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); @@ -860,11 +860,11 @@ namespace OpenSim.Framework.Communications.Capabilities private UpdateItem handlerUpdateItem = null; private string uploaderPath = String.Empty; - private LLUUID inventoryItemID; + private UUID inventoryItemID; private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public ItemUpdater(LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) + public ItemUpdater(UUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; @@ -882,10 +882,10 @@ namespace OpenSim.Framework.Communications.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = inventoryItemID; + UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); - LLUUID assetID = LLUUID.Zero; + UUID assetID = UUID.Zero; handlerUpdateItem = OnUpLoad; if (handlerUpdateItem != null) { @@ -942,13 +942,13 @@ namespace OpenSim.Framework.Communications.Capabilities private UpdateTaskScript handlerUpdateTaskScript = null; private string uploaderPath = String.Empty; - private LLUUID inventoryItemID; - private LLUUID primID; + private UUID inventoryItemID; + private UUID primID; private bool isScriptRunning; private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, + public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index aa9951c..44c4a05 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -32,7 +32,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; using System.Xml; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -158,9 +158,9 @@ namespace OpenSim.Framework.Communications.Capabilities { throw new Exception("ulong in LLSD is currently not implemented, fix me!"); } - else if (obj is LLUUID) + else if (obj is UUID) { - LLUUID u = (LLUUID) obj; + UUID u = (UUID) obj; writer.WriteStartElement(String.Empty, "uuid", String.Empty); writer.WriteString(u.ToString()); writer.WriteEndElement(); @@ -294,11 +294,11 @@ namespace OpenSim.Framework.Communications.Capabilities if (reader.IsEmptyElement) { reader.Read(); - return LLUUID.Zero; + return UUID.Zero; } reader.Read(); - ret = new LLUUID(reader.ReadString().Trim()); + ret = new UUID(reader.ReadString().Trim()); break; } case "string": @@ -476,9 +476,9 @@ namespace OpenSim.Framework.Communications.Capabilities { return GetSpaces(indent) + "- float " + obj.ToString() + "\n"; } - else if (obj is LLUUID) + else if (obj is UUID) { - return GetSpaces(indent) + "- uuid " + ((LLUUID) obj).ToString() + Environment.NewLine; + return GetSpaces(indent) + "- uuid " + ((UUID) obj).ToString() + Environment.NewLine; } else if (obj is Hashtable) { @@ -509,7 +509,7 @@ namespace OpenSim.Framework.Communications.Capabilities } else if (obj is byte[]) { - return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[]) obj, GetSpaces(indent)) + + return GetSpaces(indent) + "- binary\n" + Utils.BytesToHexString((byte[]) obj, GetSpaces(indent)) + Environment.NewLine; } else @@ -568,14 +568,14 @@ namespace OpenSim.Framework.Communications.Capabilities } case 'u': { - if (llsd.Length < 17) throw new LLSDParseException("LLUUID value type with no value"); - LLUUID value; + if (llsd.Length < 17) throw new LLSDParseException("UUID value type with no value"); + UUID value; endPos = FindEnd(llsd, 1); - if (LLUUID.TryParse(llsd.Substring(1, endPos - 1), out value)) + if (UUID.TryParse(llsd.Substring(1, endPos - 1), out value)) return value; else - throw new LLSDParseException("Failed to parse LLUUID value type"); + throw new LLSDParseException("Failed to parse UUID value type"); } case 'b': //byte[] value = new byte[llsd.Length - 1]; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 6c4db4b..680dcc8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -26,7 +26,7 @@ */ using System; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -34,7 +34,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDAssetUploadComplete { public string new_asset = String.Empty; - public LLUUID new_inventory_item = LLUUID.Zero; + public UUID new_inventory_item = UUID.Zero; public string state = String.Empty; //public bool success = false; @@ -42,4 +42,4 @@ namespace OpenSim.Framework.Communications.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 289cc93..5833b65 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -26,7 +26,7 @@ */ using System; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -35,7 +35,7 @@ namespace OpenSim.Framework.Communications.Capabilities { public string asset_type = String.Empty; public string description = String.Empty; - public LLUUID folder_id = LLUUID.Zero; + public UUID folder_id = UUID.Zero; public string inventory_type = String.Empty; public string name = String.Empty; @@ -43,4 +43,4 @@ namespace OpenSim.Framework.Communications.Capabilities { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 507f12b..b14bfdd 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -86,8 +86,8 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteString(fieldName); writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); - // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - // writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); + // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( + // writer, OpenMetaverse.StructuredData.LLSD.FromObject(fieldValue)); } } writer.WriteEndElement(); @@ -111,8 +111,8 @@ namespace OpenSim.Framework.Communications.Capabilities else { LLSD.LLSDWriteOne(writer, obj); - //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); + //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( + // writer, OpenMetaverse.StructuredData.LLSD.FromObject(obj)); } } @@ -133,12 +133,12 @@ namespace OpenSim.Framework.Communications.Capabilities FieldInfo field = myType.GetField(keyName); if (field != null) { - // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) + // if (enumerator.Value is OpenMetaverse.StructuredData.LLSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); - // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); + // DeserialiseLLSDMap((OpenMetaverse.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { @@ -160,4 +160,4 @@ namespace OpenSim.Framework.Communications.Capabilities return obj; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 1a75aba..ff36821 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -25,17 +25,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDInventoryItem { - public LLUUID parent_id; + public UUID parent_id; - public LLUUID asset_id; - public LLUUID item_id; + public UUID asset_id; + public UUID item_id; public LLSDPermissions permissions; public string type; public string inv_type; @@ -50,9 +50,9 @@ namespace OpenSim.Framework.Communications.Capabilities [LLSDMap] public class LLSDPermissions { - public LLUUID creator_id; - public LLUUID owner_id; - public LLUUID group_id; + public UUID creator_id; + public UUID owner_id; + public UUID group_id; public int base_mask; public int owner_mask; public int group_mask; @@ -77,8 +77,8 @@ namespace OpenSim.Framework.Communications.Capabilities [LLSDMap] public class LLSDFetchInventoryDescendents { - public LLUUID folder_id; - public LLUUID owner_id; + public UUID folder_id; + public UUID owner_id; public int sort_order; public bool fetch_folders; public bool fetch_items; @@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications.Capabilities [LLSDMap] public class LLSDInventoryFolderContents { - public LLUUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" + public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" public int descendents; - public LLUUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names + public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names public LLSDArray items = new LLSDArray(); - public LLUUID owner___id; // and of course we can't have field names with "-" in + public UUID owner___id; // and of course we can't have field names with "-" in public int version; } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 2c4b68f..c147bd3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -25,17 +25,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDMap] public class LLSDItemUpdate { - public LLUUID item_id; + public UUID item_id; public LLSDItemUpdate() { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 50f5241..fc381e4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -36,10 +36,10 @@ namespace OpenSim.Framework.Communications.Capabilities public int Right = 0; public int Top = 0; public int Bottom = 0; - public LLUUID ImageID = LLUUID.Zero; + public UUID ImageID = UUID.Zero; public LLSDMapLayer() { } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs index b0e2b8f..1220089 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs @@ -26,14 +26,14 @@ * */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] public class LLSDRemoteParcelResponse { - public LLUUID parcel_id; + public UUID parcel_id; public LLSDRemoteParcelResponse() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 36090e1..7fcbb81 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -53,8 +53,8 @@ namespace OpenSim.Framework.Communications.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) - // libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); + // OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap) + // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); @@ -67,4 +67,4 @@ namespace OpenSim.Framework.Communications.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 8bfd20c..b34cbf9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -35,16 +35,16 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// The task inventory item that was updated /// - public LLUUID item_id; + public UUID item_id; /// /// The task that was updated /// - public LLUUID task_id; + public UUID task_id; /// /// State of the upload. So far have only even seen this set to "complete" /// public string state; } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index e45d9de..730e95b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { @@ -35,16 +35,16 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// The item containing the script to update /// - public LLUUID item_id; + public UUID item_id; /// /// The task containing the script /// - public LLUUID task_id; + public UUID task_id; /// /// Signals whether the script is currently active /// public int is_script_running; } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 08dbc80..e6413e8 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,7 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; -using libsecondlife; +using OpenMetaverse; using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Dictionary m_nameRequestCache = new Dictionary(); + protected Dictionary m_nameRequestCache = new Dictionary(); public IUserService UserService { @@ -238,8 +238,8 @@ namespace OpenSim.Framework.Communications /// /// /// - /// The UUID of the added user. Returns LLUUID.Zero if the add was unsuccessful - public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) + /// The UUID of the added user. Returns UUID.Zero if the add was unsuccessful + public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); @@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); if (userProf == null) { - return LLUUID.Zero; + return UUID.Zero; } else { @@ -265,7 +265,7 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being added to /// The agent that being added to the friends list of the friends list owner /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { m_userService.AddNewUserFriend(friendlistowner, friend, perms); } @@ -279,7 +279,7 @@ namespace OpenSim.Framework.Communications /// /// /// - public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); @@ -290,7 +290,7 @@ namespace OpenSim.Framework.Communications /// /// The agent that who's friends list is being updated /// The Ex-friend agent - public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + public void RemoveUserFriend(UUID friendlistowner, UUID friend) { m_userService.RemoveUserFriend(friendlistowner, friend); } @@ -301,16 +301,16 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being updated /// The agent that is getting or loosing permissions /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); } /// - /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner /// /// The agent that we're retreiving the friends Data. - public List GetUserFriendList(LLUUID friendlistowner) + public List GetUserFriendList(UUID friendlistowner) { return m_userService.GetUserFriendList(friendlistowner); } @@ -325,7 +325,7 @@ namespace OpenSim.Framework.Communications return; } - public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) + public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) { if (uuid == m_userProfileCacheService.libraryRoot.Owner) { @@ -342,7 +342,7 @@ namespace OpenSim.Framework.Communications } } - private string[] doUUIDNameRequest(LLUUID uuid) + private string[] doUUIDNameRequest(UUID uuid) { string[] returnstring = new string[0]; bool doLookup = false; @@ -366,7 +366,7 @@ namespace OpenSim.Framework.Communications if (profileData != null) { returnstring = new string[2]; - // LLUUID profileId = profileData.ID; + // UUID profileId = profileData.ID; returnstring[0] = profileData.FirstName; returnstring[1] = profileData.SurName; lock (m_nameRequestCache) @@ -380,13 +380,13 @@ namespace OpenSim.Framework.Communications } - public bool UUIDNameCachedTest(LLUUID uuid) + public bool UUIDNameCachedTest(UUID uuid) { lock (m_nameRequestCache) return m_nameRequestCache.ContainsKey(uuid); } - public string UUIDNameRequestString(LLUUID uuid) + public string UUIDNameRequestString(UUID uuid) { string[] names = doUUIDNameRequest(uuid); if (names.Length == 2) @@ -400,7 +400,7 @@ namespace OpenSim.Framework.Communications return "(hippos)"; } - public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + public List GenerateAgentPickerRequestResponse(UUID queryID, string query) { List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); return pickerlist; diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 6c033e1..25b26dd 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -28,16 +28,16 @@ using System; using System.Collections.Generic; using System.Text; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications { public interface IAvatarService { /// Get's the User Appearance - AvatarAppearance GetUserAppearance(LLUUID user); + AvatarAppearance GetUserAppearance(UUID user); - void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + void UpdateUserAppearance(UUID user, AvatarAppearance appearance); } } diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index fcc0db5..6c5d2e2 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -26,7 +26,7 @@ */ using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications { @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); - RegionInfo RequestNeighbourInfo(LLUUID regionID); + RegionInfo RequestNeighbourInfo(UUID regionID); RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 57fb82d..3dd5561 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications { @@ -35,16 +35,16 @@ namespace OpenSim.Framework.Communications bool CheckRegion(string address, uint port); bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData, int XMLMethod); + bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod); bool RegionUp(SerializableRegionInfo region, ulong regionhandle); bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); - bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); - bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isFlying); + bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying); + bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying); - bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId); - bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID); + bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId); + bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID); - bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); + bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); } } diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs index a1f4c2e..5900f4e 100644 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs @@ -26,7 +26,7 @@ */ using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications { @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications /// /// /// true if the inventory was successfully created, false otherwise - bool CreateNewUserInventory(LLUUID user); + bool CreateNewUserInventory(UUID user); /// /// Returns a list of all the folders in a given user's inventory. @@ -48,6 +48,6 @@ namespace OpenSim.Framework.Communications /// /// A flat list of the user's inventory folder tree, /// null if there is no inventory for this user - List GetInventorySkeleton(LLUUID userId); + List GetInventorySkeleton(UUID userId); } } diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index b00b1bf..aead3be 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -26,7 +26,7 @@ */ using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications /// /// /// - void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); + void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback); /// /// Add a new folder to the user's inventory @@ -109,13 +109,13 @@ namespace OpenSim.Framework.Communications /// /// /// - bool HasInventoryForUser(LLUUID userID); + bool HasInventoryForUser(UUID userID); /// /// Retrieve the root inventory folder for the given user. /// /// /// null if no root folder was found - InventoryFolderBase RequestRootFolder(LLUUID userID); + InventoryFolderBase RequestRootFolder(UUID userID); } } diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index bd962d1..6d4ce46 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -26,7 +26,7 @@ */ using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications @@ -47,69 +47,69 @@ namespace OpenSim.Framework.Communications /// /// /// - void RequestInventoryForUser(LLUUID userID, LLUUID session_id, InventoryReceiptCallback callback); + void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback); /// /// Add a new folder to the user's inventory /// /// /// true if the folder was successfully added - bool AddFolder(InventoryFolderBase folder, LLUUID session_id); + bool AddFolder(InventoryFolderBase folder, UUID session_id); /// /// Update a folder in the user's inventory /// /// /// true if the folder was successfully updated - bool UpdateFolder(InventoryFolderBase folder, LLUUID session_id); + bool UpdateFolder(InventoryFolderBase folder, UUID session_id); /// /// Move an inventory folder to a new location /// /// A folder containing the details of the new location /// true if the folder was successfully moved - bool MoveFolder(InventoryFolderBase folder, LLUUID session_id); + bool MoveFolder(InventoryFolderBase folder, UUID session_id); /// /// Purge an inventory folder of all its items and subfolders. /// /// /// true if the folder was successfully purged - bool PurgeFolder(InventoryFolderBase folder, LLUUID session_id); + bool PurgeFolder(InventoryFolderBase folder, UUID session_id); /// /// Add a new item to the user's inventory /// /// /// true if the item was successfully added - bool AddItem(InventoryItemBase item, LLUUID session_id); + bool AddItem(InventoryItemBase item, UUID session_id); /// /// Update an item in the user's inventory /// /// /// true if the item was successfully updated - bool UpdateItem(InventoryItemBase item, LLUUID session_id); + bool UpdateItem(InventoryItemBase item, UUID session_id); /// /// Delete an item from the user's inventory /// /// /// true if the item was successfully deleted - bool DeleteItem(InventoryItemBase item, LLUUID session_id); + bool DeleteItem(InventoryItemBase item, UUID session_id); /// /// Does the given user have an inventory structure? /// /// /// - bool HasInventoryForUser(LLUUID userID); + bool HasInventoryForUser(UUID userID); /// /// Retrieve the root inventory folder for the given user. /// /// /// null if no root folder was found - InventoryFolderBase RequestRootFolder(LLUUID userID); + InventoryFolderBase RequestRootFolder(UUID userID); } } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index c1ae0e2..07ea437 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -26,7 +26,7 @@ */ using System.Collections.Generic; -using libsecondlife; +using OpenMetaverse; namespace OpenSim.Framework.Communications { @@ -47,22 +47,22 @@ namespace OpenSim.Framework.Communications /// /// The target UUID /// A user profile. Returns null if no user profile is found. - UserProfileData GetUserProfile(LLUUID userId); + UserProfileData GetUserProfile(UUID userId); - UserAgentData GetAgentByUUID(LLUUID userId); + UserAgentData GetAgentByUUID(UUID userId); - void ClearUserAgent(LLUUID avatarID); - List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); + void ClearUserAgent(UUID avatarID); + List GenerateAgentPickerRequestResponse(UUID QueryID, string Query); UserProfileData SetupMasterUser(string firstName, string lastName); UserProfileData SetupMasterUser(string firstName, string lastName, string password); - UserProfileData SetupMasterUser(LLUUID userId); + UserProfileData SetupMasterUser(UUID userId); /// /// /// /// - LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); /// /// Update the user's profile. @@ -78,14 +78,14 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being added to /// The agent that being added to the friends list of the friends list owner /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms); + void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms); /// /// Delete friend on friendlistowner's friendlist. /// /// The agent that who's friends list is being updated /// The Ex-friend agent - void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend); + void RemoveUserFriend(UUID friendlistowner, UUID friend); /// /// Update permissions for friend on friendlistowner's friendlist. @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being updated /// The agent that is getting or loosing permissions /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); + void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); /// /// Updates a user profile @@ -110,31 +110,31 @@ namespace OpenSim.Framework.Communications /// final position x /// final position y /// final position z - void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz); + void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz); /// - /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner /// /// The agent that we're retreiving the friends Data. - List GetUserFriendList(LLUUID friendlistowner); + List GetUserFriendList(UUID friendlistowner); /// /// Updates the current region the User is in /// /// User Region the Avatar is IN /// User Region the Avatar is IN - void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle); + void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle); /// /// Get's the User Appearance - // AvatarAppearance GetUserAppearance(LLUUID user); + // AvatarAppearance GetUserAppearance(UUID user); - // void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); + // void UpdateUserAppearance(UUID user, AvatarAppearance appearance); - // void AddAttachment(LLUUID user, LLUUID attach); + // void AddAttachment(UUID user, UUID attach); - // void RemoveAttachment(LLUUID user, LLUUID attach); + // void RemoveAttachment(UUID user, UUID attach); - // List GetAttachments(LLUUID user); + // List GetAttachments(UUID user); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index c76c078..3239268 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Reflection; using System.Threading; -using libsecondlife; +using OpenMetaverse; using log4net; namespace OpenSim.Framework.Communications @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications new PluginLoader (new InventoryDataInitialiser (connect)); // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.xml + // unless it is constrainted to the correct "Provider" entry in the addin.Xml loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); loader.Load(); @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public List GetInventorySkeleton(LLUUID userId) + public List GetInventorySkeleton(UUID userId) { // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); @@ -105,13 +105,13 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public virtual bool HasInventoryForUser(LLUUID userID) + public virtual bool HasInventoryForUser(UUID userID) { return false; } // See IInventoryServices - public InventoryFolderBase RequestRootFolder(LLUUID userID) + public InventoryFolderBase RequestRootFolder(UUID userID) { // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin foreach (IInventoryDataPlugin plugin in m_plugins) @@ -122,7 +122,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool CreateNewUserInventory(LLUUID user) + public bool CreateNewUserInventory(UUID user) { InventoryFolderBase existingRootFolder = RequestRootFolder(user); @@ -146,13 +146,13 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback); + public abstract void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback); #endregion #region Methods used by GridInventoryService - public List RequestSubFolders(LLUUID parentFolderID) + public List RequestSubFolders(UUID parentFolderID) { List inventoryList = new List(); foreach (IInventoryDataPlugin plugin in m_plugins) @@ -162,7 +162,7 @@ namespace OpenSim.Framework.Communications return inventoryList; } - public List RequestFolderItems(LLUUID folderID) + public List RequestFolderItems(UUID folderID) { List itemsList = new List(); foreach (IInventoryDataPlugin plugin in m_plugins) @@ -313,27 +313,27 @@ namespace OpenSim.Framework.Communications /// private class UsersInventory { - public Dictionary Folders = new Dictionary(); - public Dictionary Items = new Dictionary(); + public Dictionary Folders = new Dictionary(); + public Dictionary Items = new Dictionary(); - public virtual void CreateNewInventorySet(LLUUID user) + public virtual void CreateNewInventorySet(UUID user) { InventoryFolderBase folder = new InventoryFolderBase(); - folder.ParentID = LLUUID.Zero; + folder.ParentID = UUID.Zero; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "My Inventory"; folder.Type = (short)AssetType.Folder; folder.Version = 1; Folders.Add(folder.ID, folder); - LLUUID rootFolder = folder.ID; + UUID rootFolder = folder.ID; folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Animations"; folder.Type = (short)AssetType.Animation; folder.Version = 1; @@ -342,7 +342,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Body Parts"; folder.Type = (short)AssetType.Bodypart; folder.Version = 1; @@ -351,7 +351,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Calling Cards"; folder.Type = (short)AssetType.CallingCard; folder.Version = 1; @@ -360,7 +360,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Clothing"; folder.Type = (short)AssetType.Clothing; folder.Version = 1; @@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Gestures"; folder.Type = (short)AssetType.Gesture; folder.Version = 1; @@ -378,7 +378,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Landmarks"; folder.Type = (short)AssetType.Landmark; folder.Version = 1; @@ -387,7 +387,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Lost And Found"; folder.Type = (short)AssetType.LostAndFoundFolder; folder.Version = 1; @@ -396,7 +396,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Notecards"; folder.Type = (short)AssetType.Notecard; folder.Version = 1; @@ -405,7 +405,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Objects"; folder.Type = (short)AssetType.Object; folder.Version = 1; @@ -414,7 +414,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Photo Album"; folder.Type = (short)AssetType.SnapshotFolder; folder.Version = 1; @@ -423,7 +423,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Scripts"; folder.Type = (short)AssetType.LSLText; folder.Version = 1; @@ -432,7 +432,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Sounds"; folder.Type = (short)AssetType.Sound; folder.Version = 1; @@ -441,7 +441,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Textures"; folder.Type = (short)AssetType.Texture; folder.Version = 1; @@ -450,7 +450,7 @@ namespace OpenSim.Framework.Communications folder = new InventoryFolderBase(); folder.ParentID = rootFolder; folder.Owner = user; - folder.ID = LLUUID.Random(); + folder.ID = UUID.Random(); folder.Name = "Trash"; folder.Type = (short)AssetType.TrashFolder; folder.Version = 1; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 686d1bb..16be2b7 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -29,8 +29,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; -using libsecondlife; -using libsecondlife.StructuredData; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; @@ -63,9 +63,9 @@ namespace OpenSim.Framework.Communications private UserInfo userProfile; - private LLUUID agentID; - private LLUUID sessionID; - private LLUUID secureSessionID; + private UUID agentID; + private UUID sessionID; + private UUID secureSessionID; // Login Flags private string dst; @@ -171,9 +171,9 @@ namespace OpenSim.Framework.Communications AddClassifiedCategory((Int32) 8, "Service"); AddClassifiedCategory((Int32) 9, "Personal"); - SessionID = LLUUID.Random(); - SecureSessionID = LLUUID.Random(); - AgentID = LLUUID.Random(); + SessionID = UUID.Random(); + SecureSessionID = UUID.Random(); + AgentID = UUID.Random(); Hashtable InitialOutfitHash = new Hashtable(); InitialOutfitHash["folder_name"] = "Nightclub Female"; @@ -567,19 +567,19 @@ namespace OpenSim.Framework.Communications set { simAddress = value; } } - public LLUUID AgentID + public UUID AgentID { get { return agentID; } set { agentID = value; } } - public LLUUID SessionID + public UUID SessionID { get { return sessionID; } set { sessionID = value; } } - public LLUUID SecureSessionID + public UUID SecureSessionID { get { return secureSessionID; } set { secureSessionID = value; } @@ -724,8 +724,8 @@ namespace OpenSim.Framework.Communications public string firstname; public string lastname; public ulong homeregionhandle; - public LLVector3 homepos; - public LLVector3 homelookat; + public Vector3 homepos; + public Vector3 homelookat; } public class BuddyList @@ -754,14 +754,14 @@ namespace OpenSim.Framework.Communications { public int BuddyRightsHave = 1; public int BuddyRightsGiven = 1; - public LLUUID BuddyID; + public UUID BuddyID; public BuddyInfo(string buddyID) { - BuddyID = new LLUUID(buddyID); + BuddyID = new UUID(buddyID); } - public BuddyInfo(LLUUID buddyID) + public BuddyInfo(UUID buddyID) { BuddyID = buddyID; } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 73fba1e..d8d0fa2 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -33,8 +33,8 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using System.Web; -using libsecondlife; -using libsecondlife.StructuredData; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; @@ -94,7 +94,7 @@ namespace OpenSim.Framework.Communications /// /// /// This will be thrown if there is a problem with the inventory service - protected abstract InventoryData GetInventorySkeleton(LLUUID userID); + protected abstract InventoryData GetInventorySkeleton(UUID userID); /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message @@ -163,10 +163,10 @@ namespace OpenSim.Framework.Communications } else if (requestData.Contains("web_login_key")) { - LLUUID webloginkey = null; + UUID webloginkey = null; try { - webloginkey = new LLUUID((string)requestData["web_login_key"]); + webloginkey = new UUID((string)requestData["web_login_key"]); } catch (Exception e) { @@ -227,7 +227,7 @@ namespace OpenSim.Framework.Communications try { - LLUUID agentID = userProfile.ID; + UUID agentID = userProfile.ID; InventoryData inventData = null; try @@ -400,7 +400,7 @@ namespace OpenSim.Framework.Communications try { - LLUUID agentID = userProfile.ID; + UUID agentID = userProfile.ID; //InventoryData inventData = GetInventorySkeleton(agentID); InventoryData inventData = null; @@ -566,7 +566,7 @@ namespace OpenSim.Framework.Communications if (goodweblogin) { - LLUUID webloginkey = LLUUID.Random(); + UUID webloginkey = UUID.Random(); m_userManager.StoreWebLoginKey(user.ID, webloginkey); statuscode = 301; @@ -737,13 +737,13 @@ namespace OpenSim.Framework.Communications return passwordSuccess; } - public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) + public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) { bool passwordSuccess = false; m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - // Match web login key unless it's the default weblogin key LLUUID.Zero - passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != LLUUID.Zero); + // Match web login key unless it's the default weblogin key UUID.Zero + passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != UUID.Zero); return passwordSuccess; } @@ -803,7 +803,7 @@ namespace OpenSim.Framework.Communications /// protected virtual ArrayList GetInventoryLibrary() { - Dictionary rootFolders + Dictionary rootFolders = m_libraryRootFolder.RequestSelfAndDescendentFolders(); ArrayList folderHashes = new ArrayList(); @@ -838,9 +838,9 @@ namespace OpenSim.Framework.Communications public class InventoryData { public ArrayList InventoryArray = null; - public LLUUID RootFolderID = LLUUID.Zero; + public UUID RootFolderID = UUID.Zero; - public InventoryData(ArrayList invList, LLUUID rootID) + public InventoryData(ArrayList invList, UUID rootID) { InventoryArray = invList; RootFolderID = rootID; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index a35ed72..5a63e70 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -31,8 +31,8 @@ using System.Collections.Generic; using System.Net; using System.Reflection; using System.Security.Cryptography; -using libsecondlife; -using libsecondlife.StructuredData; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; using OpenSim.Framework.Statistics; @@ -59,7 +59,7 @@ namespace OpenSim.Framework.Communications new PluginLoader (new UserDataInitialiser (connect)); // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.xml + // unless it is constrainted to the correct "Provider" entry in the addin.Xml loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); loader.Load(); @@ -84,14 +84,14 @@ namespace OpenSim.Framework.Communications return null; } - public void ResetAttachments(LLUUID userID) + public void ResetAttachments(UUID userID) { foreach (IUserDataPlugin plugin in _plugins) { plugin.ResetAttachments(userID); } } - public UserAgentData GetAgentByUUID(LLUUID userId) + public UserAgentData GetAgentByUUID(UUID userId) { foreach (IUserDataPlugin plugin in _plugins) { @@ -106,7 +106,7 @@ namespace OpenSim.Framework.Communications return null; } // see IUserService - public UserProfileData GetUserProfile(LLUUID uuid) + public UserProfileData GetUserProfile(UUID uuid) { foreach (IUserDataPlugin plugin in _plugins) { @@ -122,7 +122,7 @@ namespace OpenSim.Framework.Communications return null; } - public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + public List GenerateAgentPickerRequestResponse(UUID queryID, string query) { List pickerlist = new List(); foreach (IUserDataPlugin plugin in _plugins) @@ -172,7 +172,7 @@ namespace OpenSim.Framework.Communications /// /// The agent's UUID /// Agent profiles - public UserAgentData GetUserAgent(LLUUID uuid) + public UserAgentData GetUserAgent(UUID uuid) { foreach (IUserDataPlugin plugin in _plugins) { @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications return null; } - public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) + public void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle) { foreach (IUserDataPlugin plugin in _plugins) { @@ -254,7 +254,7 @@ namespace OpenSim.Framework.Communications /// /// the UUID of the friend list owner /// A List of FriendListItems that contains info about the user's friends - public List GetUserFriendList(LLUUID ownerID) + public List GetUserFriendList(UUID ownerID) { foreach (IUserDataPlugin plugin in _plugins) { @@ -271,7 +271,7 @@ namespace OpenSim.Framework.Communications return null; } - public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey) + public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) { foreach (IUserDataPlugin plugin in _plugins) { @@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications } } - public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { foreach (IUserDataPlugin plugin in _plugins) { @@ -301,7 +301,7 @@ namespace OpenSim.Framework.Communications } } - public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + public void RemoveUserFriend(UUID friendlistowner, UUID friend) { foreach (IUserDataPlugin plugin in _plugins) { @@ -316,7 +316,7 @@ namespace OpenSim.Framework.Communications } } - public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { foreach (IUserDataPlugin plugin in _plugins) { @@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications /// Resets the currentAgent in the user profile /// /// The agent's ID - public void ClearUserAgent(LLUUID agentID) + public void ClearUserAgent(UUID agentID) { UserProfileData profile = GetUserProfile(agentID); @@ -382,8 +382,8 @@ namespace OpenSim.Framework.Communications rand.GetBytes(randDataS); rand.GetBytes(randDataSS); - agent.SecureSessionID = new LLUUID(randDataSS, 0); - agent.SessionID = new LLUUID(randDataS, 0); + agent.SecureSessionID = new UUID(randDataSS, 0); + agent.SessionID = new UUID(randDataS, 0); // Profile UUID agent.ProfileID = profile.ID; @@ -434,8 +434,8 @@ namespace OpenSim.Framework.Communications agent.LogoutTime = 0; // Current location - agent.InitialRegion = LLUUID.Zero; // Fill in later - agent.Region = LLUUID.Zero; // Fill in later + agent.InitialRegion = UUID.Zero; // Fill in later + agent.Region = UUID.Zero; // Fill in later profile.CurrentAgent = agent; } @@ -449,14 +449,14 @@ namespace OpenSim.Framework.Communications /// /// /// - public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { if (StatsManager.UserStats != null) StatsManager.UserStats.AddLogout(); UserProfileData userProfile; UserAgentData userAgent; - LLVector3 currentPos = new LLVector3(posx, posy, posz); + Vector3 currentPos = new Vector3(posx, posy, posz); userProfile = GetUserProfile(userid); @@ -470,8 +470,8 @@ namespace OpenSim.Framework.Communications { userAgent.AgentOnline = false; userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); - //userAgent.sessionID = LLUUID.Zero; - if (regionid != LLUUID.Zero) + //userAgent.sessionID = UUID.Zero; + if (regionid != UUID.Zero) { userAgent.Region = regionid; } @@ -508,8 +508,8 @@ namespace OpenSim.Framework.Communications rand.GetBytes(randDataS); rand.GetBytes(randDataSS); - agent.SecureSessionID = new LLUUID(randDataSS, 0); - agent.SessionID = new LLUUID(randDataS, 0); + agent.SecureSessionID = new UUID(randDataSS, 0); + agent.SessionID = new UUID(randDataS, 0); // Profile UUID agent.ProfileID = profile.ID; @@ -523,8 +523,8 @@ namespace OpenSim.Framework.Communications agent.LogoutTime = 0; // Current location - agent.InitialRegion = LLUUID.Zero; // Fill in later - agent.Region = LLUUID.Zero; // Fill in later + agent.InitialRegion = UUID.Zero; // Fill in later + agent.Region = UUID.Zero; // Fill in later profile.CurrentAgent = agent; } @@ -550,17 +550,17 @@ namespace OpenSim.Framework.Communications /// /// /// - public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); - user.HomeLocation = new LLVector3(128, 128, 100); - user.ID = LLUUID.Random(); + user.HomeLocation = new Vector3(128, 128, 100); + user.ID = UUID.Random(); user.FirstName = firstName; user.SurName = lastName; user.PasswordHash = pass; user.PasswordSalt = String.Empty; user.Created = Util.UnixTimeSinceEpoch(); - user.HomeLookAt = new LLVector3(100, 100, 100); + user.HomeLookAt = new Vector3(100, 100, 100); user.HomeRegionX = regX; user.HomeRegionY = regY; @@ -604,7 +604,7 @@ namespace OpenSim.Framework.Communications public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); - public abstract UserProfileData SetupMasterUser(LLUUID uuid); + public abstract UserProfileData SetupMasterUser(UUID uuid); /// /// Add agent to DB @@ -629,7 +629,7 @@ namespace OpenSim.Framework.Communications /// Appearance /// TODO: stubs for now to get us to a compiling state gently - public AvatarAppearance GetUserAppearance(LLUUID user) + public AvatarAppearance GetUserAppearance(UUID user) { foreach (IUserDataPlugin plugin in _plugins) { @@ -645,7 +645,7 @@ namespace OpenSim.Framework.Communications return null; } - public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) + public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { foreach (IUserDataPlugin plugin in _plugins) { -- cgit v1.1 From 9e545c9984790ddeabba0bf86e229af90da09ad6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 6 Sep 2008 14:58:23 +0000 Subject: Mantis #2133 Thank you, Xugu Madison and ChrisDown, for a patch that fixes linux filename extensions from .Xml back to .xml --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 7e561b5..88047c2 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(ID, this); - LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.Xml")); + LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); // CreateLibraryItems(); } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 3239268..e9dc3c4 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications new PluginLoader (new InventoryDataInitialiser (connect)); // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.Xml + // unless it is constrainted to the correct "Provider" entry in the addin.xml loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); loader.Load(); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 5a63e70..b6564bf 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -59,7 +59,7 @@ namespace OpenSim.Framework.Communications new PluginLoader (new UserDataInitialiser (connect)); // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.Xml + // unless it is constrainted to the correct "Provider" entry in the addin.xml loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); loader.Load(); -- cgit v1.1 From ea8c18f63d7d8079bc790524bc99e9e067f29737 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 7 Sep 2008 00:47:08 +0000 Subject: * minor: just minor doc and tidy up --- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 16be2b7..f92d66f 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -131,7 +131,7 @@ namespace OpenSim.Framework.Communications SetDefaultValues(); } - public void SetDefaultValues() + private void SetDefaultValues() { DST = "N"; StipendSinceLogin = "N"; -- cgit v1.1 From 815278531ab578dc5c4fbfefb71c6b458c201571 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 7 Sep 2008 05:07:57 +0000 Subject: * Improve login failure handling. * Now it should properly inform the user and stop a login if a region server could not be contacted in order to expect a user (the last commit didn't actually quite work correctly) --- OpenSim/Framework/Communications/LoginService.cs | 41 ++++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d8d0fa2..42292f3 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -74,11 +74,13 @@ namespace OpenSim.Framework.Communications } /// - /// Customises the login response and fills in missing values. + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. /// /// The existing response /// The user profile - public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); + /// true on success, false if the region was not successfully told to expect a user connection + public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); /// /// If the user is already logged in, try to notify the region that the user they've got is dead. @@ -86,8 +88,8 @@ namespace OpenSim.Framework.Communications /// public virtual void LogOffUser(UserProfileData theUser, string message) { - } + /// /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. /// @@ -284,29 +286,26 @@ namespace OpenSim.Framework.Communications logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; - try + if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) { - CustomiseResponse(logResponse, userProfile, startLocationRequest); + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + + return logResponse.ToXmlRpcResponse(); } - catch (Exception e) + else { - m_log.Info("[LOGIN END]: XMLRPC " + e.ToString()); + m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); } - - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); - - return logResponse.ToXmlRpcResponse(); } catch (Exception e) { -- cgit v1.1 From fae34bb10cfa10702faf5c19d8c8517faa018cb5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 9 Sep 2008 01:26:48 +0000 Subject: Update svn properties, formatting cleanup. --- OpenSim/Framework/Communications/Cache/FileAssetClient.cs | 4 ++-- OpenSim/Framework/Communications/LoginService.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index e793feb..17282a1 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -6,11 +6,11 @@ namespace OpenSim.Framework.Communications.Cache public class FileAssetClient : AssetServerBase { private readonly string m_dir; - private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); + private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); public FileAssetClient(string dir) { - if(!Directory.Exists(dir)) + if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 42292f3..7cdbf6c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications } /// - /// Customises the login response and fills in missing values. This method also tells the login region to + /// Customises the login response and fills in missing values. This method also tells the login region to /// expect a client connection. /// /// The existing response @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications public virtual void LogOffUser(UserProfileData theUser, string message) { } - + /// /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. /// @@ -298,7 +298,7 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", firstname, lastname); - + return logResponse.ToXmlRpcResponse(); } else -- cgit v1.1 From aa12787a17a21e45f2d0191dbe3cf40ab73a857a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 11 Sep 2008 11:39:43 +0000 Subject: * Added small convenience function to recursively calculate total amounts of items loaded under library inventory node --- .../Framework/Communications/Cache/InventoryFolderImpl.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index debcbfb..61343a0 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -315,5 +315,20 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } + + public int TotalCount + { + get + { + int total = Items.Count; + + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + total = total + folder.TotalCount; + } + + return total; + } + } } } -- cgit v1.1 From e04ce96cee58a25f48ef3695d7a8566eb6406c57 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 11 Sep 2008 11:41:52 +0000 Subject: * Removed some legacy commenting --- .../Communications/Cache/LibraryRootFolder.cs | 44 ---------------------- 1 file changed, 44 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 88047c2..a33fa67 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -67,52 +67,8 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(ID, this); LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); - - // CreateLibraryItems(); } - /// - /// Hardcoded item creation. Please don't add any more items here - future items should be created - /// in the xml in the bin/inventory folder. - /// - /// - /// Commented the following out due to sending it all through xml, remove this section once this is provin to work stable. - /// - //private void CreateLibraryItems() - //{ - // InventoryItemBase item = - // CreateItem(new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"), - // new UUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", - // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); - // item.inventoryCurrentPermissions = 0; - // item.inventoryNextPermissions = 0; - // Items.Add(item.inventoryID, item); - - // item = - // CreateItem(new UUID("77c41e39-38f9-f75a-024e-585989bfabc9"), - // new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", - // (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); - // item.inventoryCurrentPermissions = 0; - // item.inventoryNextPermissions = 0; - // Items.Add(item.inventoryID, item); - - // item = - // CreateItem(new UUID("77c41e39-38f9-f75a-0000-585989bf0000"), - // new UUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", - // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); - // item.inventoryCurrentPermissions = 0; - // item.inventoryNextPermissions = 0; - // Items.Add(item.inventoryID, item); - - // item = - // CreateItem(new UUID("77c41e39-38f9-f75a-0000-5859892f1111"), - // new UUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", - // (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); - // item.inventoryCurrentPermissions = 0; - // item.inventoryNextPermissions = 0; - // Items.Add(item.inventoryID, item); - //} - public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, int assetType, int invType, UUID parentFolderID) { -- cgit v1.1 From 8d6096b815cf0425fdf8b5a4abad4d34f163f8e5 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 12 Sep 2008 03:33:26 +0000 Subject: Mantis#2165. Thank you kindly, CMickeyB for a patch that: patch is attached that replaces the o(n^2) algorithm currently used to build the inventory cache with an o(n) algorithm using hash tables. the patch also adds some additional error handling. --- .../Communications/Cache/CachedUserInfo.cs | 58 +++++++++++++++------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 339bb31..6371105 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -146,16 +146,20 @@ namespace OpenSim.Framework.Communications.Cache /// Recursively, in depth-first order, add all the folders we've received (stored /// in a dictionary indexed by parent ID) into the tree that describes user folder /// heirarchy + /// Any folder that is resolved into the tree is also added to resolvedFolderDictionary, + /// indexed by folder ID. /// /// /// A /// - private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, IDictionary> folderDictionary) + private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, + IDictionary> receivedFolderDictionary, + IDictionary resolvedFolderDictionary) { - if (folderDictionary.ContainsKey(parentFolder.ID)) + if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) { List resolvedFolders = new List(); // Folders we've resolved with this invocation - foreach (InventoryFolderImpl folder in folderDictionary[parentFolder.ID]) + foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID]) { lock (parentFolder.SubFolders) { @@ -167,16 +171,25 @@ namespace OpenSim.Framework.Communications.Cache } else { - resolvedFolders.Add(folder); - parentFolder.SubFolders.Add(folder.ID, folder); + if ( resolvedFolderDictionary.ContainsKey( folder.ID ) ) { + m_log.WarnFormat( + "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", + folder.Name, folder.ID); + } + else + { + resolvedFolders.Add(folder); + resolvedFolderDictionary[folder.ID] = folder; + parentFolder.SubFolders.Add(folder.ID, folder); + } } - } + } // lock (parentFolder.SubFolders) } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) - folderDictionary.Remove(parentFolder.ID); + receivedFolderDictionary.Remove(parentFolder.ID); foreach (InventoryFolderImpl folder in resolvedFolders) - ResolveReceivedFolders(folder, folderDictionary); - } + ResolveReceivedFolders(folder, receivedFolderDictionary, resolvedFolderDictionary); + } // if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) } /// @@ -211,6 +224,13 @@ namespace OpenSim.Framework.Communications.Cache IDictionary> receivedFolders = new Dictionary>(); + // collection of all folders that have been placed into the folder heirarchy starting at m_rootFolder + // This dictonary exists so we don't have to do an InventoryFolderImpl.FindFolder(), which is O(n) on the + // number of folders in our inventory. + // Maybe we should make this structure a member so we can skip InventoryFolderImpl.FindFolder() calls later too? + IDictionary resolvedFolders = + new Dictionary(); + // Take all received folders, find the root folder, and put ther rest into // the pendingCategorizationFolders collection foreach (InventoryFolderImpl folder in folders) @@ -222,6 +242,7 @@ namespace OpenSim.Framework.Communications.Cache { IList rootFolderList = receivedFolders[UUID.Zero]; m_rootFolder = rootFolderList[0]; + resolvedFolders[m_rootFolder.ID] = m_rootFolder; if (rootFolderList.Count > 1) { for (int i = 1; i < rootFolderList.Count; i++) @@ -237,7 +258,7 @@ namespace OpenSim.Framework.Communications.Cache // Now take the pendingCategorizationFolders collection, and turn that into a tree, // with the root being RootFolder if (RootFolder != null) - ResolveReceivedFolders(RootFolder, receivedFolders); + ResolveReceivedFolders(RootFolder, receivedFolders, resolvedFolders); // Generate a warning for folders that are not part of the heirarchy foreach (KeyValuePair> folderList in receivedFolders) @@ -247,10 +268,10 @@ namespace OpenSim.Framework.Communications.Cache } // Take all ther received items and put them into the folder tree heirarchy - // TBD: This operation is O(n^2), if we made a dictionary of all folders indexed by their ID, we could make - // this O(n) - foreach (InventoryItemBase item in items) - ItemReceive(item); + foreach (InventoryItemBase item in items) { + InventoryFolderImpl folder = resolvedFolders.ContainsKey(item.Folder) ? resolvedFolders[item.Folder] : null; + ItemReceive(item, folder ); + } } catch (Exception e) { @@ -276,16 +297,17 @@ namespace OpenSim.Framework.Communications.Cache /// /// We're assuming here that items are always received after all the folders /// received. + /// If folder is null, we will search for it starting from RootFolder (an O(n) operation), + /// otherwise we'll just put it into folder /// /// - private void ItemReceive(InventoryItemBase itemInfo) + private void ItemReceive(InventoryItemBase itemInfo, InventoryFolderImpl folder) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", // itemInfo.Name, itemInfo.ID, userID); - InventoryFolderImpl folder = null; - if ( RootFolder != null ) + if (folder == null && RootFolder != null) folder = RootFolder.FindFolder(itemInfo.Folder); if (null == folder) @@ -550,7 +572,7 @@ namespace OpenSim.Framework.Communications.Cache else item.Folder = RootFolder.ID; } - ItemReceive(item); + ItemReceive(item, null); if (m_commsManager.SecureInventoryService != null) { m_commsManager.SecureInventoryService.AddItem(item, m_session_id); -- cgit v1.1 From 52a4c4d82f9c5b808e6c61fd51c1c70e42865565 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Sep 2008 20:12:03 +0000 Subject: * Check in first part of http://opensimulator.org/mantis/view.php?id=2073 * This patch aims to introduce look at direction persistence between logins. It won't be active until the second part of the patch is committed in about two weeks time. At this point, region servers that haven't upgraded past this revision may run into problems * This checkin upgrades the user database. As always, we recommend you have backups in case something goes wrong. * Many thanks to tyre for this patch. --- .../Communications/CommunicationsManager.cs | 14 +- OpenSim/Framework/Communications/IUserService.cs | 13 +- OpenSim/Framework/Communications/LoginService.cs | 35 +--- .../Framework/Communications/UserManagerBase.cs | 196 ++++++++++----------- 4 files changed, 130 insertions(+), 128 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e6413e8..969bdd8 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -276,13 +276,25 @@ namespace OpenSim.Framework.Communications /// /// /// + /// + /// + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) + { + m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat); + } + + /// + /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27) + /// + /// + /// + /// /// /// /// public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); - } /// diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 07ea437..7e3c77b 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -106,7 +106,18 @@ namespace OpenSim.Framework.Communications /// Logs off a user on the user server /// /// UUID of the user - /// UUID of the Region + /// UUID of the Region + /// regionhandle + /// final position + /// final lookat + void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat); + + /// + /// Logs off a user on the user server (deprecated as of 2008-08-27) + /// + /// UUID of the user + /// UUID of the Region + /// regionhandle /// final position x /// final position y /// final position z diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7cdbf6c..26ae3c6 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -258,30 +258,19 @@ namespace OpenSim.Framework.Communications InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; ArrayList InventoryLibRoot = new ArrayList(); InventoryLibRoot.Add(InventoryLibRootHash); - logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); - // Circuit Code - uint circode = (uint) (Util.RandomClass.Next()); - + logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); - - logResponse.CircuitCode = (Int32) circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten logResponse.Message = GetMessage(); logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; @@ -322,6 +311,11 @@ namespace OpenSim.Framework.Communications } } + /// + /// Called when we receive the client's initial LLSD login_to_simulator request message + /// + /// The LLSD request + /// The response to send public LLSD LLSDLoginMethod(LLSD request) { // Temporary fix @@ -432,30 +426,19 @@ namespace OpenSim.Framework.Communications InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; ArrayList InventoryLibRoot = new ArrayList(); InventoryLibRoot.Add(InventoryLibRootHash); - logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); - // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); - + logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); - - logResponse.CircuitCode = (Int32)circode; - //logResponse.RegionX = 0; //overwritten - //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten - //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - //logResponse.SimAddress = "127.0.0.1"; //overwritten - //logResponse.SimPort = 0; //overwritten logResponse.Message = GetMessage(); logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b6564bf..75c4dc1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -388,84 +388,115 @@ namespace OpenSim.Framework.Communications // Profile UUID agent.ProfileID = profile.ID; - // Current position (from Home) - agent.Handle = profile.HomeRegion; - agent.Position = profile.HomeLocation; - - // If user specified additional start, use that - if (requestData.ContainsKey("start")) + // Current location/position/alignment + if (profile.CurrentAgent != null) { - string startLoc = ((string)requestData["start"]).Trim(); - if (("last" == startLoc) && (profile.CurrentAgent != null)) - { - if ((profile.CurrentAgent.Position.X > 0) - && (profile.CurrentAgent.Position.Y > 0) - && (profile.CurrentAgent.Position.Z > 0) - ) - { - // TODO: Right now, currentRegion has not been used in GridServer for requesting region. - // TODO: It is only using currentHandle. - agent.Region = profile.CurrentAgent.Region; - agent.Handle = profile.CurrentAgent.Handle; - agent.Position = profile.CurrentAgent.Position; - } - } - -// if (!(startLoc == "last" || startLoc == "home")) -// { -// // Format: uri:Ahern&162&213&34 -// try -// { -// string[] parts = startLoc.Remove(0, 4).Split('&'); -// //string region = parts[0]; -// -// //////////////////////////////////////////////////// -// //SimProfile SimInfo = new SimProfile(); -// //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); -// } -// catch (Exception) -// { -// } -// } + agent.Region = profile.CurrentAgent.Region; + agent.Handle = profile.CurrentAgent.Handle; + agent.Position = profile.CurrentAgent.Position; + agent.LookAt = profile.CurrentAgent.LookAt; + } + else + { + agent.Region = profile.HomeRegionID; + agent.Handle = profile.HomeRegion; + agent.Position = profile.HomeLocation; + agent.LookAt = profile.HomeLookAt; } // What time did the user login? agent.LoginTime = Util.UnixTimeSinceEpoch(); agent.LogoutTime = 0; - // Current location - agent.InitialRegion = UUID.Zero; // Fill in later - agent.Region = UUID.Zero; // Fill in later + profile.CurrentAgent = agent; + } + + public void CreateAgent(UserProfileData profile, LLSD request) + { + UserAgentData agent = new UserAgentData(); + + // User connection + agent.AgentOnline = true; + + //if (request.Params.Count > 1) + //{ + // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; + // agent.AgentIP = RemoteIPEndPoint.Address.ToString(); + // agent.AgentPort = (uint)RemoteIPEndPoint.Port; + //} + + // Generate sessions + RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); + byte[] randDataS = new byte[16]; + byte[] randDataSS = new byte[16]; + rand.GetBytes(randDataS); + rand.GetBytes(randDataSS); + + agent.SecureSessionID = new UUID(randDataSS, 0); + agent.SessionID = new UUID(randDataS, 0); + + // Profile UUID + agent.ProfileID = profile.ID; + + // Current location/position/alignment + if (profile.CurrentAgent != null) + { + agent.Region = profile.CurrentAgent.Region; + agent.Handle = profile.CurrentAgent.Handle; + agent.Position = profile.CurrentAgent.Position; + agent.LookAt = profile.CurrentAgent.LookAt; + } + else + { + agent.Region = profile.HomeRegionID; + agent.Handle = profile.HomeRegion; + agent.Position = profile.HomeLocation; + agent.LookAt = profile.HomeLookAt; + } + + // What time did the user login? + agent.LoginTime = Util.UnixTimeSinceEpoch(); + agent.LogoutTime = 0; profile.CurrentAgent = agent; } /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" + // TODO: what is the logic should be? + bool ret = false; + ret = AddUserAgent(profile.CurrentAgent); + ret = ret & UpdateUserProfile(profile); + return ret; + } + + /// /// Process a user logoff from OpenSim. /// /// /// /// - /// - /// - /// - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) + /// + /// + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) { if (StatsManager.UserStats != null) StatsManager.UserStats.AddLogout(); - UserProfileData userProfile; - UserAgentData userAgent; - Vector3 currentPos = new Vector3(posx, posy, posz); - - userProfile = GetUserProfile(userid); + UserProfileData userProfile = GetUserProfile(userid); if (userProfile != null) { // This line needs to be in side the above if statement or the UserServer will crash on some logouts. - m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); + m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + position.X + "," + position.Y + "," + position.Z + ")"); - userAgent = userProfile.CurrentAgent; + UserAgentData userAgent = userProfile.CurrentAgent; if (userAgent != null) { userAgent.AgentOnline = false; @@ -475,10 +506,11 @@ namespace OpenSim.Framework.Communications { userAgent.Region = regionid; } - userAgent.Handle = regionhandle; - userAgent.Position = currentPos; - userProfile.CurrentAgent = userAgent; + userAgent.Position = position; + userAgent.LookAt = lookat; + //userProfile.CurrentAgent = userAgent; + userProfile.LastLogin = userAgent.LogoutTime; CommitAgent(ref userProfile); } @@ -494,54 +526,18 @@ namespace OpenSim.Framework.Communications } } - public void CreateAgent(UserProfileData profile, LLSD request) - { - UserAgentData agent = new UserAgentData(); - - // User connection - agent.AgentOnline = true; - - // Generate sessions - RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); - byte[] randDataS = new byte[16]; - byte[] randDataSS = new byte[16]; - rand.GetBytes(randDataS); - rand.GetBytes(randDataSS); - - agent.SecureSessionID = new UUID(randDataSS, 0); - agent.SessionID = new UUID(randDataS, 0); - - // Profile UUID - agent.ProfileID = profile.ID; - - // Current position (from Home) - agent.Handle = profile.HomeRegion; - agent.Position = profile.HomeLocation; - - // What time did the user login? - agent.LoginTime = Util.UnixTimeSinceEpoch(); - agent.LogoutTime = 0; - - // Current location - agent.InitialRegion = UUID.Zero; // Fill in later - agent.Region = UUID.Zero; // Fill in later - - profile.CurrentAgent = agent; - } - /// - /// Saves a target agent to the database + /// Process a user logoff from OpenSim (deprecated as of 2008-08-27) /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) + /// + /// + /// + /// + /// + /// + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { - // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" - // TODO: what is the logic should be? - bool ret = false; - ret = AddUserAgent(profile.CurrentAgent); - ret = ret & UpdateUserProfile(profile); - return ret; + LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); } #endregion -- cgit v1.1 From 3476dd56ea9a6b2e597d2a4e8abf679ac0778681 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 14 Sep 2008 04:13:15 +0000 Subject: * Converted a number of methods within the login processes from private to protected. * Made several methods virtual to allow derivative overrides. * Minor cleanups. --- OpenSim/Framework/Communications/LoginResponse.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index f92d66f..435852d4 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -307,7 +307,7 @@ namespace OpenSim.Framework.Communications #endregion - public XmlRpcResponse ToXmlRpcResponse() + public virtual XmlRpcResponse ToXmlRpcResponse() { try { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 26ae3c6..f4c43ef 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -103,7 +103,7 @@ namespace OpenSim.Framework.Communications /// /// The XMLRPC request /// The response to send - public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { // Temporary fix m_loginMutex.WaitOne(); @@ -123,8 +123,8 @@ namespace OpenSim.Framework.Communications UserProfileData userProfile; LoginResponse logResponse = new LoginResponse(); - string firstname = String.Empty; - string lastname = String.Empty; + string firstname; + string lastname; if (GoodXML) { @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications try { UUID agentID = userProfile.ID; - InventoryData inventData = null; + InventoryData inventData; try { @@ -265,7 +265,7 @@ namespace OpenSim.Framework.Communications logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); - logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); + logResponse.CircuitCode = Util.RandomClass.Next(); logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); @@ -298,7 +298,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[LOGIN END]: XMLRPC Login failed, " + e.ToString()); + m_log.Info("[LOGIN END]: XMLRPC Login failed, " + e); } } -- cgit v1.1 From cdced699fb497ebf3ecbbd306269dbbda337aadc Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 14 Sep 2008 23:39:35 +0000 Subject: * Made Seed CAP response respect the SSL setting. --- .../Framework/Communications/Capabilities/Caps.cs | 44 ++++++++++++++++++++-- .../Communications/Capabilities/CapsHandlers.cs | 28 +++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index e82a5e9..a0c59ad 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -104,6 +104,15 @@ namespace OpenSim.Framework.Communications.Capabilities private bool m_dumpAssetsToFile; private string m_regionName; + public bool SSLCaps + { + get { return m_httpListener.UseSSL; } + } + public string SSLCommonName + { + get { return m_httpListener.SSLCommonName; } + } + // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls public NewInventoryItem AddNewInventoryItem = null; @@ -119,10 +128,19 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsObjectPath = capsPath; m_httpListener = httpServer; m_httpListenerHostName = httpListen; + m_httpListenPort = httpPort; + + if (httpServer.UseSSL) + { + m_httpListenPort = httpServer.SSLPort; + httpListen = httpServer.SSLCommonName; + httpPort = httpServer.SSLPort; + } + m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; - m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort); + m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL); m_regionName = regionName; } @@ -541,7 +559,13 @@ namespace OpenSim.Framework.Communications.Capabilities m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + + + string protocol = "http://"; + + if (m_httpListener.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); @@ -587,7 +611,13 @@ namespace OpenSim.Framework.Communications.Capabilities m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + + + string protocol = "http://"; + + if (m_httpListener.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); @@ -646,7 +676,13 @@ namespace OpenSim.Framework.Communications.Capabilities llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + + + string protocol = "http://"; + + if (m_httpListener.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index 4a3d00f..ed31c45 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -42,6 +42,7 @@ namespace OpenSim.Framework.Communications.Capabilities private BaseHttpServer m_httpListener; private string m_httpListenerHostName; private uint m_httpListenerPort; + private bool m_useSSL = false; /// /// CapsHandlers is a cap handler container but also takes @@ -53,10 +54,30 @@ namespace OpenSim.Framework.Communications.Capabilities /// server /// HTTP port public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) + : this (httpListener,httpListenerHostname,httpListenerPort, false) + { + } + + /// + /// CapsHandlers is a cap handler container but also takes + /// care of adding and removing cap handlers to and from the + /// supplied BaseHttpServer. + /// + /// base HTTP server + /// host name of the HTTP + /// server + /// HTTP port + public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) { m_httpListener = httpListener; m_httpListenerHostName = httpListenerHostname; m_httpListenerPort = httpListenerPort; + m_useSSL = https; + if (m_useSSL) + { + m_httpListenerHostName = httpListener.SSLCommonName; + m_httpListenerPort = httpListener.SSLPort; + } } /// @@ -130,7 +151,12 @@ namespace OpenSim.Framework.Communications.Capabilities get { Hashtable caps = new Hashtable(); - string baseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); + string protocol = "http://"; + + if (m_useSSL) + protocol = "https://"; + + string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); foreach (string capsName in m_capsHandlers.Keys) { // skip SEED cap -- cgit v1.1 From 6d289c3ae00b8d0f745d3345e8148b8d39b5206f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 15 Sep 2008 17:29:11 +0000 Subject: * Add "reset user password" command to standalone region console * Grid user server implementation to follow shortly --- .../Communications/CommunicationsManager.cs | 12 +++++++++ OpenSim/Framework/Communications/IUserService.cs | 11 +++++++- .../Framework/Communications/UserManagerBase.cs | 29 ++++++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 969bdd8..1ac5fe4 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -256,6 +256,18 @@ namespace OpenSim.Framework.Communications return userProf.ID; } } + + /// + /// Reset a user password + /// + /// + /// + /// + /// true if the update was successful, false otherwise + public bool ResetUserPassword(string firstName, string lastName, string newPassword) + { + return m_userService.ResetUserPassword(firstName, lastName, newPassword); + } #region Friend Methods diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 7e3c77b..d52d1ea 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -59,7 +59,7 @@ namespace OpenSim.Framework.Communications UserProfileData SetupMasterUser(UUID userId); /// - /// + /// Add a new user profile /// /// UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); @@ -71,6 +71,15 @@ namespace OpenSim.Framework.Communications /// via a call to GetUserProfile(). /// true if the update could be applied, false if it could not be applied. bool UpdateUserProfile(UserProfileData data); + + /// + /// Reset a user password + /// + /// + /// + /// + /// true if the update was successful, false otherwise + bool ResetUserPassword(string firstName, string lastName, string newPassword); /// /// Adds a new friend to the database for XUser diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 75c4dc1..4fc2fea 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -361,8 +361,6 @@ namespace OpenSim.Framework.Communications /// The users loginrequest public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - Hashtable requestData = (Hashtable) request.Params[0]; - UserAgentData agent = new UserAgentData(); // User connection @@ -574,6 +572,33 @@ namespace OpenSim.Framework.Communications return user.ID; } + + /// + /// Reset a user password + /// + /// + /// + /// + /// true if the update was successful, false otherwise + public bool ResetUserPassword(string firstName, string lastName, string newPassword) + { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); + + UserProfileData profile = GetUserProfile(firstName, lastName); + + if (null == profile) + { + m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName); + return false; + } + + profile.PasswordHash = md5PasswdHash; + profile.PasswordSalt = String.Empty; + + UpdateUserProfile(profile); + + return true; + } public bool UpdateUserProfileProperties(UserProfileData UserProfile) { -- cgit v1.1 From c2ee26399947be5e3c23ac3abc53f2ba907ff10f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 15 Sep 2008 18:23:36 +0000 Subject: * refactor: Break out IUserServiceAdmin out of IUserService since admin methods don't need to be implemented on Grid hosted region servers --- .../Framework/Communications/CommunicationsManager.cs | 9 +++++++-- OpenSim/Framework/Communications/IUserService.cs | 17 ----------------- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 3 files changed, 8 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 1ac5fe4..27cdd35 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -98,6 +98,11 @@ namespace OpenSim.Framework.Communications get { return m_networkServersInfo; } } protected NetworkServersInfo m_networkServersInfo; + + /// + /// Interface to administrative user service calls. + /// + protected IUserServiceAdmin m_userServiceAdmin; /// /// Constructor @@ -243,7 +248,7 @@ namespace OpenSim.Framework.Communications { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); + m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); if (userProf == null) { @@ -266,7 +271,7 @@ namespace OpenSim.Framework.Communications /// true if the update was successful, false otherwise public bool ResetUserPassword(string firstName, string lastName, string newPassword) { - return m_userService.ResetUserPassword(firstName, lastName, newPassword); + return m_userServiceAdmin.ResetUserPassword(firstName, lastName, newPassword); } #region Friend Methods diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index d52d1ea..64c6c68 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -40,8 +40,6 @@ namespace OpenSim.Framework.Communications /// A user profile. Returns null if no profile is found UserProfileData GetUserProfile(string firstName, string lastName); - //UserProfileData GetUserProfile(string name); - /// /// Loads a user profile from a database by UUID /// @@ -59,27 +57,12 @@ namespace OpenSim.Framework.Communications UserProfileData SetupMasterUser(UUID userId); /// - /// Add a new user profile - /// - /// - UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); - - /// /// Update the user's profile. /// /// UserProfileData object with updated data. Should be obtained /// via a call to GetUserProfile(). /// true if the update could be applied, false if it could not be applied. bool UpdateUserProfile(UserProfileData data); - - /// - /// Reset a user password - /// - /// - /// - /// - /// true if the update was successful, false otherwise - bool ResetUserPassword(string firstName, string lastName, string newPassword); /// /// Adds a new friend to the database for XUser diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 4fc2fea..f06a438 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IAvatarService + public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 6791ac395893be97f436605bacb5093c36305f4a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 15 Sep 2008 18:35:52 +0000 Subject: * oops! Add interface file I forgot in the last checkin --- .../Framework/Communications/IUserServiceAdmin.cs | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 OpenSim/Framework/Communications/IUserServiceAdmin.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs new file mode 100644 index 0000000..9d1ab9f --- /dev/null +++ b/OpenSim/Framework/Communications/IUserServiceAdmin.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework.Communications +{ + public interface IUserServiceAdmin + { + /// + /// Add a new user profile + /// + /// + UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + + /// + /// Reset a user password + /// + /// + /// + /// + /// true if the update was successful, false otherwise + bool ResetUserPassword(string firstName, string lastName, string newPassword); + } +} -- cgit v1.1 From ddaa90d270c9bd10c74cf89b29b45963719f9b60 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 15 Sep 2008 19:02:34 +0000 Subject: * refactor: collapse UpdateUserProfileProperties() into existing UpdateUserProfile * the methods were identical except that the Properties one did a check for the user profile beforehand. However, every caller was doing this already anyway. --- .../Communications/CommunicationsManager.cs | 2 +- OpenSim/Framework/Communications/IUserService.cs | 7 ------- .../Framework/Communications/UserManagerBase.cs | 23 ---------------------- 3 files changed, 1 insertion(+), 31 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 27cdd35..5bed282 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) { - m_userService.UpdateUserProfileProperties(UserProfile); + m_userService.UpdateUserProfile(UserProfile); return; } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 64c6c68..50c9917 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -88,13 +88,6 @@ namespace OpenSim.Framework.Communications void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); /// - /// Updates a user profile - /// - /// Profile to update - /// - bool UpdateUserProfileProperties(UserProfileData UserProfile); - - /// /// Logs off a user on the user server /// /// UUID of the user diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f06a438..46a9b67 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -600,29 +600,6 @@ namespace OpenSim.Framework.Communications return true; } - public bool UpdateUserProfileProperties(UserProfileData UserProfile) - { - if (null == GetUserProfile(UserProfile.ID)) - { - m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString()); - return false; - } - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.UpdateUserProfile(UserProfile); - } - catch (Exception e) - { - m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString() - + " via " + plugin.Name + "(" + e.ToString() + ")"); - return false; - } - } - return true; - } - public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); public abstract UserProfileData SetupMasterUser(UUID uuid); -- cgit v1.1 From 5fb7b485b211bbf19f4531a051b78dde92da4ba3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 19 Sep 2008 17:41:21 +0000 Subject: * Only allow logins on standalone when the sim has completed it's initial startup (script startup doesn't count here) * There was a small window where region logins were allowed before modules were loaded - avatars logins that hit this window could have caused bad things to happen. * A similar change will follow for grid mode sometime soon --- .../Cache/UserProfileCacheService.cs | 22 +++++++++++++++------- .../Communications/CommunicationsManager.cs | 9 ++++----- OpenSim/Framework/Communications/IGridServices.cs | 7 ++++++- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- 4 files changed, 27 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 3675053..cf6a74d 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -51,12 +51,20 @@ namespace OpenSim.Framework.Communications.Cache /// private readonly Dictionary m_userProfiles = new Dictionary(); - public readonly LibraryRootFolder libraryRoot = new LibraryRootFolder(); + /// + /// The root library folder. + /// + public readonly LibraryRootFolder LibraryRoot; - // Methods - public UserProfileCacheService(CommunicationsManager commsManager) + /// + /// Constructor + /// + /// + /// + public UserProfileCacheService(CommunicationsManager commsManager, LibraryRootFolder libraryRootFolder) { m_commsManager = commsManager; + LibraryRoot = libraryRootFolder; } /// @@ -293,10 +301,10 @@ namespace OpenSim.Framework.Communications.Cache // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold = null; - if ((fold = libraryRoot.FindFolder(folderID)) != null) + if ((fold = LibraryRoot.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - libraryRoot.Owner, folderID, fold.RequestListOfItems(), + LibraryRoot.Owner, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -337,7 +345,7 @@ namespace OpenSim.Framework.Communications.Cache // FIXME MAYBE: We're not handling sortOrder! InventoryFolderImpl fold; - if ((fold = libraryRoot.FindFolder(folderID)) != null) + if ((fold = LibraryRoot.FindFolder(folderID)) != null) { return fold.RequestListOfItems(); } @@ -428,7 +436,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) { - if (ownerID == libraryRoot.Owner) + if (ownerID == LibraryRoot.Owner) { //Console.WriteLine("request info for library item"); diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 5bed282..198bd83 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -112,11 +112,11 @@ namespace OpenSim.Framework.Communications /// /// public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, - bool dumpAssetsToFile) + bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; m_assetCache = assetCache; - m_userProfileCacheService = new UserProfileCacheService(this); + m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } @@ -356,7 +356,7 @@ namespace OpenSim.Framework.Communications public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) { - if (uuid == m_userProfileCacheService.libraryRoot.Owner) + if (uuid == m_userProfileCacheService.LibraryRoot.Owner) { remote_client.SendNameReply(uuid, "Mr", "OpenSim"); } @@ -376,7 +376,6 @@ namespace OpenSim.Framework.Communications string[] returnstring = new string[0]; bool doLookup = false; - lock (m_nameRequestCache) { if (m_nameRequestCache.ContainsKey(uuid)) @@ -405,8 +404,8 @@ namespace OpenSim.Framework.Communications } } } + return returnstring; - } public bool UUIDNameCachedTest(UUID uuid) diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 6c5d2e2..f6a2885 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -33,6 +33,11 @@ namespace OpenSim.Framework.Communications public interface IGridServices { string gdebugRegionName { get; set; } + + /// + /// If true, then regions will accept logins from the user service. If false, then they will not. + /// + bool RegionLoginsEnabled { get; set; } /// /// Register a region with the grid service. @@ -42,7 +47,7 @@ namespace OpenSim.Framework.Communications /// Thrown if region registration failed RegionCommsListener RegisterRegion(RegionInfo regionInfos); - bool DeregisterRegion(RegionInfo regionInfo); + bool DeregisterRegion(RegionInfo regionInfo); /// /// Get information about the regions neighbouring the given co-ordinates. diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f4c43ef..8d27a23 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -239,8 +239,8 @@ namespace OpenSim.Framework.Communications catch (Exception e) { m_log.ErrorFormat( - "[LOGIN END]: XMLRPC Error retrieving inventory skeleton of agent {0}, {1} - {2}", - agentID, e.GetType(), e.Message); + "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", + agentID, e); return logResponse.CreateLoginInventoryFailedResponse(); } -- cgit v1.1 From 82d79e3b0bfa73ed3682c61e14b12471631eda93 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Sep 2008 20:56:39 +0000 Subject: Partially implement notecard saves in task inventory. Still makes the notecard go read-only, but changes are saved. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a0c59ad..a891517 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -168,8 +168,9 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateNotecardAgentInventory"] = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; - m_capsHandlers["UpdateScriptTaskInventory"] = + m_capsHandlers["UpdateNotecardTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); + m_capsHandlers["UpdateScriptTaskInventory"] = m_capsHandlers["UpdateNotecardTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From e4bead4edc50c669fc291a8235e6f6850ade9d8f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Sep 2008 22:04:59 +0000 Subject: Remove CAPS notecard updating, as LL isn't supporting it and the viewer is not playing nice --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a891517..e058555 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -170,7 +170,8 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateNotecardTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); - m_capsHandlers["UpdateScriptTaskInventory"] = m_capsHandlers["UpdateNotecardTaskInventory"]; + // LL doesn't offer this + // m_capsHandlers["UpdateScriptTaskInventory"] = m_capsHandlers["UpdateNotecardTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From a8785f5b2cd27344897baf06ec8ec0fe34c4f370 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Sep 2008 22:11:53 +0000 Subject: And re-reverse the names from last commit --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index e058555..d42c055 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -168,10 +168,10 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateNotecardAgentInventory"] = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; - m_capsHandlers["UpdateNotecardTaskInventory"] = + m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); // LL doesn't offer this - // m_capsHandlers["UpdateScriptTaskInventory"] = m_capsHandlers["UpdateNotecardTaskInventory"]; + // m_capsHandlers["UpdateNotecardTaskInventory"] = m_capsHandlers["UpdateScriptTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From 70be30fbaa6f41ae3849eb33fb23aebdeb02e3b8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 21 Sep 2008 00:05:33 +0000 Subject: Completely revert the notecard uploading changes I made, since they appear to break script saves in prims for some. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d42c055..a0c59ad 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -170,8 +170,6 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); - // LL doesn't offer this - // m_capsHandlers["UpdateNotecardTaskInventory"] = m_capsHandlers["UpdateScriptTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From 1a71a3a56776bc1d91f9da031a295fd4a0023e87 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 21 Sep 2008 16:58:14 +0000 Subject: * Fix http://opensimulator.org/mantis/view.php?id=2189 * Allow a grid mode region simulator to properly shutdown even if the grid service is offline --- OpenSim/Framework/Communications/IGridServices.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index f6a2885..177009d 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -47,6 +47,12 @@ namespace OpenSim.Framework.Communications /// Thrown if region registration failed RegionCommsListener RegisterRegion(RegionInfo regionInfos); + /// + /// Deregister a region with the grid service. + /// + /// + /// + /// Thrown if region deregistration failed bool DeregisterRegion(RegionInfo regionInfo); /// -- cgit v1.1 From 52f0c8d15d0d8a43a809d0f94f96dd115a6d3766 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 21 Sep 2008 17:49:52 +0000 Subject: * minor: tidy up of AssetCache, remove currently pointless storing of thread reference --- .../Framework/Communications/Cache/AssetCache.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3e88eba..c6f41a6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Assets requests which are waiting for asset server data. This includes texture requests /// - private Dictionary RequestedAssets; + private Dictionary RequestedAssets; /// /// Asset requests with data which are ready to be sent back to requesters. This includes textures. @@ -80,10 +80,11 @@ namespace OpenSim.Framework.Communications.Cache /// private Dictionary RequestLists; + /// + /// The 'server' from which assets can be requested and to which assets are persisted. + /// private readonly IAssetServer m_assetServer; - private readonly Thread m_assetCacheThread; - /// /// Report statistical data. /// @@ -175,11 +176,11 @@ namespace OpenSim.Framework.Communications.Cache m_assetServer = assetServer; m_assetServer.SetReceiver(this); - m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - m_assetCacheThread.Name = "AssetCacheThread"; - m_assetCacheThread.IsBackground = true; - m_assetCacheThread.Start(); - ThreadTracker.Add(m_assetCacheThread); + Thread assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + assetCacheThread.Name = "AssetCacheThread"; + assetCacheThread.IsBackground = true; + assetCacheThread.Start(); + ThreadTracker.Add(assetCacheThread); } /// @@ -252,7 +253,6 @@ namespace OpenSim.Framework.Communications.Cache { //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); - // Xantor 20080526: // if a request is made for an asset which is not in the cache yet, but has already been requested by // something else, queue up the callbacks on that requestor instead of swamping the assetserver @@ -266,9 +266,7 @@ namespace OpenSim.Framework.Communications.Cache } else { -#if DEBUG // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); -#endif NewAssetRequest req = new NewAssetRequest(assetId, callback); AssetRequestsList requestList; @@ -389,7 +387,6 @@ namespace OpenSim.Framework.Communications.Cache /// real solution here is a much better cache archicture, but /// this is a stop gap measure until we have such a thing. /// - public void ExpireAsset(UUID uuid) { // uuid is unique, so no need to worry about it showing up -- cgit v1.1 From 70e8097e318511b3bd5661ec60f8c9ac4fdba2ed Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 21 Sep 2008 18:53:58 +0000 Subject: * Eliminate the need to copy asset request lists in the asset cache when an asset is received or missing * Also eliminates a race condition --- .../Framework/Communications/Cache/AssetCache.cs | 104 +++++---------------- 1 file changed, 22 insertions(+), 82 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c6f41a6..0112198 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -46,7 +46,7 @@ namespace OpenSim.Framework.Communications.Cache /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and /// AssetNotFound(), which means they do share the same asset and texture caches. /// - /// TODO Assets in this cache are effectively immortal (they are never disposed off through old age). + /// TODO: Assets in this cache are effectively immortal (they are never disposed of through old age). /// This is not a huge problem at the moment since other memory use usually dwarfs that used by assets /// but it's something to bear in mind. /// @@ -206,24 +206,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// Only get an asset if we already have it in the cache. /// - /// - /// - //private AssetBase GetCachedAsset(UUID assetId) - //{ - // AssetBase asset = null; - - // if (Textures.ContainsKey(assetId)) - // { - // asset = Textures[assetId]; - // } - // else if (Assets.ContainsKey(assetId)) - // { - // asset = Assets[assetId]; - // } - - // return asset; - //} - + /// + /// + /// true if the asset was in the cache, false if it was not private bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { if (Textures.ContainsKey(assetId)) @@ -451,42 +436,21 @@ namespace OpenSim.Framework.Communications.Cache } // Notify requesters for this asset - if (RequestLists.ContainsKey(asset.FullID)) - { - AssetRequestsList reqList = null; - lock (RequestLists) - { - //m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #1)"); - reqList = RequestLists[asset.FullID]; + AssetRequestsList reqList = null; + + lock (RequestLists) + { + if (RequestLists.TryGetValue(asset.FullID, out reqList)) + RequestLists.Remove(asset.FullID); + } - } - //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #1)"); - if (reqList != null) + if (reqList != null) + { + foreach (NewAssetRequest req in reqList.Requests) { - //making a copy of the list is not ideal - //but the old method of locking around this whole block of code was causing a multi-thread lock - //between this and the TextureDownloadModule - //while the localAsset thread running this and trying to send a texture to the callback in the - //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding - // the lock in the texturedownload module) was trying to - //request a new asset and hitting a lock in here on the RequestLists. - - List theseRequests = new List(reqList.Requests); - reqList.Requests.Clear(); - - lock (RequestLists) - { - // m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #2)"); - RequestLists.Remove(asset.FullID); - } - //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #2)"); - - foreach (NewAssetRequest req in theseRequests) - { - // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked - // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); - req.Callback(asset.FullID, asset); - } + // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked + // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); + req.Callback(asset.FullID, asset); } } } @@ -509,27 +473,13 @@ namespace OpenSim.Framework.Communications.Cache AssetRequestsList reqList = null; lock (RequestLists) { - // m_log.Info("AssetCache: Lock taken on requestLists (AssetNotFound #1)"); - if (RequestLists.ContainsKey(assetID)) - { - reqList = RequestLists[assetID]; - } + if (RequestLists.TryGetValue(assetID, out reqList)) + RequestLists.Remove(assetID); } - // m_log.Info("AssetCache: Lock released on requestLists (AssetNotFound #1)"); if (reqList != null) { - List theseRequests = new List(reqList.Requests); - reqList.Requests.Clear(); - - lock (RequestLists) - { - // m_log.Info("AssetCache: Lock taken on requestLists (AssetNotFound #2)"); - RequestLists.Remove(assetID); - } - // m_log.Info("AssetCache: Lock released on requestLists (AssetNotFound #2)"); - - foreach (NewAssetRequest req in theseRequests) + foreach (NewAssetRequest req in reqList.Requests) { req.Callback(assetID, null); } @@ -578,6 +528,7 @@ namespace OpenSim.Framework.Communications.Cache source = 3; //Console.WriteLine("asset request " + requestID); } + //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); if (!Assets.ContainsKey(requestID)) @@ -636,6 +587,7 @@ namespace OpenSim.Framework.Communications.Cache //no requests waiting return; } + // if less than 5, do all of them int num = Math.Min(5, AssetRequests.Count); @@ -688,18 +640,10 @@ namespace OpenSim.Framework.Communications.Cache //public bool AssetInCache; //public int TimeRequested; public int DiscardLevel = -1; - - public AssetRequest() - { - } } public class AssetInfo : AssetBase { - public AssetInfo() - { - } - public AssetInfo(AssetBase aBase) { Data = aBase.Data; @@ -712,10 +656,6 @@ namespace OpenSim.Framework.Communications.Cache public class TextureImage : AssetBase { - public TextureImage() - { - } - public TextureImage(AssetBase aBase) { Data = aBase.Data; -- cgit v1.1 From 8fb3523ef74f87995a4c791212e7dbefe8134a61 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 21 Sep 2008 20:29:06 +0000 Subject: * Start recording asset request times after a cache miss. This is very primtive at the moment - only the last time is kept for some classes of request * This can be seen as "Latest asset request time after cache miss" in show stats on the region console --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0112198..9c73587 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -252,7 +252,7 @@ namespace OpenSim.Framework.Communications.Cache else { // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - + NewAssetRequest req = new NewAssetRequest(assetId, callback); AssetRequestsList requestList; @@ -268,8 +268,11 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); requestList = new AssetRequestsList(assetId); - RequestLists.Add(assetId, requestList); - requestList.Requests.Add(req); + requestList.TimeRequested = DateTime.Now; + requestList.Requests.Add(req); + + RequestLists.Add(assetId, requestList); + m_assetServer.RequestAsset(assetId, isTexture); } } @@ -446,6 +449,9 @@ namespace OpenSim.Framework.Communications.Cache if (reqList != null) { + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); + foreach (NewAssetRequest req in reqList.Requests) { // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked @@ -479,6 +485,9 @@ namespace OpenSim.Framework.Communications.Cache if (reqList != null) { + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); + foreach (NewAssetRequest req in reqList.Requests) { req.Callback(assetID, null); @@ -670,6 +679,11 @@ namespace OpenSim.Framework.Communications.Cache { public UUID AssetID; public List Requests = new List(); + + /// + /// Record the time that this request was first made. + /// + public DateTime TimeRequested; public AssetRequestsList(UUID assetID) { -- cgit v1.1 From 3782d6aab74278996360e6b3e0762a7f6f105495 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 21 Sep 2008 20:44:54 +0000 Subject: * minor: Remove some of the redundant asset id storage for now --- .../Framework/Communications/Cache/AssetCache.cs | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 9c73587..32a6c7d 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -253,7 +253,7 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - NewAssetRequest req = new NewAssetRequest(assetId, callback); + NewAssetRequest req = new NewAssetRequest(callback); AssetRequestsList requestList; lock (RequestLists) @@ -267,7 +267,7 @@ namespace OpenSim.Framework.Communications.Cache else { // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - requestList = new AssetRequestsList(assetId); + requestList = new AssetRequestsList(); requestList.TimeRequested = DateTime.Now; requestList.Requests.Add(req); @@ -675,30 +675,31 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// A list of requests for a particular asset. + /// public class AssetRequestsList { - public UUID AssetID; + /// + /// A list of requests for assets + /// public List Requests = new List(); /// /// Record the time that this request was first made. /// public DateTime TimeRequested; - - public AssetRequestsList(UUID assetID) - { - AssetID = assetID; - } } + /// + /// Represent a request for an asset that has yet to be fulfilled. + /// public class NewAssetRequest { - public UUID AssetID; public AssetRequestCallback Callback; - public NewAssetRequest(UUID assetID, AssetRequestCallback callback) + public NewAssetRequest(AssetRequestCallback callback) { - AssetID = assetID; Callback = callback; } } -- cgit v1.1 From fe9aea258ff4142e718b4916ccefeeedef229768 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Wed, 24 Sep 2008 21:12:21 +0000 Subject: Add persistence of active gestures. This needs an UGAIM update to work. Active gestures are sent as part of the login-response. Added fetchActiveGestures to SQLite and MySQL; added an empty one for MSSQL and NHibernate. Using the empty ones won't cause errors, but doesn't provide persistence either, of course. --- .../Communications/IInterServiceInventoryServices.cs | 11 +++++++++++ OpenSim/Framework/Communications/InventoryServiceBase.cs | 9 +++++++++ OpenSim/Framework/Communications/LoginResponse.cs | 12 ++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs index 5900f4e..661eb91 100644 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs @@ -49,5 +49,16 @@ namespace OpenSim.Framework.Communications /// A flat list of the user's inventory folder tree, /// null if there is no inventory for this user List GetInventorySkeleton(UUID userId); + + /// + /// Returns a list of all the active gestures in a user's inventory. + /// + /// + /// The of the user + /// + /// + /// A flat list of the gesture items. + /// + List GetActiveGestures(UUID userId); } } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index e9dc3c4..d6392c4 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -148,6 +148,15 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public abstract void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback); + public List GetActiveGestures(UUID userId) + { + foreach (IInventoryDataPlugin plugin in m_plugins) + { + return plugin.fetchActiveGestures(userId); + } + return new List(); + } + #endregion #region Methods used by GridInventoryService diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 435852d4..db504f9 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -60,6 +60,7 @@ namespace OpenSim.Framework.Communications private ArrayList inventoryLibraryOwner; private ArrayList inventoryLibRoot; private ArrayList inventoryLibrary; + private ArrayList activeGestures; private UserInfo userProfile; @@ -124,6 +125,7 @@ namespace OpenSim.Framework.Communications agentInventory = new ArrayList(); inventoryLibrary = new ArrayList(); inventoryLibraryOwner = new ArrayList(); + activeGestures = new ArrayList(); xmlRpcResponse = new XmlRpcResponse(); // defaultXmlRpcResponse = new XmlRpcResponse(); @@ -355,7 +357,7 @@ namespace OpenSim.Framework.Communications responseData["inventory-skel-lib"] = inventoryLibrary; responseData["inventory-root"] = inventoryRoot; responseData["inventory-lib-root"] = inventoryLibRoot; - responseData["gestures"] = new ArrayList(); // todo + responseData["gestures"] = activeGestures; responseData["inventory-lib-owner"] = inventoryLibraryOwner; responseData["initial-outfit"] = initialOutfit; responseData["start_location"] = startLocation; @@ -452,7 +454,7 @@ namespace OpenSim.Framework.Communications #endregion Inventory - map["gestures"] = new LLSDArray(); // todo + map["gestures"] = ArrayListToLLSDArray(activeGestures); map["initial-outfit"] = ArrayListToLLSDArray(initialOutfit); map["start_location"] = LLSD.FromString(startLocation); @@ -699,6 +701,12 @@ namespace OpenSim.Framework.Communications set { inventoryLibRoot = value; } } + public ArrayList ActiveGestures + { + get { return activeGestures; } + set { activeGestures = value; } + } + public string Home { get { return home; } -- cgit v1.1 From 17be1b736d438273aa634943629b7f892503744d Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 25 Sep 2008 08:42:48 +0000 Subject: * In Standalone, add a persistant account for the OGP user. * Gridmode, this has no effect at all. --- .../Framework/Communications/CommunicationsManager.cs | 18 ++++++++++++++++++ OpenSim/Framework/Communications/IUserServiceAdmin.cs | 7 +++++-- OpenSim/Framework/Communications/UserManagerBase.cs | 9 +++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 198bd83..1bf8c05 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -261,6 +261,24 @@ namespace OpenSim.Framework.Communications return userProf.ID; } } + + public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY, UUID SetUUID) + { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); + + m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY, SetUUID); + UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); + if (userProf == null) + { + return UUID.Zero; + } + else + { + InterServiceInventoryService.CreateNewUserInventory(userProf.ID); + m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); + return userProf.ID; + } + } /// /// Reset a user password diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs index 9d1ab9f..169385f 100644 --- a/OpenSim/Framework/Communications/IUserServiceAdmin.cs +++ b/OpenSim/Framework/Communications/IUserServiceAdmin.cs @@ -35,8 +35,11 @@ namespace OpenSim.Framework.Communications /// Add a new user profile /// /// - UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); - + UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + + // Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances! + UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID setUUID); + /// /// Reset a user password /// diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 46a9b67..b7f9f5a 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -546,9 +546,14 @@ namespace OpenSim.Framework.Communications /// public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { + return AddUserProfile(firstName, lastName, pass, regX, regY, UUID.Random()); + } + + public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID SetUUID) + { UserProfileData user = new UserProfileData(); user.HomeLocation = new Vector3(128, 128, 100); - user.ID = UUID.Random(); + user.ID = SetUUID; user.FirstName = firstName; user.SurName = lastName; user.PasswordHash = pass; @@ -572,7 +577,7 @@ namespace OpenSim.Framework.Communications return user.ID; } - + /// /// Reset a user password /// -- cgit v1.1 From 16b6738cdadc70966a93b6d025ae469738955dcb Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 26 Sep 2008 17:25:22 +0000 Subject: * Patch from JHurliman * Updates to libomv r2243, * Remove lots of unnecessary typecasts * Improves SendWindData() Thanks jhurliman. * Will update OpenSim-libs in 10 minutes.. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- OpenSim/Framework/Communications/LoginService.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 32a6c7d..1a442ea 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -523,7 +523,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { - UUID requestID = null; + UUID requestID = UUID.Zero; byte source = 2; if (transferRequest.TransferInfo.SourceType == 2) { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8d27a23..7a39a97 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -165,7 +165,7 @@ namespace OpenSim.Framework.Communications } else if (requestData.Contains("web_login_key")) { - UUID webloginkey = null; + UUID webloginkey = UUID.Zero; try { webloginkey = new UUID((string)requestData["web_login_key"]); @@ -268,9 +268,9 @@ namespace OpenSim.Framework.Communications logResponse.CircuitCode = Util.RandomClass.Next(); logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; logResponse.Message = GetMessage(); logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; @@ -436,9 +436,9 @@ namespace OpenSim.Framework.Communications logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); logResponse.Lastname = userProfile.SurName; logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; logResponse.Message = GetMessage(); logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; -- cgit v1.1 From 7ec065198aea732ffc241ab70a72acfb534aeccc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 29 Sep 2008 14:41:16 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2294 * This is an initial basic experimental code for inventory import and export from the region server * Probably not yet ready for general use * Thanks Kayne! --- .../Framework/Communications/Cache/InventoryFolderImpl.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 61343a0..f78cdee 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -316,6 +316,21 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } + public List RequestListOfFolderImpls() + { + List folderList = new List(); + + lock (SubFolders) + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + folderList.Add(folder); + } + } + + return folderList; + } + public int TotalCount { get -- cgit v1.1 From 79b2e5ac71794dd4e55228e0ac146b527fb71ddf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 30 Sep 2008 16:56:33 +0000 Subject: * Replacing Net.HttpListener with HttpServer. * This is a HUGE update.. and should be considered fraut with peril. * SSL Mode isn't available *yet* but I'll work on that next. * DrScofld is still working on a radical new thread pump scheme for this which will be implemented soon. * This could break the Build! This could break your Grid! --- OpenSim/Framework/Communications/UserManagerBase.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b7f9f5a..aa68367 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -368,9 +368,12 @@ namespace OpenSim.Framework.Communications if (request.Params.Count > 1) { - IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; - agent.AgentIP = RemoteIPEndPoint.Address.ToString(); - agent.AgentPort = (uint)RemoteIPEndPoint.Port; + if (request.Params[1] != null) + { + IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; + agent.AgentIP = RemoteIPEndPoint.Address.ToString(); + agent.AgentPort = (uint)RemoteIPEndPoint.Port; + } } // Generate sessions -- cgit v1.1 From fecbb2febd04ec1ad26d0a38930c61cad372b6c6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 1 Oct 2008 15:17:37 +0000 Subject: Add a user server XMLRPC method to set the MOTD and the minimum GodLevel required to log in. set_login_params accepts avatar_uuid and password of a user with god level 200 or more, and allows setting either or both the login_motd or login_level --- OpenSim/Framework/Communications/LoginResponse.cs | 16 ++++++++++++++++ OpenSim/Framework/Communications/LoginService.cs | 9 +++++++++ 2 files changed, 25 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index db504f9..b2565b1 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -275,6 +275,22 @@ namespace OpenSim.Framework.Communications "false"); } + public XmlRpcResponse CreateLoginBlockedResponse() + { + return + (GenerateFailureResponse("presence", + "Logins are currently restricted. Please try again later", + "false")); + } + + public LLSD CreateLoginBlockedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "Logins are currently restricted. Please try again later", + "false"); + } + public XmlRpcResponse CreateDeadRegionResponse() { return diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7a39a97..7a657b5 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -47,6 +47,7 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected string m_welcomeMessage = "Welcome to OpenSim"; + protected int m_minLoginLevel = 0; protected UserManagerBase m_userManager = null; protected Mutex m_loginMutex = new Mutex(false); @@ -196,6 +197,10 @@ namespace OpenSim.Framework.Communications return logResponse.CreateLoginFailedResponse(); } + else if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponse(); + } else { // If we already have a session... @@ -363,6 +368,10 @@ namespace OpenSim.Framework.Communications { return logResponse.CreateLoginFailedResponseLLSD(); } + else if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponseLLSD(); + } else { // If we already have a session... -- cgit v1.1 From 16d68749a457acf079a6737f4ca9a9adb9e53e2f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Fri, 3 Oct 2008 23:00:42 +0000 Subject: Add the missing bits for the new region-search: - Added lookup in the data-layer - MySQL works - SQLite doesn't have a grid-db, so it won't work there - I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-) - Added the plumbing up to OGS1GridServices. This speaks with the grid-server via XMLRPC. - Modified MapSearchModule to use the new data. It's backward compatible; if used with an old grid-server, it just returns one found region instead of a list. - Refactored a bit. Note: This updates data, grid-server and region code. No new files. --- OpenSim/Framework/Communications/IGridServices.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 177009d..69e8756 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -70,5 +70,20 @@ namespace OpenSim.Framework.Communications List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); // not complete yet, only contains the fields needed for ParcelInfoReqeust LandData RequestLandData(ulong regionHandle, uint x, uint y); + + /// + /// Get information about regions starting with the provided name. + /// + /// + /// The name to match against. + /// + /// + /// The maximum number of results to return. + /// + /// + /// A list of s of regions with matching name. If the + /// grid-server couldn't be contacted or returned an error, return null. + /// + List RequestNamedRegions(string name, int maxNumber); } } -- cgit v1.1 From 3ac76db76b378525c001027596df9edbf4ed021e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 5 Oct 2008 18:42:05 +0000 Subject: * Fixes the last snag with the EventQueue. The situation where the seedcap gets lost on teleport. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a0c59ad..0c52e5e 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -157,6 +157,7 @@ namespace OpenSim.Framework.Communications.Capabilities { // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); + m_log.Warn("[SEED]: " + capsBase + m_requestPath); //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, -- cgit v1.1 From 54d7be8a49cbbd47217df84c131221b19e66f0e3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 14 Oct 2008 08:54:46 +0000 Subject: * Adding CrytoGridAssetClient support - allows encrypting assets that are stored on a potentially hostile grid. This is not DRM, not should be relied on until after it's been security audited. I'll write a blog post on this explaining how/why/when you should use this, and what it does. --- .../Communications/Cache/CryptoGridAssetClient.cs | 527 +++++++++++++++++++++ 1 file changed, 527 insertions(+) create mode 100644 OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs new file mode 100644 index 0000000..a8e6efb --- /dev/null +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -0,0 +1,527 @@ +/* + * 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. + */ +/* + * This file includes content derived from Obviex. + * Copyright (C) 2002 Obviex(TM). All rights reserved. + * http://www.obviex.com/samples/Encryption.aspx + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Xml.Serialization; +using log4net; +using OpenSim.Framework.Servers; +using System.Security.Cryptography; + +namespace OpenSim.Framework.Communications.Cache +{ + public class CryptoGridAssetClient : AssetServerBase + { + #region Keyfile Classes + [Serializable] + private class RjinKeyfile + { + public string Secret; + public string AlsoKnownAs; + public int Keysize; + public string IVBytes; + public string Description = "OpenSim Key"; + + private static string SHA1Hash(byte[] bytes) + { + SHA1 sha1 = SHA1CryptoServiceProvider.Create(); + byte[] dataMd5 = sha1.ComputeHash(bytes); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < dataMd5.Length; i++) + sb.AppendFormat("{0:x2}", dataMd5[i]); + return sb.ToString(); + } + + public void GenerateRandom() + { + RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider(); + + byte[] genSec = new byte[32]; + byte[] genAKA = new byte[32]; + byte[] genIV = new byte[32]; + + Gen.GetBytes(genSec); + Gen.GetBytes(genAKA); + Gen.GetBytes(genIV); + + Secret = SHA1Hash(genSec); + AlsoKnownAs = SHA1Hash(genAKA); + IVBytes = SHA1Hash(genIV).Substring(0, 16); + Keysize = 256; + } + } + #endregion + + #region Rjindael + /// + /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and + /// decrypt data. As long as encryption and decryption routines use the same + /// parameters to generate the keys, the keys are guaranteed to be the same. + /// The class uses static functions with duplicate code to make it easier to + /// demonstrate encryption and decryption logic. In a real-life application, + /// this may not be the most efficient way of handling encryption, so - as + /// soon as you feel comfortable with it - you may want to redesign this class. + /// + private class UtilRijndael + { + /// + /// Encrypts specified plaintext using Rijndael symmetric key algorithm + /// and returns a base64-encoded result. + /// + /// + /// Plaintext value to be encrypted. + /// + /// + /// Passphrase from which a pseudo-random password will be derived. The + /// derived password will be used to generate the encryption key. + /// Passphrase can be any string. In this example we assume that this + /// passphrase is an ASCII string. + /// + /// + /// Salt value used along with passphrase to generate password. Salt can + /// be any string. In this example we assume that salt is an ASCII string. + /// + /// + /// Hash algorithm used to generate password. Allowed values are: "MD5" and + /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. + /// + /// + /// Number of iterations used to generate password. One or two iterations + /// should be enough. + /// + /// + /// Initialization vector (or IV). This value is required to encrypt the + /// first block of plaintext data. For RijndaelManaged class IV must be + /// exactly 16 ASCII characters long. + /// + /// + /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. + /// Longer keys are more secure than shorter keys. + /// + /// + /// Encrypted value formatted as a base64-encoded string. + /// + public static byte[] Encrypt(byte[] plainText, + string passPhrase, + string saltValue, + string hashAlgorithm, + int passwordIterations, + string initVector, + int keySize) + { + // Convert strings into byte arrays. + // Let us assume that strings only contain ASCII codes. + // If strings include Unicode characters, use Unicode, UTF7, or UTF8 + // encoding. + byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); + byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); + + // Convert our plaintext into a byte array. + // Let us assume that plaintext contains UTF8-encoded characters. + byte[] plainTextBytes = plainText; + + // First, we must create a password, from which the key will be derived. + // This password will be generated from the specified passphrase and + // salt value. The password will be created using the specified hash + // algorithm. Password creation can be done in several iterations. + PasswordDeriveBytes password = new PasswordDeriveBytes( + passPhrase, + saltValueBytes, + hashAlgorithm, + passwordIterations); + + // Use the password to generate pseudo-random bytes for the encryption + // key. Specify the size of the key in bytes (instead of bits). + byte[] keyBytes = password.GetBytes(keySize / 8); + + // Create uninitialized Rijndael encryption object. + RijndaelManaged symmetricKey = new RijndaelManaged(); + + // It is reasonable to set encryption mode to Cipher Block Chaining + // (CBC). Use default options for other symmetric key parameters. + symmetricKey.Mode = CipherMode.CBC; + + // Generate encryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key + // bytes. + ICryptoTransform encryptor = symmetricKey.CreateEncryptor( + keyBytes, + initVectorBytes); + + // Define memory stream which will be used to hold encrypted data. + MemoryStream memoryStream = new MemoryStream(); + + // Define cryptographic stream (always use Write mode for encryption). + CryptoStream cryptoStream = new CryptoStream(memoryStream, + encryptor, + CryptoStreamMode.Write); + // Start encrypting. + cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); + + // Finish encrypting. + cryptoStream.FlushFinalBlock(); + + // Convert our encrypted data from a memory stream into a byte array. + byte[] cipherTextBytes = memoryStream.ToArray(); + + // Close both streams. + memoryStream.Close(); + cryptoStream.Close(); + + // Return encrypted string. + return cipherTextBytes; + } + + /// + /// Decrypts specified ciphertext using Rijndael symmetric key algorithm. + /// + /// + /// Base64-formatted ciphertext value. + /// + /// + /// Passphrase from which a pseudo-random password will be derived. The + /// derived password will be used to generate the encryption key. + /// Passphrase can be any string. In this example we assume that this + /// passphrase is an ASCII string. + /// + /// + /// Salt value used along with passphrase to generate password. Salt can + /// be any string. In this example we assume that salt is an ASCII string. + /// + /// + /// Hash algorithm used to generate password. Allowed values are: "MD5" and + /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. + /// + /// + /// Number of iterations used to generate password. One or two iterations + /// should be enough. + /// + /// + /// Initialization vector (or IV). This value is required to encrypt the + /// first block of plaintext data. For RijndaelManaged class IV must be + /// exactly 16 ASCII characters long. + /// + /// + /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. + /// Longer keys are more secure than shorter keys. + /// + /// + /// Decrypted string value. + /// + /// + /// Most of the logic in this function is similar to the Encrypt + /// logic. In order for decryption to work, all parameters of this function + /// - except cipherText value - must match the corresponding parameters of + /// the Encrypt function which was called to generate the + /// ciphertext. + /// + public static byte[] Decrypt(byte[] cipherText, + string passPhrase, + string saltValue, + string hashAlgorithm, + int passwordIterations, + string initVector, + int keySize) + { + // Convert strings defining encryption key characteristics into byte + // arrays. Let us assume that strings only contain ASCII codes. + // If strings include Unicode characters, use Unicode, UTF7, or UTF8 + // encoding. + byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); + byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); + + // Convert our ciphertext into a byte array. + byte[] cipherTextBytes = cipherText; + + // First, we must create a password, from which the key will be + // derived. This password will be generated from the specified + // passphrase and salt value. The password will be created using + // the specified hash algorithm. Password creation can be done in + // several iterations. + PasswordDeriveBytes password = new PasswordDeriveBytes( + passPhrase, + saltValueBytes, + hashAlgorithm, + passwordIterations); + + // Use the password to generate pseudo-random bytes for the encryption + // key. Specify the size of the key in bytes (instead of bits). + byte[] keyBytes = password.GetBytes(keySize / 8); + + // Create uninitialized Rijndael encryption object. + RijndaelManaged symmetricKey = new RijndaelManaged(); + + // It is reasonable to set encryption mode to Cipher Block Chaining + // (CBC). Use default options for other symmetric key parameters. + symmetricKey.Mode = CipherMode.CBC; + + // Generate decryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key + // bytes. + ICryptoTransform decryptor = symmetricKey.CreateDecryptor( + keyBytes, + initVectorBytes); + + // Define memory stream which will be used to hold encrypted data. + MemoryStream memoryStream = new MemoryStream(cipherTextBytes); + + // Define cryptographic stream (always use Read mode for encryption). + CryptoStream cryptoStream = new CryptoStream(memoryStream, + decryptor, + CryptoStreamMode.Read); + + // Since at this point we don't know what the size of decrypted data + // will be, allocate the buffer long enough to hold ciphertext; + // plaintext is never longer than ciphertext. + byte[] plainTextBytes = new byte[cipherTextBytes.Length]; + + // Start decrypting. + int decryptedByteCount = cryptoStream.Read(plainTextBytes, + 0, + plainTextBytes.Length); + + // Close both streams. + memoryStream.Close(); + cryptoStream.Close(); + + byte[] plainText = new byte[decryptedByteCount]; + int i; + for (i = 0; i < decryptedByteCount; i++) + plainText[i] = plainTextBytes[i]; + + // Return decrypted string. + return plainText; + } + } + #endregion + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private readonly string _assetServerUrl; + private readonly bool m_encryptOnUpload; + private readonly RjinKeyfile m_encryptKey; + private readonly Dictionary m_keyfiles = new Dictionary(); + + public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) + { + _assetServerUrl = serverUrl; + + string[] keys = Directory.GetFiles(keydir, "*.deckey"); + foreach (string key in keys) + { + XmlSerializer xs = new XmlSerializer(typeof (RjinKeyfile)); + FileStream file = new FileStream(key, FileMode.Open, FileAccess.Read); + + RjinKeyfile rjkey = (RjinKeyfile) xs.Deserialize(file); + + file.Close(); + + m_keyfiles.Add(rjkey.AlsoKnownAs, rjkey); + } + + + keys = Directory.GetFiles(keydir, "*.enckey"); + if (keys.Length == 1) + { + string Ekey = keys[0]; + XmlSerializer Exs = new XmlSerializer(typeof (RjinKeyfile)); + FileStream Efile = new FileStream(Ekey, FileMode.Open, FileAccess.Read); + + RjinKeyfile Erjkey = (RjinKeyfile) Exs.Deserialize(Efile); + + Efile.Close(); + + m_keyfiles.Add(Erjkey.AlsoKnownAs, Erjkey); + + m_encryptKey = Erjkey; + } else + { + if (keys.Length > 1) + throw new Exception( + "You have more than one asset *encryption* key. (You should never have more than one)," + + "If you downloaded this key from someone, rename it to .deckey to convert it to" + + "a decryption-only key."); + + m_log.Warn("No encryption key found, generating a new one for you..."); + RjinKeyfile encKey = new RjinKeyfile(); + encKey.GenerateRandom(); + + m_encryptKey = encKey; + + FileStream encExportFile = new FileStream("mysecretkey_rename_me.enckey",FileMode.CreateNew); + XmlSerializer xs = new XmlSerializer(typeof(RjinKeyfile)); + xs.Serialize(encExportFile, encKey); + encExportFile.Flush(); + encExportFile.Close(); + + m_log.Info( + "Encryption file generated, please rename 'mysecretkey_rename_me.enckey' to something more appropriate (however preserve the file extension)."); + } + + // If Decrypt-Only, dont encrypt on upload + m_encryptOnUpload = !decOnly; + } + + private static void EncryptAssetBase(AssetBase x, RjinKeyfile file) + { + // Make a salt + RNGCryptoServiceProvider RandomGen = new RNGCryptoServiceProvider(); + byte[] rand = new byte[32]; + RandomGen.GetBytes(rand); + + string salt = Convert.ToBase64String(rand); + + x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); + x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", + "OPENSIM_AES_AF1", + file.AlsoKnownAs, + salt, + x.Description); + } + + private bool DecryptAssetBase(AssetBase x) + { + // Check it's encrypted first. + if (!x.Description.Contains("ENCASS")) + return true; + + // ENCASS:ALG:AKA:SALT:Description + // 0 1 2 3 4 + string[] splitchars = new string[1]; + splitchars[0] = "#:~:#"; + + string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); + if (meta.Length < 5) + { + m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); + return false; + } + + // Check if we have a matching key + if (m_keyfiles.ContainsKey(meta[2])) + { + RjinKeyfile deckey = m_keyfiles[meta[2]]; + x.Description = meta[4]; + switch (meta[1]) + { + case "OPENSIM_AES_AF1": + x.Data = UtilRijndael.Decrypt(x.Data, + deckey.Secret, + meta[3], + "SHA1", + 2, + deckey.IVBytes, + deckey.Keysize); + // Decrypted Successfully + return true; + default: + m_log.Warn( + "[ENCASSETS] Recieved Encrypted Asset, but we dont know how to decrypt '" + meta[1] + "'."); + // We dont understand this encryption scheme + return false; + } + } + + m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but we do not have the decryption key."); + return false; + } + + #region IAssetServer Members + + protected override AssetBase GetAsset(AssetRequest req) + { +#if DEBUG + //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); +#endif + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + + Stream s = rc.Request(); + + if (s == null) + return null; + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + + AssetBase encAsset = (AssetBase)xs.Deserialize(s); + + // Try decrypt it + if (DecryptAssetBase(encAsset)) + return encAsset; + } + + return null; + } + + public override void UpdateAsset(AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + public override void StoreAsset(AssetBase asset) + { + if (m_encryptOnUpload) + EncryptAssetBase(asset, m_encryptKey); + + try + { + string assetUrl = _assetServerUrl + "/assets/"; + + m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); + + RestObjectPoster.BeginPostObject(assetUrl, asset); + } + catch (Exception e) + { + m_log.ErrorFormat("[CRYPTO GRID ASSET CLIENT]: {0}", e); + } + } + + public override void Close() + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + } +} -- cgit v1.1 From 9324c3f110d70d44ef91c18e570cffc59d067683 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 15 Oct 2008 16:35:27 +0000 Subject: * refactor: Move error logging from GetUserDetails up to callers, since there are some circumstances in which not finding a user is not an error --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index cf6a74d..45102d8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -75,6 +75,7 @@ namespace OpenSim.Framework.Communications.Cache { if (userID == UUID.Zero) return; + m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); GetUserDetails(userID); } @@ -133,8 +134,8 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Get the details of the given user. A caller should try this method first if it isn't sure that - /// a user profile exists for the given user. + /// Get cached details of the given user. If the user isn't in cache then the user is requested from the + /// profile service. /// /// /// null if no user details are found @@ -160,7 +161,6 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", userID); return null; } } -- cgit v1.1 From 7f721ae20c9d948a67a09c72eb76b3fbede69220 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 16 Oct 2008 15:58:07 +0000 Subject: fix line endings, as apparently the bot didn't do this yet --- .../Communications/Cache/CryptoGridAssetClient.cs | 1054 ++++++++++---------- 1 file changed, 527 insertions(+), 527 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index a8e6efb..8e88844 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -1,527 +1,527 @@ -/* - * 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. - */ -/* - * This file includes content derived from Obviex. - * Copyright (C) 2002 Obviex(TM). All rights reserved. - * http://www.obviex.com/samples/Encryption.aspx - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using System.Xml.Serialization; -using log4net; -using OpenSim.Framework.Servers; -using System.Security.Cryptography; - -namespace OpenSim.Framework.Communications.Cache -{ - public class CryptoGridAssetClient : AssetServerBase - { - #region Keyfile Classes - [Serializable] - private class RjinKeyfile - { - public string Secret; - public string AlsoKnownAs; - public int Keysize; - public string IVBytes; - public string Description = "OpenSim Key"; - - private static string SHA1Hash(byte[] bytes) - { - SHA1 sha1 = SHA1CryptoServiceProvider.Create(); - byte[] dataMd5 = sha1.ComputeHash(bytes); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < dataMd5.Length; i++) - sb.AppendFormat("{0:x2}", dataMd5[i]); - return sb.ToString(); - } - - public void GenerateRandom() - { - RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider(); - - byte[] genSec = new byte[32]; - byte[] genAKA = new byte[32]; - byte[] genIV = new byte[32]; - - Gen.GetBytes(genSec); - Gen.GetBytes(genAKA); - Gen.GetBytes(genIV); - - Secret = SHA1Hash(genSec); - AlsoKnownAs = SHA1Hash(genAKA); - IVBytes = SHA1Hash(genIV).Substring(0, 16); - Keysize = 256; - } - } - #endregion - - #region Rjindael - /// - /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and - /// decrypt data. As long as encryption and decryption routines use the same - /// parameters to generate the keys, the keys are guaranteed to be the same. - /// The class uses static functions with duplicate code to make it easier to - /// demonstrate encryption and decryption logic. In a real-life application, - /// this may not be the most efficient way of handling encryption, so - as - /// soon as you feel comfortable with it - you may want to redesign this class. - /// - private class UtilRijndael - { - /// - /// Encrypts specified plaintext using Rijndael symmetric key algorithm - /// and returns a base64-encoded result. - /// - /// - /// Plaintext value to be encrypted. - /// - /// - /// Passphrase from which a pseudo-random password will be derived. The - /// derived password will be used to generate the encryption key. - /// Passphrase can be any string. In this example we assume that this - /// passphrase is an ASCII string. - /// - /// - /// Salt value used along with passphrase to generate password. Salt can - /// be any string. In this example we assume that salt is an ASCII string. - /// - /// - /// Hash algorithm used to generate password. Allowed values are: "MD5" and - /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. - /// - /// - /// Number of iterations used to generate password. One or two iterations - /// should be enough. - /// - /// - /// Initialization vector (or IV). This value is required to encrypt the - /// first block of plaintext data. For RijndaelManaged class IV must be - /// exactly 16 ASCII characters long. - /// - /// - /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. - /// Longer keys are more secure than shorter keys. - /// - /// - /// Encrypted value formatted as a base64-encoded string. - /// - public static byte[] Encrypt(byte[] plainText, - string passPhrase, - string saltValue, - string hashAlgorithm, - int passwordIterations, - string initVector, - int keySize) - { - // Convert strings into byte arrays. - // Let us assume that strings only contain ASCII codes. - // If strings include Unicode characters, use Unicode, UTF7, or UTF8 - // encoding. - byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); - byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); - - // Convert our plaintext into a byte array. - // Let us assume that plaintext contains UTF8-encoded characters. - byte[] plainTextBytes = plainText; - - // First, we must create a password, from which the key will be derived. - // This password will be generated from the specified passphrase and - // salt value. The password will be created using the specified hash - // algorithm. Password creation can be done in several iterations. - PasswordDeriveBytes password = new PasswordDeriveBytes( - passPhrase, - saltValueBytes, - hashAlgorithm, - passwordIterations); - - // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead of bits). - byte[] keyBytes = password.GetBytes(keySize / 8); - - // Create uninitialized Rijndael encryption object. - RijndaelManaged symmetricKey = new RijndaelManaged(); - - // It is reasonable to set encryption mode to Cipher Block Chaining - // (CBC). Use default options for other symmetric key parameters. - symmetricKey.Mode = CipherMode.CBC; - - // Generate encryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key - // bytes. - ICryptoTransform encryptor = symmetricKey.CreateEncryptor( - keyBytes, - initVectorBytes); - - // Define memory stream which will be used to hold encrypted data. - MemoryStream memoryStream = new MemoryStream(); - - // Define cryptographic stream (always use Write mode for encryption). - CryptoStream cryptoStream = new CryptoStream(memoryStream, - encryptor, - CryptoStreamMode.Write); - // Start encrypting. - cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); - - // Finish encrypting. - cryptoStream.FlushFinalBlock(); - - // Convert our encrypted data from a memory stream into a byte array. - byte[] cipherTextBytes = memoryStream.ToArray(); - - // Close both streams. - memoryStream.Close(); - cryptoStream.Close(); - - // Return encrypted string. - return cipherTextBytes; - } - - /// - /// Decrypts specified ciphertext using Rijndael symmetric key algorithm. - /// - /// - /// Base64-formatted ciphertext value. - /// - /// - /// Passphrase from which a pseudo-random password will be derived. The - /// derived password will be used to generate the encryption key. - /// Passphrase can be any string. In this example we assume that this - /// passphrase is an ASCII string. - /// - /// - /// Salt value used along with passphrase to generate password. Salt can - /// be any string. In this example we assume that salt is an ASCII string. - /// - /// - /// Hash algorithm used to generate password. Allowed values are: "MD5" and - /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. - /// - /// - /// Number of iterations used to generate password. One or two iterations - /// should be enough. - /// - /// - /// Initialization vector (or IV). This value is required to encrypt the - /// first block of plaintext data. For RijndaelManaged class IV must be - /// exactly 16 ASCII characters long. - /// - /// - /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. - /// Longer keys are more secure than shorter keys. - /// - /// - /// Decrypted string value. - /// - /// - /// Most of the logic in this function is similar to the Encrypt - /// logic. In order for decryption to work, all parameters of this function - /// - except cipherText value - must match the corresponding parameters of - /// the Encrypt function which was called to generate the - /// ciphertext. - /// - public static byte[] Decrypt(byte[] cipherText, - string passPhrase, - string saltValue, - string hashAlgorithm, - int passwordIterations, - string initVector, - int keySize) - { - // Convert strings defining encryption key characteristics into byte - // arrays. Let us assume that strings only contain ASCII codes. - // If strings include Unicode characters, use Unicode, UTF7, or UTF8 - // encoding. - byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); - byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); - - // Convert our ciphertext into a byte array. - byte[] cipherTextBytes = cipherText; - - // First, we must create a password, from which the key will be - // derived. This password will be generated from the specified - // passphrase and salt value. The password will be created using - // the specified hash algorithm. Password creation can be done in - // several iterations. - PasswordDeriveBytes password = new PasswordDeriveBytes( - passPhrase, - saltValueBytes, - hashAlgorithm, - passwordIterations); - - // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead of bits). - byte[] keyBytes = password.GetBytes(keySize / 8); - - // Create uninitialized Rijndael encryption object. - RijndaelManaged symmetricKey = new RijndaelManaged(); - - // It is reasonable to set encryption mode to Cipher Block Chaining - // (CBC). Use default options for other symmetric key parameters. - symmetricKey.Mode = CipherMode.CBC; - - // Generate decryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key - // bytes. - ICryptoTransform decryptor = symmetricKey.CreateDecryptor( - keyBytes, - initVectorBytes); - - // Define memory stream which will be used to hold encrypted data. - MemoryStream memoryStream = new MemoryStream(cipherTextBytes); - - // Define cryptographic stream (always use Read mode for encryption). - CryptoStream cryptoStream = new CryptoStream(memoryStream, - decryptor, - CryptoStreamMode.Read); - - // Since at this point we don't know what the size of decrypted data - // will be, allocate the buffer long enough to hold ciphertext; - // plaintext is never longer than ciphertext. - byte[] plainTextBytes = new byte[cipherTextBytes.Length]; - - // Start decrypting. - int decryptedByteCount = cryptoStream.Read(plainTextBytes, - 0, - plainTextBytes.Length); - - // Close both streams. - memoryStream.Close(); - cryptoStream.Close(); - - byte[] plainText = new byte[decryptedByteCount]; - int i; - for (i = 0; i < decryptedByteCount; i++) - plainText[i] = plainTextBytes[i]; - - // Return decrypted string. - return plainText; - } - } - #endregion - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private readonly string _assetServerUrl; - private readonly bool m_encryptOnUpload; - private readonly RjinKeyfile m_encryptKey; - private readonly Dictionary m_keyfiles = new Dictionary(); - - public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) - { - _assetServerUrl = serverUrl; - - string[] keys = Directory.GetFiles(keydir, "*.deckey"); - foreach (string key in keys) - { - XmlSerializer xs = new XmlSerializer(typeof (RjinKeyfile)); - FileStream file = new FileStream(key, FileMode.Open, FileAccess.Read); - - RjinKeyfile rjkey = (RjinKeyfile) xs.Deserialize(file); - - file.Close(); - - m_keyfiles.Add(rjkey.AlsoKnownAs, rjkey); - } - - - keys = Directory.GetFiles(keydir, "*.enckey"); - if (keys.Length == 1) - { - string Ekey = keys[0]; - XmlSerializer Exs = new XmlSerializer(typeof (RjinKeyfile)); - FileStream Efile = new FileStream(Ekey, FileMode.Open, FileAccess.Read); - - RjinKeyfile Erjkey = (RjinKeyfile) Exs.Deserialize(Efile); - - Efile.Close(); - - m_keyfiles.Add(Erjkey.AlsoKnownAs, Erjkey); - - m_encryptKey = Erjkey; - } else - { - if (keys.Length > 1) - throw new Exception( - "You have more than one asset *encryption* key. (You should never have more than one)," + - "If you downloaded this key from someone, rename it to .deckey to convert it to" + - "a decryption-only key."); - - m_log.Warn("No encryption key found, generating a new one for you..."); - RjinKeyfile encKey = new RjinKeyfile(); - encKey.GenerateRandom(); - - m_encryptKey = encKey; - - FileStream encExportFile = new FileStream("mysecretkey_rename_me.enckey",FileMode.CreateNew); - XmlSerializer xs = new XmlSerializer(typeof(RjinKeyfile)); - xs.Serialize(encExportFile, encKey); - encExportFile.Flush(); - encExportFile.Close(); - - m_log.Info( - "Encryption file generated, please rename 'mysecretkey_rename_me.enckey' to something more appropriate (however preserve the file extension)."); - } - - // If Decrypt-Only, dont encrypt on upload - m_encryptOnUpload = !decOnly; - } - - private static void EncryptAssetBase(AssetBase x, RjinKeyfile file) - { - // Make a salt - RNGCryptoServiceProvider RandomGen = new RNGCryptoServiceProvider(); - byte[] rand = new byte[32]; - RandomGen.GetBytes(rand); - - string salt = Convert.ToBase64String(rand); - - x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); - x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", - "OPENSIM_AES_AF1", - file.AlsoKnownAs, - salt, - x.Description); - } - - private bool DecryptAssetBase(AssetBase x) - { - // Check it's encrypted first. - if (!x.Description.Contains("ENCASS")) - return true; - - // ENCASS:ALG:AKA:SALT:Description - // 0 1 2 3 4 - string[] splitchars = new string[1]; - splitchars[0] = "#:~:#"; - - string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); - if (meta.Length < 5) - { - m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); - return false; - } - - // Check if we have a matching key - if (m_keyfiles.ContainsKey(meta[2])) - { - RjinKeyfile deckey = m_keyfiles[meta[2]]; - x.Description = meta[4]; - switch (meta[1]) - { - case "OPENSIM_AES_AF1": - x.Data = UtilRijndael.Decrypt(x.Data, - deckey.Secret, - meta[3], - "SHA1", - 2, - deckey.IVBytes, - deckey.Keysize); - // Decrypted Successfully - return true; - default: - m_log.Warn( - "[ENCASSETS] Recieved Encrypted Asset, but we dont know how to decrypt '" + meta[1] + "'."); - // We dont understand this encryption scheme - return false; - } - } - - m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but we do not have the decryption key."); - return false; - } - - #region IAssetServer Members - - protected override AssetBase GetAsset(AssetRequest req) - { -#if DEBUG - //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); -#endif - - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(req.AssetID.ToString()); - if (req.IsTexture) - rc.AddQueryParameter("texture"); - - rc.RequestMethod = "GET"; - - Stream s = rc.Request(); - - if (s == null) - return null; - - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - - AssetBase encAsset = (AssetBase)xs.Deserialize(s); - - // Try decrypt it - if (DecryptAssetBase(encAsset)) - return encAsset; - } - - return null; - } - - public override void UpdateAsset(AssetBase asset) - { - throw new Exception("The method or operation is not implemented."); - } - - public override void StoreAsset(AssetBase asset) - { - if (m_encryptOnUpload) - EncryptAssetBase(asset, m_encryptKey); - - try - { - string assetUrl = _assetServerUrl + "/assets/"; - - m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); - - RestObjectPoster.BeginPostObject(assetUrl, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[CRYPTO GRID ASSET CLIENT]: {0}", e); - } - } - - public override void Close() - { - throw new Exception("The method or operation is not implemented."); - } - - #endregion - } -} +/* + * 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. + */ +/* + * This file includes content derived from Obviex. + * Copyright (C) 2002 Obviex(TM). All rights reserved. + * http://www.obviex.com/samples/Encryption.aspx + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Xml.Serialization; +using log4net; +using OpenSim.Framework.Servers; +using System.Security.Cryptography; + +namespace OpenSim.Framework.Communications.Cache +{ + public class CryptoGridAssetClient : AssetServerBase + { + #region Keyfile Classes + [Serializable] + private class RjinKeyfile + { + public string Secret; + public string AlsoKnownAs; + public int Keysize; + public string IVBytes; + public string Description = "OpenSim Key"; + + private static string SHA1Hash(byte[] bytes) + { + SHA1 sha1 = SHA1CryptoServiceProvider.Create(); + byte[] dataMd5 = sha1.ComputeHash(bytes); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < dataMd5.Length; i++) + sb.AppendFormat("{0:x2}", dataMd5[i]); + return sb.ToString(); + } + + public void GenerateRandom() + { + RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider(); + + byte[] genSec = new byte[32]; + byte[] genAKA = new byte[32]; + byte[] genIV = new byte[32]; + + Gen.GetBytes(genSec); + Gen.GetBytes(genAKA); + Gen.GetBytes(genIV); + + Secret = SHA1Hash(genSec); + AlsoKnownAs = SHA1Hash(genAKA); + IVBytes = SHA1Hash(genIV).Substring(0, 16); + Keysize = 256; + } + } + #endregion + + #region Rjindael + /// + /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and + /// decrypt data. As long as encryption and decryption routines use the same + /// parameters to generate the keys, the keys are guaranteed to be the same. + /// The class uses static functions with duplicate code to make it easier to + /// demonstrate encryption and decryption logic. In a real-life application, + /// this may not be the most efficient way of handling encryption, so - as + /// soon as you feel comfortable with it - you may want to redesign this class. + /// + private class UtilRijndael + { + /// + /// Encrypts specified plaintext using Rijndael symmetric key algorithm + /// and returns a base64-encoded result. + /// + /// + /// Plaintext value to be encrypted. + /// + /// + /// Passphrase from which a pseudo-random password will be derived. The + /// derived password will be used to generate the encryption key. + /// Passphrase can be any string. In this example we assume that this + /// passphrase is an ASCII string. + /// + /// + /// Salt value used along with passphrase to generate password. Salt can + /// be any string. In this example we assume that salt is an ASCII string. + /// + /// + /// Hash algorithm used to generate password. Allowed values are: "MD5" and + /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. + /// + /// + /// Number of iterations used to generate password. One or two iterations + /// should be enough. + /// + /// + /// Initialization vector (or IV). This value is required to encrypt the + /// first block of plaintext data. For RijndaelManaged class IV must be + /// exactly 16 ASCII characters long. + /// + /// + /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. + /// Longer keys are more secure than shorter keys. + /// + /// + /// Encrypted value formatted as a base64-encoded string. + /// + public static byte[] Encrypt(byte[] plainText, + string passPhrase, + string saltValue, + string hashAlgorithm, + int passwordIterations, + string initVector, + int keySize) + { + // Convert strings into byte arrays. + // Let us assume that strings only contain ASCII codes. + // If strings include Unicode characters, use Unicode, UTF7, or UTF8 + // encoding. + byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); + byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); + + // Convert our plaintext into a byte array. + // Let us assume that plaintext contains UTF8-encoded characters. + byte[] plainTextBytes = plainText; + + // First, we must create a password, from which the key will be derived. + // This password will be generated from the specified passphrase and + // salt value. The password will be created using the specified hash + // algorithm. Password creation can be done in several iterations. + PasswordDeriveBytes password = new PasswordDeriveBytes( + passPhrase, + saltValueBytes, + hashAlgorithm, + passwordIterations); + + // Use the password to generate pseudo-random bytes for the encryption + // key. Specify the size of the key in bytes (instead of bits). + byte[] keyBytes = password.GetBytes(keySize / 8); + + // Create uninitialized Rijndael encryption object. + RijndaelManaged symmetricKey = new RijndaelManaged(); + + // It is reasonable to set encryption mode to Cipher Block Chaining + // (CBC). Use default options for other symmetric key parameters. + symmetricKey.Mode = CipherMode.CBC; + + // Generate encryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key + // bytes. + ICryptoTransform encryptor = symmetricKey.CreateEncryptor( + keyBytes, + initVectorBytes); + + // Define memory stream which will be used to hold encrypted data. + MemoryStream memoryStream = new MemoryStream(); + + // Define cryptographic stream (always use Write mode for encryption). + CryptoStream cryptoStream = new CryptoStream(memoryStream, + encryptor, + CryptoStreamMode.Write); + // Start encrypting. + cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); + + // Finish encrypting. + cryptoStream.FlushFinalBlock(); + + // Convert our encrypted data from a memory stream into a byte array. + byte[] cipherTextBytes = memoryStream.ToArray(); + + // Close both streams. + memoryStream.Close(); + cryptoStream.Close(); + + // Return encrypted string. + return cipherTextBytes; + } + + /// + /// Decrypts specified ciphertext using Rijndael symmetric key algorithm. + /// + /// + /// Base64-formatted ciphertext value. + /// + /// + /// Passphrase from which a pseudo-random password will be derived. The + /// derived password will be used to generate the encryption key. + /// Passphrase can be any string. In this example we assume that this + /// passphrase is an ASCII string. + /// + /// + /// Salt value used along with passphrase to generate password. Salt can + /// be any string. In this example we assume that salt is an ASCII string. + /// + /// + /// Hash algorithm used to generate password. Allowed values are: "MD5" and + /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. + /// + /// + /// Number of iterations used to generate password. One or two iterations + /// should be enough. + /// + /// + /// Initialization vector (or IV). This value is required to encrypt the + /// first block of plaintext data. For RijndaelManaged class IV must be + /// exactly 16 ASCII characters long. + /// + /// + /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. + /// Longer keys are more secure than shorter keys. + /// + /// + /// Decrypted string value. + /// + /// + /// Most of the logic in this function is similar to the Encrypt + /// logic. In order for decryption to work, all parameters of this function + /// - except cipherText value - must match the corresponding parameters of + /// the Encrypt function which was called to generate the + /// ciphertext. + /// + public static byte[] Decrypt(byte[] cipherText, + string passPhrase, + string saltValue, + string hashAlgorithm, + int passwordIterations, + string initVector, + int keySize) + { + // Convert strings defining encryption key characteristics into byte + // arrays. Let us assume that strings only contain ASCII codes. + // If strings include Unicode characters, use Unicode, UTF7, or UTF8 + // encoding. + byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); + byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); + + // Convert our ciphertext into a byte array. + byte[] cipherTextBytes = cipherText; + + // First, we must create a password, from which the key will be + // derived. This password will be generated from the specified + // passphrase and salt value. The password will be created using + // the specified hash algorithm. Password creation can be done in + // several iterations. + PasswordDeriveBytes password = new PasswordDeriveBytes( + passPhrase, + saltValueBytes, + hashAlgorithm, + passwordIterations); + + // Use the password to generate pseudo-random bytes for the encryption + // key. Specify the size of the key in bytes (instead of bits). + byte[] keyBytes = password.GetBytes(keySize / 8); + + // Create uninitialized Rijndael encryption object. + RijndaelManaged symmetricKey = new RijndaelManaged(); + + // It is reasonable to set encryption mode to Cipher Block Chaining + // (CBC). Use default options for other symmetric key parameters. + symmetricKey.Mode = CipherMode.CBC; + + // Generate decryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key + // bytes. + ICryptoTransform decryptor = symmetricKey.CreateDecryptor( + keyBytes, + initVectorBytes); + + // Define memory stream which will be used to hold encrypted data. + MemoryStream memoryStream = new MemoryStream(cipherTextBytes); + + // Define cryptographic stream (always use Read mode for encryption). + CryptoStream cryptoStream = new CryptoStream(memoryStream, + decryptor, + CryptoStreamMode.Read); + + // Since at this point we don't know what the size of decrypted data + // will be, allocate the buffer long enough to hold ciphertext; + // plaintext is never longer than ciphertext. + byte[] plainTextBytes = new byte[cipherTextBytes.Length]; + + // Start decrypting. + int decryptedByteCount = cryptoStream.Read(plainTextBytes, + 0, + plainTextBytes.Length); + + // Close both streams. + memoryStream.Close(); + cryptoStream.Close(); + + byte[] plainText = new byte[decryptedByteCount]; + int i; + for (i = 0; i < decryptedByteCount; i++) + plainText[i] = plainTextBytes[i]; + + // Return decrypted string. + return plainText; + } + } + #endregion + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private readonly string _assetServerUrl; + private readonly bool m_encryptOnUpload; + private readonly RjinKeyfile m_encryptKey; + private readonly Dictionary m_keyfiles = new Dictionary(); + + public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) + { + _assetServerUrl = serverUrl; + + string[] keys = Directory.GetFiles(keydir, "*.deckey"); + foreach (string key in keys) + { + XmlSerializer xs = new XmlSerializer(typeof (RjinKeyfile)); + FileStream file = new FileStream(key, FileMode.Open, FileAccess.Read); + + RjinKeyfile rjkey = (RjinKeyfile) xs.Deserialize(file); + + file.Close(); + + m_keyfiles.Add(rjkey.AlsoKnownAs, rjkey); + } + + + keys = Directory.GetFiles(keydir, "*.enckey"); + if (keys.Length == 1) + { + string Ekey = keys[0]; + XmlSerializer Exs = new XmlSerializer(typeof (RjinKeyfile)); + FileStream Efile = new FileStream(Ekey, FileMode.Open, FileAccess.Read); + + RjinKeyfile Erjkey = (RjinKeyfile) Exs.Deserialize(Efile); + + Efile.Close(); + + m_keyfiles.Add(Erjkey.AlsoKnownAs, Erjkey); + + m_encryptKey = Erjkey; + } else + { + if (keys.Length > 1) + throw new Exception( + "You have more than one asset *encryption* key. (You should never have more than one)," + + "If you downloaded this key from someone, rename it to .deckey to convert it to" + + "a decryption-only key."); + + m_log.Warn("No encryption key found, generating a new one for you..."); + RjinKeyfile encKey = new RjinKeyfile(); + encKey.GenerateRandom(); + + m_encryptKey = encKey; + + FileStream encExportFile = new FileStream("mysecretkey_rename_me.enckey",FileMode.CreateNew); + XmlSerializer xs = new XmlSerializer(typeof(RjinKeyfile)); + xs.Serialize(encExportFile, encKey); + encExportFile.Flush(); + encExportFile.Close(); + + m_log.Info( + "Encryption file generated, please rename 'mysecretkey_rename_me.enckey' to something more appropriate (however preserve the file extension)."); + } + + // If Decrypt-Only, dont encrypt on upload + m_encryptOnUpload = !decOnly; + } + + private static void EncryptAssetBase(AssetBase x, RjinKeyfile file) + { + // Make a salt + RNGCryptoServiceProvider RandomGen = new RNGCryptoServiceProvider(); + byte[] rand = new byte[32]; + RandomGen.GetBytes(rand); + + string salt = Convert.ToBase64String(rand); + + x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); + x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", + "OPENSIM_AES_AF1", + file.AlsoKnownAs, + salt, + x.Description); + } + + private bool DecryptAssetBase(AssetBase x) + { + // Check it's encrypted first. + if (!x.Description.Contains("ENCASS")) + return true; + + // ENCASS:ALG:AKA:SALT:Description + // 0 1 2 3 4 + string[] splitchars = new string[1]; + splitchars[0] = "#:~:#"; + + string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); + if (meta.Length < 5) + { + m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); + return false; + } + + // Check if we have a matching key + if (m_keyfiles.ContainsKey(meta[2])) + { + RjinKeyfile deckey = m_keyfiles[meta[2]]; + x.Description = meta[4]; + switch (meta[1]) + { + case "OPENSIM_AES_AF1": + x.Data = UtilRijndael.Decrypt(x.Data, + deckey.Secret, + meta[3], + "SHA1", + 2, + deckey.IVBytes, + deckey.Keysize); + // Decrypted Successfully + return true; + default: + m_log.Warn( + "[ENCASSETS] Recieved Encrypted Asset, but we dont know how to decrypt '" + meta[1] + "'."); + // We dont understand this encryption scheme + return false; + } + } + + m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but we do not have the decryption key."); + return false; + } + + #region IAssetServer Members + + protected override AssetBase GetAsset(AssetRequest req) + { +#if DEBUG + //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); +#endif + + RestClient rc = new RestClient(_assetServerUrl); + rc.AddResourcePath("assets"); + rc.AddResourcePath(req.AssetID.ToString()); + if (req.IsTexture) + rc.AddQueryParameter("texture"); + + rc.RequestMethod = "GET"; + + Stream s = rc.Request(); + + if (s == null) + return null; + + if (s.Length > 0) + { + XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + + AssetBase encAsset = (AssetBase)xs.Deserialize(s); + + // Try decrypt it + if (DecryptAssetBase(encAsset)) + return encAsset; + } + + return null; + } + + public override void UpdateAsset(AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + public override void StoreAsset(AssetBase asset) + { + if (m_encryptOnUpload) + EncryptAssetBase(asset, m_encryptKey); + + try + { + string assetUrl = _assetServerUrl + "/assets/"; + + m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); + + RestObjectPoster.BeginPostObject(assetUrl, asset); + } + catch (Exception e) + { + m_log.ErrorFormat("[CRYPTO GRID ASSET CLIENT]: {0}", e); + } + } + + public override void Close() + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + } +} -- cgit v1.1 From ae9e38bf3fdc27144e0f3fa377c60506526e4c13 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Thu, 16 Oct 2008 21:46:03 +0000 Subject: Fixed (mono-)script handling for SL viewer 1.21: - Added two missing caps (UpdateScriptAgent, UpdateScriptTask) - Added one missing EventQueue event (ScriptRunningReply) - Changed DNE and XEngine to use this new event As we only use the mono engine anyway, the "Mono" checkbox is set by default but doesn't have any function. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 0c52e5e..fd43e89 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -171,6 +171,8 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); + m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; + m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From 138bcf6fffdb16e3962c03f995aff7cda15a7800 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 17 Oct 2008 16:44:05 +0000 Subject: * Apply a modified version of http://opensimulator.org/mantis/view.php?id=2290 * This allows multiple user profile providers to be specified in OpenSim.ini separated by commas * If multiple providers are specified then a request for a user profile will query each in turn until the profile is either found or all have been queried * Unfortunately I don't believe this order can currently be specified, which if true is something that will need to be fixed. * Thanks to smeans for the original patch. --- OpenSim/Framework/Communications/UserManagerBase.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index aa68367..32bfed7 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -56,11 +56,11 @@ namespace OpenSim.Framework.Communications public void AddPlugin(string provider, string connect) { PluginLoader loader = - new PluginLoader (new UserDataInitialiser (connect)); + new PluginLoader(new UserDataInitialiser(connect)); // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml - loader.Add ("/OpenSim/UserData", new PluginProviderFilter (provider)); + loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider)); loader.Load(); _plugins = loader.Plugins; @@ -178,7 +178,12 @@ namespace OpenSim.Framework.Communications { try { - return plugin.GetAgentByUUID(uuid); + UserAgentData result = plugin.GetAgentByUUID(uuid); + + if (result != null) + { + return result; + } } catch (Exception e) { @@ -260,7 +265,12 @@ namespace OpenSim.Framework.Communications { try { - return plugin.GetUserFriendList(ownerID); + List result = plugin.GetUserFriendList(ownerID); + + if (result != null) + { + return result; + } } catch (Exception e) { @@ -331,7 +341,6 @@ namespace OpenSim.Framework.Communications } } - /// /// Resets the currentAgent in the user profile /// @@ -344,6 +353,7 @@ namespace OpenSim.Framework.Communications { return; } + profile.CurrentAgent = null; UpdateUserProfile(profile); -- cgit v1.1 From e4b8912296536aab8a267ddbaee5d95419f806e8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 17 Oct 2008 17:08:14 +0000 Subject: * reverse part of a change that accidentally crept in with the last revision --- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 32bfed7..ba9cf27 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -84,6 +84,7 @@ namespace OpenSim.Framework.Communications return null; } + public void ResetAttachments(UUID userID) { foreach (IUserDataPlugin plugin in _plugins) @@ -91,6 +92,7 @@ namespace OpenSim.Framework.Communications plugin.ResetAttachments(userID); } } + public UserAgentData GetAgentByUUID(UUID userId) { foreach (IUserDataPlugin plugin in _plugins) @@ -105,6 +107,7 @@ namespace OpenSim.Framework.Communications return null; } + // see IUserService public UserProfileData GetUserProfile(UUID uuid) { @@ -137,6 +140,7 @@ namespace OpenSim.Framework.Communications return new List(); } } + return pickerlist; } -- cgit v1.1 From efe3f3eb2a0a31b1da474974c7d8193c2b28e13f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 18 Oct 2008 05:51:36 +0000 Subject: Megapatch. :) Fix skull attachment editing. Streamline Object terse updates. Add rezzing time to objects. Add Object return and traffic fields to land database. Add plumbing for auto return. Implement auto return. Contains a migration. May contain nuts. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6371105..d242cb3 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -715,7 +715,7 @@ namespace OpenSim.Framework.Communications.Cache } } - private InventoryFolderImpl FindFolderForType(int type) + public InventoryFolderImpl FindFolderForType(int type) { if (RootFolder == null) return null; -- cgit v1.1 From 3a75a54da1d973d0a8044a680c97bc2a54995548 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 18 Oct 2008 15:26:41 +0000 Subject: - Fix Util.UnixTimeSinceEpoch: * Unix epoch starts at midnight, not at 8:00am * All date/time handling should be done in UTC in the server, not in the local timezone. * Refactor out repeated computation of a constant value - Added setting of CreationTime to some places where inventoryitems are created This fixes Mantis#2390. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index fd43e89..28e56da 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -754,6 +754,7 @@ namespace OpenSim.Framework.Communications.Capabilities item.BasePermissions = 2147483647; item.EveryOnePermissions = 0; item.NextPermissions = 2147483647; + item.CreationDate = Util.UnixTimeSinceEpoch(); if (AddNewInventoryItem != null) { -- cgit v1.1 From 12042cdc2b53e581ace6a017d9b17bd763a544b2 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 20 Oct 2008 18:07:06 +0000 Subject: From: Alan Webb cleanups and assorted fixes to REST inventory, asset, and appearance services. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index a33fa67..437e5e4 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -178,8 +178,14 @@ namespace OpenSim.Framework.Communications.Cache if (libraryFolders.ContainsKey(item.Folder)) { InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; - - parentFolder.Items.Add(item.ID, item); + try + { + parentFolder.Items.Add(item.ID, item); + } + catch (Exception) + { + m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); + } } else { -- cgit v1.1 From b91857b8f7809b9bddfa5d36c1ccf84e8142d22b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 23 Oct 2008 10:15:19 +0000 Subject: Adding AddXmlRpcHandler(name, method, bool) to selectively disable KeepAlive for certain XmlRpc handlers. Making use of new AddXmlRpcHandler method in RemoteAdminPlugin to avoid clients waiting indefinitely for response. taking note of BaseHttpServer parameter in CommunicationsManager constructor (was passed it but then just ignored so far). --- OpenSim/Framework/Communications/CommunicationsManager.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 1bf8c05..dfe0fdc 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -104,6 +104,13 @@ namespace OpenSim.Framework.Communications /// protected IUserServiceAdmin m_userServiceAdmin; + + public BaseHttpServer HttpServer + { + get { return m_httpServer; } + } + protected BaseHttpServer m_httpServer; + /// /// Constructor /// @@ -117,6 +124,7 @@ namespace OpenSim.Framework.Communications m_networkServersInfo = serversInfo; m_assetCache = assetCache; m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); + m_httpServer = httpServer; // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } -- cgit v1.1 From 1ff9709ea3d5e7c9ef21f6f59ae0dce62dd7b1c4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 28 Oct 2008 21:31:23 +0000 Subject: * Possibly fix grey avatar appearance problems * And hopefully rebaking all the time should no longer be necessary now * It turns out that when the client baked the texture, the uploaded asset had the Temporary flag to true (Temporary is actually deprecated). * It also had the StoreLocal flag set to true, which signifies that the asset should be stored locally. If it disappears we should reply to the asset request with ImageNotInDatabasePacket * However, last time this was enabled some clients started crashing. This may well no longer be the case and needs to be tested, but in the mean time we will store the asset instead. * This needs to be resolved in a better way, possibly by starting to send the ImageNotInDatabase packet again instead --- .../Framework/Communications/Cache/AssetCache.cs | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1a442ea..1ae7eb7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -334,6 +334,10 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { +// m_log.DebugFormat( +// "[ASSET CACHE]: Uploaded asset {0}, temporary {1}, store local {2}", +// asset.ID, asset.Temporary, asset.Local); + if (asset.Type == (int)AssetType.Texture) { if (!Textures.ContainsKey(asset.FullID)) @@ -344,11 +348,23 @@ namespace OpenSim.Framework.Communications.Cache if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddTexture(textur); - if (!asset.Temporary) + // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the + // information is stored locally. It could disappear, in which case we could send the + // ImageNotInDatabase packet to tell the client this. However, when this was enabled in + // TextureNotFoundSender it ended up crashing clients - we need to go back and try this again. + // + // In the mean time, we're just going to push local assets to the permanent store instead. + // TODO: Need to come back and address this. + // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. + if (!asset.Temporary || asset.Local) { m_assetServer.StoreAsset(asset); } } +// else +// { +// m_log.DebugFormat("[ASSET CACHE]: Textures already contains {0}", asset.ID); +// } } else { @@ -360,11 +376,16 @@ namespace OpenSim.Framework.Communications.Cache if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAsset(assetInf); - if (!asset.Temporary) + // See comment above. + if (!asset.Temporary || asset.Local) { m_assetServer.StoreAsset(asset); } } +// else +// { +// m_log.DebugFormat("[ASSET CACHE]: Assets already contains {0}", asset.ID); +// } } } @@ -394,6 +415,8 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver public void AssetReceived(AssetBase asset, bool IsTexture) { +// m_log.DebugFormat("[ASSET CACHE]: Received asset {0}", asset.ID); + //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) @@ -464,7 +487,7 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver public void AssetNotFound(UUID assetID, bool IsTexture) { - //m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); +// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); if (IsTexture) { -- cgit v1.1 From 8a3157aa6a83b7b84811cd4675ba9fc8e6fbd32e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Oct 2008 18:38:10 +0000 Subject: * Check in (disabled) results of not persisting avatar textures but rather sending ImageNotFound to clients if avatar textures are missing * Whilst this does automatically get the client to rebake, on crossing a region border the 'local' assets are left behind * There may be a cunning solution (such as squirting the assets on region crossing, or having them fetched from the original region) but instead I'm going to opt for the easy solution of keeping them in the asset database, for now --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1ae7eb7..e1e42cf 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -350,11 +350,21 @@ namespace OpenSim.Framework.Communications.Cache // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the // information is stored locally. It could disappear, in which case we could send the - // ImageNotInDatabase packet to tell the client this. However, when this was enabled in - // TextureNotFoundSender it ended up crashing clients - we need to go back and try this again. + // ImageNotInDatabase packet to tell the client this. + // + // However, this doesn't quite appear to work with local textures that are part of an avatar's + // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake + // and reupload by the client, if those assets aren't pushed to the asset server anyway, then + // on crossing onto another region server, other avatars can no longer get the required textures. + // There doesn't appear to be any signal from the sim to the newly region border crossed client + // asking it to reupload its local texture assets to that region server. + // + // One can think of other cunning ways around this. For instance, on a region crossing or teleport, + // the original sim could squirt local assets to the new sim. Or the new sim could have pointers + // to the original sim to fetch the 'local' assets (this is getting more complicated). + // + // But for now, we're going to take the easy way out and store local assets globally. // - // In the mean time, we're just going to push local assets to the permanent store instead. - // TODO: Need to come back and address this. // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. if (!asset.Temporary || asset.Local) { -- cgit v1.1 From 38e8853e5761d09a7e8f580dd277d9b99b834696 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 1 Nov 2008 22:09:48 +0000 Subject: Megapatch that fixes/adds: friend offer/deny/accept, friendship termination, on-/offline updates, calling cards for friends. This adds methods in the DB layer and changes the MessagingServer, so a full update (incl. UGAIM) is necessary to get it working. Older regions shouldn't break, nor should older UGAIM break newer regions, but friends/presence will only work with all concerned parts (UGAIM, source region and destination region) at this revision (or later). I added the DB code for MSSQL, too, but couldn't test that. BEWARE: May contain bugs. --- .../Communications/CommunicationsManager.cs | 21 ++++++++++++ .../Communications/IInterRegionCommunications.cs | 38 ++++++++++++++++++++++ .../Framework/Communications/IMessagingService.cs | 37 +++++++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 24 +++++++++++++- 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Framework/Communications/IMessagingService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index dfe0fdc..bb4a853 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -50,6 +50,12 @@ namespace OpenSim.Framework.Communications } protected IUserService m_userService; + public IMessagingService MessageService + { + get { return m_messageService; } + } + protected IMessagingService m_messageService; + public IGridServices GridService { get { return m_gridService; } @@ -370,6 +376,21 @@ namespace OpenSim.Framework.Communications return m_userService.GetUserFriendList(friendlistowner); } + public Dictionary GetFriendRegionInfos(List uuids) + { + return m_messageService.GetFriendRegionInfos(uuids); + } + + public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) + { + return m_interRegion.InformFriendsInOtherRegion(agentId, destRegionHandle, friends, online); + } + + public bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) + { + return m_interRegion.TriggerTerminateFriend(regionHandle, agentID, exFriendID); + } + #endregion #region Packet Handlers diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 3dd5561..6b589b9 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenMetaverse; namespace OpenSim.Framework.Communications @@ -46,5 +47,42 @@ namespace OpenSim.Framework.Communications bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID); bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); + + /// + /// Try to inform friends in the given region about online status of agent. + /// + /// + /// The of the agent. + /// + /// + /// The regionHandle of the region. + /// + /// + /// A List of s of friends to inform in the given region. + /// + /// + /// Is the agent online or offline + /// + /// + /// A list of friends that couldn't be reached on this region. + /// + List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online); + + /// + /// Send TerminateFriend of exFriendID to agent agentID in region regionHandle. + /// + /// + /// The handle of the region agentID is in (hopefully). + /// + /// + /// The agent to send the packet to. + /// + /// + /// The ex-friends ID. + /// + /// + /// Whether the packet could be sent. False if the agent couldn't be found in the region. + /// + bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID); } } diff --git a/OpenSim/Framework/Communications/IMessagingService.cs b/OpenSim/Framework/Communications/IMessagingService.cs new file mode 100644 index 0000000..5d4cbf8 --- /dev/null +++ b/OpenSim/Framework/Communications/IMessagingService.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications +{ + public interface IMessagingService + { + Dictionary GetFriendRegionInfos (List uuids); + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index ba9cf27..7189eee 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -35,6 +35,7 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; +using OpenSim.Framework; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications @@ -42,7 +43,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService + public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService, IMessagingService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -285,6 +286,27 @@ namespace OpenSim.Framework.Communications return null; } + public Dictionary GetFriendRegionInfos (List uuids) + { + foreach (IUserDataPlugin plugin in _plugins) + { + try + { + Dictionary result = plugin.GetFriendRegionInfos(uuids); + + if (result != null) + { + return result; + } + } + catch (Exception e) + { + m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); + } + } + return null; + } + public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) { foreach (IUserDataPlugin plugin in _plugins) -- cgit v1.1 From 8aa16a9acf6f43598dba04632bb4b42bcd53d3b7 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Mon, 3 Nov 2008 05:22:36 +0000 Subject: Thanks diva for patch that makes a bunch of methods in InventoryServiceBase virtual, so that they can be overriden in subclasses. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index d6392c4..5841151 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -111,7 +111,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public InventoryFolderBase RequestRootFolder(UUID userID) + public virtual InventoryFolderBase RequestRootFolder(UUID userID) { // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin foreach (IInventoryDataPlugin plugin in m_plugins) @@ -185,7 +185,7 @@ namespace OpenSim.Framework.Communications #endregion // See IInventoryServices - public bool AddFolder(InventoryFolderBase folder) + public virtual bool AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); @@ -200,7 +200,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool UpdateFolder(InventoryFolderBase folder) + public virtual bool UpdateFolder(InventoryFolderBase folder) { m_log.DebugFormat( "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); @@ -215,7 +215,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool MoveFolder(InventoryFolderBase folder) + public virtual bool MoveFolder(InventoryFolderBase folder) { m_log.DebugFormat( "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); @@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool AddItem(InventoryItemBase item) + public virtual bool AddItem(InventoryItemBase item) { m_log.DebugFormat( "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); @@ -245,7 +245,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool UpdateItem(InventoryItemBase item) + public virtual bool UpdateItem(InventoryItemBase item) { m_log.InfoFormat( "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); @@ -260,7 +260,7 @@ namespace OpenSim.Framework.Communications } // See IInventoryServices - public bool DeleteItem(InventoryItemBase item) + public virtual bool DeleteItem(InventoryItemBase item) { m_log.InfoFormat( "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); @@ -281,7 +281,7 @@ namespace OpenSim.Framework.Communications /// already know... Needs heavy refactoring. /// /// - public bool PurgeFolder(InventoryFolderBase folder) + public virtual bool PurgeFolder(InventoryFolderBase folder) { m_log.DebugFormat( "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); -- cgit v1.1 From d664192dfee3a703a7a5b284c4562745f78fcb7f Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 5 Nov 2008 02:23:44 +0000 Subject: Mantis#2557. Thank you kindly, Diva for a patch that: This patch changes a method from private to public. Will make life easier for the asset mapper for the hypergrid. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e1e42cf..5c8fddc 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -209,7 +209,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the asset was in the cache, false if it was not - private bool TryGetCachedAsset(UUID assetId, out AssetBase asset) + public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { if (Textures.ContainsKey(assetId)) { -- cgit v1.1 From 17e43dcc0f32cbdb030e20495dc179a6f8c3ef09 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 6 Nov 2008 19:27:18 +0000 Subject: Mantis#2566. Thank you kindly, Diva for a patch that: This patch introduces a couple of read-only properties, so that I can grab the asset server plugin from a region module. This is needed to set up an http service for accessing standalone assets remotely. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 5 +++++ OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 5c8fddc..dfdb0e7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -85,6 +85,11 @@ namespace OpenSim.Framework.Communications.Cache /// private readonly IAssetServer m_assetServer; + public IAssetServer AssetServer + { + get { return m_assetServer; } + } + /// /// Report statistical data. /// diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 9f4f480..a289fb7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -45,6 +45,11 @@ namespace OpenSim.Framework.Communications.Cache protected Thread m_localAssetServerThread; protected IAssetProviderPlugin m_assetProvider; + public IAssetProviderPlugin AssetProviderPlugin + { + get { return m_assetProvider; } + } + // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); -- cgit v1.1 From bbb8d6fc51020a8734163313bfc0b8aac9e402c2 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 8 Nov 2008 14:28:43 +0000 Subject: Remove empty OSUUID.cs file. Add copyright headers. Minor formatting cleanup. --- .../Communications/Cache/AuthedSessionCache.cs | 27 ++++++++++++++++++++ .../Communications/Cache/FileAssetClient.cs | 29 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs index 625c42b..be10e96 100644 --- a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs +++ b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.Text; diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index 17282a1..5f15c3e 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -1,4 +1,31 @@ -using System.IO; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.IO; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.Cache -- cgit v1.1 From c43e466301afd6dc83f473ef98a14fa8cd775181 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 9 Nov 2008 15:00:26 +0000 Subject: * Enabled GTCache for AssetCache * Items will now be locally cached for only 24 hours from last access. (Rather than until restart) * Caveat: Implementing the new caching mechanism means statistics gathering on AssetCache is no longer functional. (Justin - you might want to take a look and see if you can somehow get that back and running if you still need it) --- .../Framework/Communications/Cache/AssetCache.cs | 268 ++++++--------------- 1 file changed, 77 insertions(+), 191 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dfdb0e7..0581cc6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -33,6 +33,7 @@ using OpenMetaverse; using OpenMetaverse.Packets; using log4net; using OpenSim.Framework.Statistics; +using GlynnTucker.Cache; namespace OpenSim.Framework.Communications.Cache { @@ -52,18 +53,20 @@ namespace OpenSim.Framework.Communications.Cache /// public class AssetCache : IAssetReceiver { + protected ICache m_memcache = new SimpleMemoryCache(); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// The cache of assets. This does not include textures. /// - private Dictionary Assets; + //private Dictionary Assets; /// /// The cache of textures. /// - private Dictionary Textures; + //private Dictionary Textures; /// /// Assets requests which are waiting for asset server data. This includes texture requests @@ -95,52 +98,11 @@ namespace OpenSim.Framework.Communications.Cache /// public void ShowState() { - m_log.InfoFormat("Assets:{0} Textures:{1} RequestLists:{2}", - Assets.Count, - Textures.Count, + m_log.InfoFormat("Memcache:{1} RequestLists:{2}", + m_memcache.Count, // AssetRequests.Count, // RequestedAssets.Count, RequestLists.Count); - - int temporaryImages = 0; - int temporaryAssets = 0; - - long imageBytes = 0; - long assetBytes = 0; - - foreach (TextureImage texture in Textures.Values) - { - if (texture != null) - { - if (texture.Temporary) - { - temporaryImages++; - } - - imageBytes += texture.Data.GetLongLength(0); - } - } - - foreach (AssetInfo asset in Assets.Values) - { - if (asset != null) - { - if (asset.Temporary) - { - temporaryAssets++; - } - - assetBytes += asset.Data.GetLongLength(0); - } - } - - m_log.InfoFormat("Temporary Images: {0} Temporary Assets: {1}", - temporaryImages, - temporaryAssets); - - m_log.InfoFormat("Image data: {0}kb Asset data: {1}kb", - imageBytes / 1024, - assetBytes / 1024); } /// @@ -161,8 +123,6 @@ namespace OpenSim.Framework.Communications.Cache /// private void Initialize() { - Assets = new Dictionary(); - Textures = new Dictionary(); AssetRequests = new List(); RequestedAssets = new Dictionary(); @@ -181,7 +141,7 @@ namespace OpenSim.Framework.Communications.Cache m_assetServer = assetServer; m_assetServer.SetReceiver(this); - Thread assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + Thread assetCacheThread = new Thread(RunAssetManager); assetCacheThread.Name = "AssetCacheThread"; assetCacheThread.IsBackground = true; assetCacheThread.Start(); @@ -203,7 +163,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.Error("[ASSET CACHE]: " + e.ToString()); + m_log.Error("[ASSET CACHE]: " + e); } } } @@ -216,14 +176,11 @@ namespace OpenSim.Framework.Communications.Cache /// true if the asset was in the cache, false if it was not public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { - if (Textures.ContainsKey(assetId)) - { - asset = Textures[assetId]; - return true; - } - else if (Assets.ContainsKey(assetId)) + Object tmp; + if(m_memcache.TryGet(assetId, out tmp)) { - asset = Assets[assetId]; + asset = (AssetBase)tmp; + //m_log.Info("Retrieved from cache " + assetId); return true; } @@ -312,25 +269,22 @@ namespace OpenSim.Framework.Communications.Cache { return asset; } - else + m_assetServer.RequestAsset(assetID, isTexture); + + do { - m_assetServer.RequestAsset(assetID, isTexture); + Thread.Sleep(pollPeriod); - do + if (TryGetCachedAsset(assetID, out asset)) { - Thread.Sleep(pollPeriod); - - if (TryGetCachedAsset(assetID, out asset)) - { - return asset; - } - } while (--maxPolls > 0); + return asset; + } + } while (--maxPolls > 0); - m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", - isTexture ? "texture" : "asset", assetID.ToString()); + m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", + isTexture ? "texture" : "asset", assetID.ToString()); - return null; - } + return null; } /// @@ -339,68 +293,34 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { -// m_log.DebugFormat( -// "[ASSET CACHE]: Uploaded asset {0}, temporary {1}, store local {2}", -// asset.ID, asset.Temporary, asset.Local); - - if (asset.Type == (int)AssetType.Texture) + if (!m_memcache.Contains(asset.FullID)) { - if (!Textures.ContainsKey(asset.FullID)) + m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); + // Use 24 hour rolling asset cache. + m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); + + // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the + // information is stored locally. It could disappear, in which case we could send the + // ImageNotInDatabase packet to tell the client this. + // + // However, this doesn't quite appear to work with local textures that are part of an avatar's + // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake + // and reupload by the client, if those assets aren't pushed to the asset server anyway, then + // on crossing onto another region server, other avatars can no longer get the required textures. + // There doesn't appear to be any signal from the sim to the newly region border crossed client + // asking it to reupload its local texture assets to that region server. + // + // One can think of other cunning ways around this. For instance, on a region crossing or teleport, + // the original sim could squirt local assets to the new sim. Or the new sim could have pointers + // to the original sim to fetch the 'local' assets (this is getting more complicated). + // + // But for now, we're going to take the easy way out and store local assets globally. + // + // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. + if (!asset.Temporary || asset.Local) { - TextureImage textur = new TextureImage(asset); - Textures.Add(textur.FullID, textur); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddTexture(textur); - - // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the - // information is stored locally. It could disappear, in which case we could send the - // ImageNotInDatabase packet to tell the client this. - // - // However, this doesn't quite appear to work with local textures that are part of an avatar's - // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake - // and reupload by the client, if those assets aren't pushed to the asset server anyway, then - // on crossing onto another region server, other avatars can no longer get the required textures. - // There doesn't appear to be any signal from the sim to the newly region border crossed client - // asking it to reupload its local texture assets to that region server. - // - // One can think of other cunning ways around this. For instance, on a region crossing or teleport, - // the original sim could squirt local assets to the new sim. Or the new sim could have pointers - // to the original sim to fetch the 'local' assets (this is getting more complicated). - // - // But for now, we're going to take the easy way out and store local assets globally. - // - // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. - if (!asset.Temporary || asset.Local) - { - m_assetServer.StoreAsset(asset); - } + m_assetServer.StoreAsset(asset); } -// else -// { -// m_log.DebugFormat("[ASSET CACHE]: Textures already contains {0}", asset.ID); -// } - } - else - { - if (!Assets.ContainsKey(asset.FullID)) - { - AssetInfo assetInf = new AssetInfo(asset); - Assets.Add(assetInf.FullID, assetInf); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAsset(assetInf); - - // See comment above. - if (!asset.Temporary || asset.Local) - { - m_assetServer.StoreAsset(asset); - } - } -// else -// { -// m_log.DebugFormat("[ASSET CACHE]: Assets already contains {0}", asset.ID); -// } } } @@ -417,71 +337,46 @@ namespace OpenSim.Framework.Communications.Cache // in the 2 caches differently. Also, locks are probably // needed in all of this, or move to synchronized non // generic forms for Dictionaries. - if (Textures.ContainsKey(uuid)) - { - Textures.Remove(uuid); - } - else if (Assets.ContainsKey(uuid)) + if(m_memcache.Contains(uuid)) { - Assets.Remove(uuid); + m_memcache.Remove(uuid); } } // See IAssetReceiver public void AssetReceived(AssetBase asset, bool IsTexture) { -// m_log.DebugFormat("[ASSET CACHE]: Received asset {0}", asset.ID); - - //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); - if (!Textures.ContainsKey(image.FullID)) - { - Textures.Add(image.FullID, image); - if (StatsManager.SimExtraStats != null) - { - StatsManager.SimExtraStats.AddTexture(image); - } - } - } - else + AssetInfo assetInf = new AssetInfo(asset); + if (!m_memcache.Contains(assetInf.FullID)) { - AssetInfo assetInf = new AssetInfo(asset); - if (!Assets.ContainsKey(assetInf.FullID)) - { - Assets.Add(assetInf.FullID, assetInf); + m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); - if (StatsManager.SimExtraStats != null) - { - StatsManager.SimExtraStats.AddAsset(assetInf); - } + if (StatsManager.SimExtraStats != null) + { + StatsManager.SimExtraStats.AddAsset(assetInf); + } - if (RequestedAssets.ContainsKey(assetInf.FullID)) - { - AssetRequest req = RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - req.NumPackets = CalculateNumPackets(assetInf.Data); - - RequestedAssets.Remove(assetInf.FullID); - // If it's a direct request for a script, drop it - // because it's a hacked client - if (req.AssetRequestSource != 2 || assetInf.Type != 10) - AssetRequests.Add(req); - } + if (RequestedAssets.ContainsKey(assetInf.FullID)) + { + AssetRequest req = RequestedAssets[assetInf.FullID]; + req.AssetInf = assetInf; + req.NumPackets = CalculateNumPackets(assetInf.Data); + + RequestedAssets.Remove(assetInf.FullID); + // If it's a direct request for a script, drop it + // because it's a hacked client + if (req.AssetRequestSource != 2 || assetInf.Type != 10) + AssetRequests.Add(req); } } // Notify requesters for this asset - AssetRequestsList reqList = null; - + AssetRequestsList reqList; + lock (RequestLists) - { - if (RequestLists.TryGetValue(asset.FullID, out reqList)) + { + if (RequestLists.TryGetValue(asset.FullID, out reqList)) RequestLists.Remove(asset.FullID); } @@ -489,7 +384,7 @@ namespace OpenSim.Framework.Communications.Cache { if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); - + foreach (NewAssetRequest req in reqList.Requests) { // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked @@ -504,17 +399,8 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); - if (IsTexture) - { - Textures[assetID] = null; - } - else - { - Assets[assetID] = null; - } - // Notify requesters for this asset - AssetRequestsList reqList = null; + AssetRequestsList reqList; lock (RequestLists) { if (RequestLists.TryGetValue(assetID, out reqList)) @@ -578,7 +464,7 @@ namespace OpenSim.Framework.Communications.Cache //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); - if (!Assets.ContainsKey(requestID)) + if (!m_memcache.Contains(requestID)) { //not found asset // so request from asset server @@ -598,7 +484,7 @@ namespace OpenSim.Framework.Communications.Cache } // It has an entry in our cache - AssetInfo asset = Assets[requestID]; + AssetInfo asset = (AssetInfo)m_memcache[requestID]; // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. if (null == asset) -- cgit v1.1 From e0498e1638e1d0aff7c571fc05bf4a5969a681bc Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 9 Nov 2008 23:05:08 +0000 Subject: * Fixed asset bug. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0581cc6..9ec5a98 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -484,7 +484,7 @@ namespace OpenSim.Framework.Communications.Cache } // It has an entry in our cache - AssetInfo asset = (AssetInfo)m_memcache[requestID]; + AssetBase asset = (AssetBase)m_memcache[requestID]; // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. if (null == asset) @@ -504,7 +504,7 @@ namespace OpenSim.Framework.Communications.Cache req.TransferRequestID = transferRequest.TransferInfo.TransferID; req.AssetRequestSource = source; req.Params = transferRequest.TransferInfo.Params; - req.AssetInf = asset; + req.AssetInf = new AssetInfo(asset); req.NumPackets = CalculateNumPackets(asset.Data); AssetRequests.Add(req); } -- cgit v1.1 From 5276c4bdf81a7d0f0ff12f8573a9cbe51cdda8aa Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 11 Nov 2008 00:52:47 +0000 Subject: Update svn properties, minor formatting cleanup. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 9ec5a98..d988032 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -177,7 +177,7 @@ namespace OpenSim.Framework.Communications.Cache public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { Object tmp; - if(m_memcache.TryGet(assetId, out tmp)) + if (m_memcache.TryGet(assetId, out tmp)) { asset = (AssetBase)tmp; //m_log.Info("Retrieved from cache " + assetId); @@ -337,7 +337,7 @@ namespace OpenSim.Framework.Communications.Cache // in the 2 caches differently. Also, locks are probably // needed in all of this, or move to synchronized non // generic forms for Dictionaries. - if(m_memcache.Contains(uuid)) + if (m_memcache.Contains(uuid)) { m_memcache.Remove(uuid); } -- cgit v1.1 From 1493f7349ff60ff4477d40910c6632d6749cb186 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 11 Nov 2008 17:48:36 +0000 Subject: * Minor typing fixes in AssetCache - now uses base types for nearly everything. * Code Cleanliness Fixes in LLClientView * Using field instead of local variable for handlerUpdatePrimGroupRotation (if you notice any new oddities with prim group rotation after this patch, please mantis) --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d988032..fe25eca 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -193,6 +193,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// + /// /// A callback invoked when the asset has either been found or not found. /// If the asset was found this is called with the asset UUID and the asset data /// If the asset was not found this is still called with the asset UUID but with a null asset data reference @@ -260,7 +261,7 @@ namespace OpenSim.Framework.Communications.Cache { // I'm not going over 3 seconds since this will be blocking processing of all the other inbound // packets from the client. - int pollPeriod = 200; + const int pollPeriod = 200; int maxPolls = 15; AssetBase asset; @@ -528,18 +529,18 @@ namespace OpenSim.Framework.Communications.Cache AssetRequestToClient req2 = null; for (int i = 0; i < num; i++) { - req = (AssetRequest)AssetRequests[i]; + req = AssetRequests[i]; if (req2 == null) { req2 = new AssetRequestToClient(); } // Trying to limit memory usage by only creating AssetRequestToClient if needed //req2 = new AssetRequestToClient(); - req2.AssetInf = (AssetBase)req.AssetInf; + req2.AssetInf = req.AssetInf; req2.AssetRequestSource = req.AssetRequestSource; req2.DataPointer = req.DataPointer; req2.DiscardLevel = req.DiscardLevel; - req2.ImageInfo = (AssetBase)req.ImageInfo; + req2.ImageInfo = req.ImageInfo; req2.IsTextureRequest = req.IsTextureRequest; req2.NumPackets = req.NumPackets; req2.PacketCounter = req.PacketCounter; -- cgit v1.1 From 50e3eb31b0c2479e0fa7511aff879426b893a35d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 11 Nov 2008 17:54:21 +0000 Subject: * Restore storing null to represent 'missing asset' requests in the AssetCache * If we don't do this then callers to the polling GetAsset wait the full polling time before returning --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index fe25eca..9945829 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -245,15 +245,13 @@ namespace OpenSim.Framework.Communications.Cache /// /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to /// load it into the cache. + /// /// /// XXX We'll keep polling the cache until we get the asset or we exceed /// the allowed number of polls. This isn't a very good way of doing things since a single thread /// is processing inbound packets, so if the asset server is slow, we could block this for up to - /// the timeout period. What we might want to do is register asynchronous callbacks on asset - /// receipt in the same manner as the TextureDownloadModule. Of course, - /// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the - /// asset is much more likely to have made it into the cache. - /// + /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() + /// /// /// /// null if the asset could not be retrieved @@ -270,6 +268,7 @@ namespace OpenSim.Framework.Communications.Cache { return asset; } + m_assetServer.RequestAsset(assetID, isTexture); do @@ -280,7 +279,8 @@ namespace OpenSim.Framework.Communications.Cache { return asset; } - } while (--maxPolls > 0); + } + while (--maxPolls > 0); m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", isTexture ? "texture" : "asset", assetID.ToString()); @@ -400,6 +400,9 @@ namespace OpenSim.Framework.Communications.Cache { // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + // Remember the fact that this asset could not be found to prevent delays from repeated requests + m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); + // Notify requesters for this asset AssetRequestsList reqList; lock (RequestLists) -- cgit v1.1 From 78d42a7fc8e17a289a559c5977d7b0959cbccd23 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sun, 16 Nov 2008 21:32:10 +0000 Subject: - Fix a formatting error in a log message (Mantis#2635). --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 9945829..436f175 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void ShowState() { - m_log.InfoFormat("Memcache:{1} RequestLists:{2}", + m_log.InfoFormat("Memcache:{0} RequestLists:{1}", m_memcache.Count, // AssetRequests.Count, // RequestedAssets.Count, -- cgit v1.1 From c25a0ea7923aa390d30b8eebdbca4e599edf9b0d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 17 Nov 2008 21:00:34 +0000 Subject: * Update libOMV to r2359. This is necessary for the progressive texture patch * Update libopenjpeg as well for this patch. * Appears to be okay on a very short sniff test * Source code will be placed in opensim-libs shortly --- .../Framework/Communications/Capabilities/Caps.cs | 16 +-- .../Communications/Capabilities/LLSDArray.cs | 4 +- .../Capabilities/LLSDAssetUploadRequest.cs | 2 +- .../Capabilities/LLSDAssetUploadResponse.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 22 ++-- .../Capabilities/LLSDInventoryItem.cs | 16 +-- .../Communications/Capabilities/LLSDItemUpdate.cs | 2 +- .../Communications/Capabilities/LLSDMapLayer.cs | 4 +- .../Capabilities/LLSDMapLayerResponse.cs | 2 +- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 4 +- .../LLSDTaskInventoryUploadComplete.cs | 2 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 2 +- .../Communications/Capabilities/LLSDType.cs | 4 +- .../Capabilities/LLSDVoiceAccountResponse.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 126 ++++++++++----------- OpenSim/Framework/Communications/LoginService.cs | 8 +- .../Framework/Communications/UserManagerBase.cs | 2 +- 19 files changed, 112 insertions(+), 112 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 28e56da..b4a0473 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.Warn("[SEED]: " + capsBase + m_requestPath); //m_capsHandlers["MapLayer"] = - // new LLSDStreamhandler("POST", + // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, // GetMapLayer); m_capsHandlers["NewFileAgentInventory"] = @@ -297,7 +297,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable inventoryhash = (Hashtable)foldersrequested[i]; LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - LLSDHelpers.DeserialiseLLSDMap(inventoryhash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); @@ -431,7 +431,7 @@ namespace OpenSim.Framework.Communications.Capabilities { m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); + mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return mapResponse; } @@ -439,9 +439,9 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - protected static LLSDMapLayer GetLLSDMapLayerResponse() + protected static OSDMapLayer GetOSDMapLayerResponse() { - LLSDMapLayer mapLayer = new LLSDMapLayer(); + OSDMapLayer mapLayer = new OSDMapLayer(); mapLayer.Right = 5000; mapLayer.Top = 5000; mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); @@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); @@ -600,10 +600,10 @@ namespace OpenSim.Framework.Communications.Capabilities OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); - //OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); + //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 3579cc2..668ca79 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -30,11 +30,11 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("ARRAY")] - public class LLSDArray + public class OSDArray { public ArrayList Array = new ArrayList(); - public LLSDArray() + public OSDArray() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 5833b65..16547d5 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDAssetUploadRequest { public string asset_type = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 63b3351..04e9ed7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -29,7 +29,7 @@ using System; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDAssetUploadResponse { public string uploader = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index 5ff21b8..d8a6265 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDCapEvent { public int id = 0; - public LLSDArray events = new LLSDArray(); + public OSDArray events = new OSDArray(); public LLSDCapEvent() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index b14bfdd..ae4a3db 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Capabilities XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.None; writer.WriteStartElement(String.Empty, "llsd", String.Empty); - SerializeLLSDType(writer, obj); + SerializeOSDType(writer, obj); writer.WriteEndElement(); writer.Close(); @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications.Capabilities return sw.ToString(); } - private static void SerializeLLSDType(XmlTextWriter writer, object obj) + private static void SerializeOSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Communications.Capabilities fieldName = fieldName.Replace("___", "-"); writer.WriteString(fieldName); writer.WriteEndElement(); - SerializeLLSDType(writer, fieldValue); + SerializeOSDType(writer, fieldValue); } else { @@ -87,13 +87,13 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.LLSD.FromObject(fieldValue)); + // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); } } writer.WriteEndElement(); break; case "ARRAY": - // LLSDArray arrayObject = obj as LLSDArray; + // OSDArray arrayObject = obj as OSDArray; // ArrayList a = arrayObject.Array; ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); if (a != null) @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteStartElement(String.Empty, "array", String.Empty); foreach (object item in a) { - SerializeLLSDType(writer, item); + SerializeOSDType(writer, item); } writer.WriteEndElement(); } @@ -112,11 +112,11 @@ namespace OpenSim.Framework.Communications.Capabilities { LLSD.LLSDWriteOne(writer, obj); //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.LLSD.FromObject(obj)); + // writer, OpenMetaverse.StructuredData.OSD.FromObject(obj)); } } - public static object DeserialiseLLSDMap(Hashtable llsd, object obj) + public static object DeserialiseOSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -133,12 +133,12 @@ namespace OpenSim.Framework.Communications.Capabilities FieldInfo field = myType.GetField(keyName); if (field != null) { - // if (enumerator.Value is OpenMetaverse.StructuredData.LLSDMap) + // if (enumerator.Value is OpenMetaverse.StructuredData.OSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); - // DeserialiseLLSDMap((OpenMetaverse.StructuredData.LLSDMap) enumerator.Value, fieldValue); + DeserialiseOSDMap((Hashtable) enumerator.Value, fieldValue); + // DeserialiseOSDMap((OpenMetaverse.StructuredData.OSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index ff36821..3651513 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDInventoryItem { public UUID parent_id; @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int created_at; } - [LLSDMap] + [OSDMap] public class LLSDPermissions { public UUID creator_id; @@ -61,20 +61,20 @@ namespace OpenSim.Framework.Communications.Capabilities public bool is_owner_group; } - [LLSDMap] + [OSDMap] public class LLSDSaleInfo { public int sale_price; public string sale_type; } - [LLSDMap] + [OSDMap] public class LLSDInventoryDescendents { - public LLSDArray folders = new LLSDArray(); + public OSDArray folders = new OSDArray(); } - [LLSDMap] + [OSDMap] public class LLSDFetchInventoryDescendents { public UUID folder_id; @@ -84,13 +84,13 @@ namespace OpenSim.Framework.Communications.Capabilities public bool fetch_items; } - [LLSDMap] + [OSDMap] public class LLSDInventoryFolderContents { public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" public int descendents; public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names - public LLSDArray items = new LLSDArray(); + public OSDArray items = new OSDArray(); public UUID owner___id; // and of course we can't have field names with "-" in public int version; } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index c147bd3..4568732 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDItemUpdate { public UUID item_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index fc381e4..356fa5e 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] - public class LLSDMapLayer + public class OSDMapLayer { public int Left = 0; public int Right = 0; @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int Bottom = 0; public UUID ImageID = UUID.Zero; - public LLSDMapLayer() + public OSDMapLayer() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 7dabbec..26815f9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDMapLayerResponse { public LLSDMapRequest AgentData = new LLSDMapRequest(); - public LLSDArray LayerData = new LLSDArray(); + public OSDArray LayerData = new OSDArray(); public LLSDMapLayerResponse() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index c045dcf..829a2a9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -30,7 +30,7 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDParcelVoiceInfoResponse { public int parcel_local_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 7fcbb81..c68a205 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -53,12 +53,12 @@ namespace OpenSim.Framework.Communications.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap) + // OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap) // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); TResponse response = m_method(llsdRequest); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index b34cbf9..bcea657 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDTaskInventoryUploadComplete { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 730e95b..7401768 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDTaskScriptUpdate { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 181a465..949e119 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -46,9 +46,9 @@ namespace OpenSim.Framework.Communications.Capabilities } [AttributeUsage(AttributeTargets.Class)] - public class LLSDMap : LLSDType + public class OSDMap : LLSDType { - public LLSDMap() : base("MAP") + public OSDMap() : base("MAP") { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 8143233..6cd5ee3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -28,7 +28,7 @@ namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDVoiceAccountResponse { public string username; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b2565b1..867e9e6 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -201,17 +201,17 @@ namespace OpenSim.Framework.Communications return (xmlRpcResponse); } - public LLSD GenerateFailureResponseLLSD(string reason, string message, string login) + public OSD GenerateFailureResponseLLSD(string reason, string message, string login) { - LLSDMap map = new LLSDMap(); + OSDMap map = new OSDMap(); // Ensure Login Failed message/reason; ErrorMessage = message; ErrorReason = reason; - map["reason"] = LLSD.FromString(ErrorReason); - map["message"] = LLSD.FromString(ErrorMessage); - map["login"] = LLSD.FromString(login); + map["reason"] = OSD.FromString(ErrorReason); + map["message"] = OSD.FromString(ErrorMessage); + map["login"] = OSD.FromString(login); return map; } @@ -221,7 +221,7 @@ namespace OpenSim.Framework.Communications return (CreateLoginFailedResponse()); } - public LLSD CreateFailedResponseLLSD() + public OSD CreateFailedResponseLLSD() { return CreateLoginFailedResponseLLSD(); } @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateLoginFailedResponseLLSD() + public OSD CreateLoginFailedResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -265,7 +265,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateAlreadyLoggedInResponseLLSD() + public OSD CreateAlreadyLoggedInResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateLoginBlockedResponseLLSD() + public OSD CreateLoginBlockedResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -299,7 +299,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateDeadRegionResponseLLSD() + public OSD CreateDeadRegionResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -315,7 +315,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateGridErrorResponseLLSD() + public OSD CreateGridErrorResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -404,90 +404,90 @@ namespace OpenSim.Framework.Communications } } - public LLSD ToLLSDResponse() + public OSD ToLLSDResponse() { try { - LLSDMap map = new LLSDMap(); + OSDMap map = new OSDMap(); - map["first_name"] = LLSD.FromString(Firstname); - map["last_name"] = LLSD.FromString(Lastname); - map["agent_access"] = LLSD.FromString(agentAccess); + map["first_name"] = OSD.FromString(Firstname); + map["last_name"] = OSD.FromString(Lastname); + map["agent_access"] = OSD.FromString(agentAccess); - map["sim_port"] = LLSD.FromInteger(SimPort); - map["sim_ip"] = LLSD.FromString(SimAddress); + map["sim_port"] = OSD.FromInteger(SimPort); + map["sim_ip"] = OSD.FromString(SimAddress); - map["agent_id"] = LLSD.FromUUID(AgentID); - map["session_id"] = LLSD.FromUUID(SessionID); - map["secure_session_id"] = LLSD.FromUUID(SecureSessionID); - map["circuit_code"] = LLSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = LLSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["secure_session_id"] = OSD.FromUUID(SecureSessionID); + map["circuit_code"] = OSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); #region Login Flags - LLSDMap loginFlagsLLSD = new LLSDMap(); - loginFlagsLLSD["daylight_savings"] = LLSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = LLSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = LLSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = LLSD.FromString(EverLoggedIn); - map["login-flags"] = WrapLLSDMap(loginFlagsLLSD); + OSDMap loginFlagsLLSD = new OSDMap(); + loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); + map["login-flags"] = WrapOSDMap(loginFlagsLLSD); #endregion Login Flags #region Global Textures - LLSDMap globalTexturesLLSD = new LLSDMap(); - globalTexturesLLSD["sun_texture_id"] = LLSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = LLSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = LLSD.FromString(MoonTexture); + OSDMap globalTexturesLLSD = new OSDMap(); + globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); - map["global-textures"] = WrapLLSDMap(globalTexturesLLSD); + map["global-textures"] = WrapOSDMap(globalTexturesLLSD); #endregion Global Textures - map["seed_capability"] = LLSD.FromString(seedCapability); + map["seed_capability"] = OSD.FromString(seedCapability); - map["event_categories"] = ArrayListToLLSDArray(eventCategories); - //map["event_notifications"] = new LLSDArray(); // todo - map["classified_categories"] = ArrayListToLLSDArray(classifiedCategories); + map["event_categories"] = ArrayListToOSDArray(eventCategories); + //map["event_notifications"] = new OSDArray(); // todo + map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); #region UI Config - LLSDMap uiConfigLLSD = new LLSDMap(); - uiConfigLLSD["allow_first_life"] = LLSD.FromString(allowFirstLife); - map["ui-config"] = WrapLLSDMap(uiConfigLLSD); + OSDMap uiConfigLLSD = new OSDMap(); + uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); + map["ui-config"] = WrapOSDMap(uiConfigLLSD); #endregion UI Config #region Inventory - map["inventory-skeleton"] = ArrayListToLLSDArray(agentInventory); + map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); - map["inventory-skel-lib"] = ArrayListToLLSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToLLSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToLLSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToLLSDArray(inventoryLibraryOwner); + map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); #endregion Inventory - map["gestures"] = ArrayListToLLSDArray(activeGestures); + map["gestures"] = ArrayListToOSDArray(activeGestures); - map["initial-outfit"] = ArrayListToLLSDArray(initialOutfit); - map["start_location"] = LLSD.FromString(startLocation); + map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); + map["start_location"] = OSD.FromString(startLocation); - map["seed_capability"] = LLSD.FromString(seedCapability); - map["home"] = LLSD.FromString(home); - map["look_at"] = LLSD.FromString(lookAt); - map["message"] = LLSD.FromString(welcomeMessage); - map["region_x"] = LLSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = LLSD.FromInteger(RegionY * Constants.RegionSize); + map["seed_capability"] = OSD.FromString(seedCapability); + map["home"] = OSD.FromString(home); + map["look_at"] = OSD.FromString(lookAt); + map["message"] = OSD.FromString(welcomeMessage); + map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); if (m_buddyList != null) { - map["buddy-list"] = ArrayListToLLSDArray(m_buddyList.ToArray()); + map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); } - map["login"] = LLSD.FromString("true"); + map["login"] = OSD.FromString("true"); return map; } @@ -499,24 +499,24 @@ namespace OpenSim.Framework.Communications } } - public LLSDArray ArrayListToLLSDArray(ArrayList arrlst) + public OSDArray ArrayListToOSDArray(ArrayList arrlst) { - LLSDArray llsdBack = new LLSDArray(); + OSDArray llsdBack = new OSDArray(); foreach (Hashtable ht in arrlst) { - LLSDMap mp = new LLSDMap(); + OSDMap mp = new OSDMap(); foreach (DictionaryEntry deHt in ht) { - mp.Add((string)deHt.Key, LLSDString.FromObject(deHt.Value)); + mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); } llsdBack.Add(mp); } return llsdBack; } - private static LLSDArray WrapLLSDMap(LLSDMap wrapMe) + private static OSDArray WrapOSDMap(OSDMap wrapMe) { - LLSDArray array = new LLSDArray(); + OSDArray array = new OSDArray(); array.Add(wrapMe); return array; } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7a657b5..c569a71 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -321,7 +321,7 @@ namespace OpenSim.Framework.Communications /// /// The LLSD request /// The response to send - public LLSD LLSDLoginMethod(LLSD request) + public OSD LLSDLoginMethod(OSD request) { // Temporary fix m_loginMutex.WaitOne(); @@ -335,9 +335,9 @@ namespace OpenSim.Framework.Communications UserProfileData userProfile = null; LoginResponse logResponse = new LoginResponse(); - if (request.Type == LLSDType.Map) + if (request.Type == OSDType.Map) { - LLSDMap map = (LLSDMap)request; + OSDMap map = (OSDMap)request; if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) { @@ -749,7 +749,7 @@ namespace OpenSim.Framework.Communications m_userManager.CreateAgent(profile, request); } - public void CreateAgent(UserProfileData profile, LLSD request) + public void CreateAgent(UserProfileData profile, OSD request) { m_userManager.CreateAgent(profile, request); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 7189eee..4b5d2bb 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -448,7 +448,7 @@ namespace OpenSim.Framework.Communications profile.CurrentAgent = agent; } - public void CreateAgent(UserProfileData profile, LLSD request) + public void CreateAgent(UserProfileData profile, OSD request) { UserAgentData agent = new UserAgentData(); -- cgit v1.1 From 434afaf717eef01f26b6b95ba8b4ae50fc470a4c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 18 Nov 2008 00:47:30 +0000 Subject: * Added and removed debug information relating to client connections * Minor client fixes * Added the ability for a client to login without a UserProfile, allowing certain alternate clients to connect to the region. --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index c569a71..b4ee069 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -166,7 +166,7 @@ namespace OpenSim.Framework.Communications } else if (requestData.Contains("web_login_key")) { - UUID webloginkey = UUID.Zero; + UUID webloginkey; try { webloginkey = new UUID((string)requestData["web_login_key"]); -- cgit v1.1 From 0abb762ecc3b87e210ffb7009bdddf8a1a159419 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 18 Nov 2008 20:02:25 +0000 Subject: Patch from jhurliman. Fixing the texture decoding issues in progressive texture sending. Grain of salt not included. --- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 44c4a05..e754256 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -561,7 +561,7 @@ namespace OpenSim.Framework.Communications.Capabilities endPos = FindEnd(llsd, 1); if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, - Helpers.EnUsCulture.NumberFormat, out value)) + Utils.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); -- cgit v1.1 From 3234472d6203671a492a73042a0b56d6301903e0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 19 Nov 2008 06:15:21 +0000 Subject: Reverting the texture sending patch and the new libOMV. This makes this release a direct descendant of the stable 7364, with all the features and none of the issues. This omits the following patch chain: r7383 r7382 r7381 r7377 r7375 r7373 r7372 r7370 r7369 r7368 r7367 r7366 --- .../Framework/Communications/Capabilities/Caps.cs | 16 +-- .../Framework/Communications/Capabilities/LLSD.cs | 2 +- .../Communications/Capabilities/LLSDArray.cs | 4 +- .../Capabilities/LLSDAssetUploadRequest.cs | 2 +- .../Capabilities/LLSDAssetUploadResponse.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 22 ++-- .../Capabilities/LLSDInventoryItem.cs | 16 +-- .../Communications/Capabilities/LLSDItemUpdate.cs | 2 +- .../Communications/Capabilities/LLSDMapLayer.cs | 4 +- .../Capabilities/LLSDMapLayerResponse.cs | 2 +- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 4 +- .../LLSDTaskInventoryUploadComplete.cs | 2 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 2 +- .../Communications/Capabilities/LLSDType.cs | 4 +- .../Capabilities/LLSDVoiceAccountResponse.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 126 ++++++++++----------- OpenSim/Framework/Communications/LoginService.cs | 8 +- .../Framework/Communications/UserManagerBase.cs | 2 +- 20 files changed, 113 insertions(+), 113 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index b4a0473..28e56da 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.Warn("[SEED]: " + capsBase + m_requestPath); //m_capsHandlers["MapLayer"] = - // new LLSDStreamhandler("POST", + // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, // GetMapLayer); m_capsHandlers["NewFileAgentInventory"] = @@ -297,7 +297,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable inventoryhash = (Hashtable)foldersrequested[i]; LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); + LLSDHelpers.DeserialiseLLSDMap(inventoryhash, llsdRequest); LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); @@ -431,7 +431,7 @@ namespace OpenSim.Framework.Communications.Capabilities { m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); + mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); return mapResponse; } @@ -439,9 +439,9 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - protected static OSDMapLayer GetOSDMapLayerResponse() + protected static LLSDMapLayer GetLLSDMapLayerResponse() { - OSDMapLayer mapLayer = new OSDMapLayer(); + LLSDMapLayer mapLayer = new LLSDMapLayer(); mapLayer.Right = 5000; mapLayer.Top = 5000; mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); @@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); @@ -600,10 +600,10 @@ namespace OpenSim.Framework.Communications.Capabilities OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); - //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); + //OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); - LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index e754256..44c4a05 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -561,7 +561,7 @@ namespace OpenSim.Framework.Communications.Capabilities endPos = FindEnd(llsd, 1); if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, - Utils.EnUsCulture.NumberFormat, out value)) + Helpers.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 668ca79..3579cc2 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -30,11 +30,11 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("ARRAY")] - public class OSDArray + public class LLSDArray { public ArrayList Array = new ArrayList(); - public OSDArray() + public LLSDArray() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 16547d5..5833b65 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDAssetUploadRequest { public string asset_type = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 04e9ed7..63b3351 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -29,7 +29,7 @@ using System; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDAssetUploadResponse { public string uploader = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index d8a6265..5ff21b8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDCapEvent { public int id = 0; - public OSDArray events = new OSDArray(); + public LLSDArray events = new LLSDArray(); public LLSDCapEvent() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index ae4a3db..b14bfdd 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Capabilities XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.None; writer.WriteStartElement(String.Empty, "llsd", String.Empty); - SerializeOSDType(writer, obj); + SerializeLLSDType(writer, obj); writer.WriteEndElement(); writer.Close(); @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications.Capabilities return sw.ToString(); } - private static void SerializeOSDType(XmlTextWriter writer, object obj) + private static void SerializeLLSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Communications.Capabilities fieldName = fieldName.Replace("___", "-"); writer.WriteString(fieldName); writer.WriteEndElement(); - SerializeOSDType(writer, fieldValue); + SerializeLLSDType(writer, fieldValue); } else { @@ -87,13 +87,13 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); + // writer, OpenMetaverse.StructuredData.LLSD.FromObject(fieldValue)); } } writer.WriteEndElement(); break; case "ARRAY": - // OSDArray arrayObject = obj as OSDArray; + // LLSDArray arrayObject = obj as LLSDArray; // ArrayList a = arrayObject.Array; ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); if (a != null) @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteStartElement(String.Empty, "array", String.Empty); foreach (object item in a) { - SerializeOSDType(writer, item); + SerializeLLSDType(writer, item); } writer.WriteEndElement(); } @@ -112,11 +112,11 @@ namespace OpenSim.Framework.Communications.Capabilities { LLSD.LLSDWriteOne(writer, obj); //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.OSD.FromObject(obj)); + // writer, OpenMetaverse.StructuredData.LLSD.FromObject(obj)); } } - public static object DeserialiseOSDMap(Hashtable llsd, object obj) + public static object DeserialiseLLSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -133,12 +133,12 @@ namespace OpenSim.Framework.Communications.Capabilities FieldInfo field = myType.GetField(keyName); if (field != null) { - // if (enumerator.Value is OpenMetaverse.StructuredData.OSDMap) + // if (enumerator.Value is OpenMetaverse.StructuredData.LLSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseOSDMap((Hashtable) enumerator.Value, fieldValue); - // DeserialiseOSDMap((OpenMetaverse.StructuredData.OSDMap) enumerator.Value, fieldValue); + DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); + // DeserialiseLLSDMap((OpenMetaverse.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 3651513..ff36821 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDInventoryItem { public UUID parent_id; @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int created_at; } - [OSDMap] + [LLSDMap] public class LLSDPermissions { public UUID creator_id; @@ -61,20 +61,20 @@ namespace OpenSim.Framework.Communications.Capabilities public bool is_owner_group; } - [OSDMap] + [LLSDMap] public class LLSDSaleInfo { public int sale_price; public string sale_type; } - [OSDMap] + [LLSDMap] public class LLSDInventoryDescendents { - public OSDArray folders = new OSDArray(); + public LLSDArray folders = new LLSDArray(); } - [OSDMap] + [LLSDMap] public class LLSDFetchInventoryDescendents { public UUID folder_id; @@ -84,13 +84,13 @@ namespace OpenSim.Framework.Communications.Capabilities public bool fetch_items; } - [OSDMap] + [LLSDMap] public class LLSDInventoryFolderContents { public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" public int descendents; public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names - public OSDArray items = new OSDArray(); + public LLSDArray items = new LLSDArray(); public UUID owner___id; // and of course we can't have field names with "-" in public int version; } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 4568732..c147bd3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDItemUpdate { public UUID item_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 356fa5e..fc381e4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] - public class OSDMapLayer + public class LLSDMapLayer { public int Left = 0; public int Right = 0; @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int Bottom = 0; public UUID ImageID = UUID.Zero; - public OSDMapLayer() + public LLSDMapLayer() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 26815f9..7dabbec 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDMapLayerResponse { public LLSDMapRequest AgentData = new LLSDMapRequest(); - public OSDArray LayerData = new OSDArray(); + public LLSDArray LayerData = new LLSDArray(); public LLSDMapLayerResponse() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index 829a2a9..c045dcf 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -30,7 +30,7 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDParcelVoiceInfoResponse { public int parcel_local_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index c68a205..7fcbb81 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -53,12 +53,12 @@ namespace OpenSim.Framework.Communications.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap) + // OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap) // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); - LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); TResponse response = m_method(llsdRequest); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index bcea657..b34cbf9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDTaskInventoryUploadComplete { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 7401768..730e95b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDTaskScriptUpdate { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 949e119..181a465 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -46,9 +46,9 @@ namespace OpenSim.Framework.Communications.Capabilities } [AttributeUsage(AttributeTargets.Class)] - public class OSDMap : LLSDType + public class LLSDMap : LLSDType { - public OSDMap() : base("MAP") + public LLSDMap() : base("MAP") { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 6cd5ee3..8143233 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -28,7 +28,7 @@ namespace OpenSim.Framework.Communications.Capabilities { - [OSDMap] + [LLSDMap] public class LLSDVoiceAccountResponse { public string username; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 867e9e6..b2565b1 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -201,17 +201,17 @@ namespace OpenSim.Framework.Communications return (xmlRpcResponse); } - public OSD GenerateFailureResponseLLSD(string reason, string message, string login) + public LLSD GenerateFailureResponseLLSD(string reason, string message, string login) { - OSDMap map = new OSDMap(); + LLSDMap map = new LLSDMap(); // Ensure Login Failed message/reason; ErrorMessage = message; ErrorReason = reason; - map["reason"] = OSD.FromString(ErrorReason); - map["message"] = OSD.FromString(ErrorMessage); - map["login"] = OSD.FromString(login); + map["reason"] = LLSD.FromString(ErrorReason); + map["message"] = LLSD.FromString(ErrorMessage); + map["login"] = LLSD.FromString(login); return map; } @@ -221,7 +221,7 @@ namespace OpenSim.Framework.Communications return (CreateLoginFailedResponse()); } - public OSD CreateFailedResponseLLSD() + public LLSD CreateFailedResponseLLSD() { return CreateLoginFailedResponseLLSD(); } @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications "false")); } - public OSD CreateLoginFailedResponseLLSD() + public LLSD CreateLoginFailedResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -265,7 +265,7 @@ namespace OpenSim.Framework.Communications "false")); } - public OSD CreateAlreadyLoggedInResponseLLSD() + public LLSD CreateAlreadyLoggedInResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Communications "false")); } - public OSD CreateLoginBlockedResponseLLSD() + public LLSD CreateLoginBlockedResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -299,7 +299,7 @@ namespace OpenSim.Framework.Communications "false")); } - public OSD CreateDeadRegionResponseLLSD() + public LLSD CreateDeadRegionResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -315,7 +315,7 @@ namespace OpenSim.Framework.Communications "false")); } - public OSD CreateGridErrorResponseLLSD() + public LLSD CreateGridErrorResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -404,90 +404,90 @@ namespace OpenSim.Framework.Communications } } - public OSD ToLLSDResponse() + public LLSD ToLLSDResponse() { try { - OSDMap map = new OSDMap(); + LLSDMap map = new LLSDMap(); - map["first_name"] = OSD.FromString(Firstname); - map["last_name"] = OSD.FromString(Lastname); - map["agent_access"] = OSD.FromString(agentAccess); + map["first_name"] = LLSD.FromString(Firstname); + map["last_name"] = LLSD.FromString(Lastname); + map["agent_access"] = LLSD.FromString(agentAccess); - map["sim_port"] = OSD.FromInteger(SimPort); - map["sim_ip"] = OSD.FromString(SimAddress); + map["sim_port"] = LLSD.FromInteger(SimPort); + map["sim_ip"] = LLSD.FromString(SimAddress); - map["agent_id"] = OSD.FromUUID(AgentID); - map["session_id"] = OSD.FromUUID(SessionID); - map["secure_session_id"] = OSD.FromUUID(SecureSessionID); - map["circuit_code"] = OSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + map["agent_id"] = LLSD.FromUUID(AgentID); + map["session_id"] = LLSD.FromUUID(SessionID); + map["secure_session_id"] = LLSD.FromUUID(SecureSessionID); + map["circuit_code"] = LLSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = LLSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); #region Login Flags - OSDMap loginFlagsLLSD = new OSDMap(); - loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); - map["login-flags"] = WrapOSDMap(loginFlagsLLSD); + LLSDMap loginFlagsLLSD = new LLSDMap(); + loginFlagsLLSD["daylight_savings"] = LLSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = LLSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = LLSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = LLSD.FromString(EverLoggedIn); + map["login-flags"] = WrapLLSDMap(loginFlagsLLSD); #endregion Login Flags #region Global Textures - OSDMap globalTexturesLLSD = new OSDMap(); - globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); + LLSDMap globalTexturesLLSD = new LLSDMap(); + globalTexturesLLSD["sun_texture_id"] = LLSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = LLSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = LLSD.FromString(MoonTexture); - map["global-textures"] = WrapOSDMap(globalTexturesLLSD); + map["global-textures"] = WrapLLSDMap(globalTexturesLLSD); #endregion Global Textures - map["seed_capability"] = OSD.FromString(seedCapability); + map["seed_capability"] = LLSD.FromString(seedCapability); - map["event_categories"] = ArrayListToOSDArray(eventCategories); - //map["event_notifications"] = new OSDArray(); // todo - map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); + map["event_categories"] = ArrayListToLLSDArray(eventCategories); + //map["event_notifications"] = new LLSDArray(); // todo + map["classified_categories"] = ArrayListToLLSDArray(classifiedCategories); #region UI Config - OSDMap uiConfigLLSD = new OSDMap(); - uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); - map["ui-config"] = WrapOSDMap(uiConfigLLSD); + LLSDMap uiConfigLLSD = new LLSDMap(); + uiConfigLLSD["allow_first_life"] = LLSD.FromString(allowFirstLife); + map["ui-config"] = WrapLLSDMap(uiConfigLLSD); #endregion UI Config #region Inventory - map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); + map["inventory-skeleton"] = ArrayListToLLSDArray(agentInventory); - map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); + map["inventory-skel-lib"] = ArrayListToLLSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToLLSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToLLSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToLLSDArray(inventoryLibraryOwner); #endregion Inventory - map["gestures"] = ArrayListToOSDArray(activeGestures); + map["gestures"] = ArrayListToLLSDArray(activeGestures); - map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); - map["start_location"] = OSD.FromString(startLocation); + map["initial-outfit"] = ArrayListToLLSDArray(initialOutfit); + map["start_location"] = LLSD.FromString(startLocation); - map["seed_capability"] = OSD.FromString(seedCapability); - map["home"] = OSD.FromString(home); - map["look_at"] = OSD.FromString(lookAt); - map["message"] = OSD.FromString(welcomeMessage); - map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); + map["seed_capability"] = LLSD.FromString(seedCapability); + map["home"] = LLSD.FromString(home); + map["look_at"] = LLSD.FromString(lookAt); + map["message"] = LLSD.FromString(welcomeMessage); + map["region_x"] = LLSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = LLSD.FromInteger(RegionY * Constants.RegionSize); if (m_buddyList != null) { - map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); + map["buddy-list"] = ArrayListToLLSDArray(m_buddyList.ToArray()); } - map["login"] = OSD.FromString("true"); + map["login"] = LLSD.FromString("true"); return map; } @@ -499,24 +499,24 @@ namespace OpenSim.Framework.Communications } } - public OSDArray ArrayListToOSDArray(ArrayList arrlst) + public LLSDArray ArrayListToLLSDArray(ArrayList arrlst) { - OSDArray llsdBack = new OSDArray(); + LLSDArray llsdBack = new LLSDArray(); foreach (Hashtable ht in arrlst) { - OSDMap mp = new OSDMap(); + LLSDMap mp = new LLSDMap(); foreach (DictionaryEntry deHt in ht) { - mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); + mp.Add((string)deHt.Key, LLSDString.FromObject(deHt.Value)); } llsdBack.Add(mp); } return llsdBack; } - private static OSDArray WrapOSDMap(OSDMap wrapMe) + private static LLSDArray WrapLLSDMap(LLSDMap wrapMe) { - OSDArray array = new OSDArray(); + LLSDArray array = new LLSDArray(); array.Add(wrapMe); return array; } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index b4ee069..7fd1c3b 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -321,7 +321,7 @@ namespace OpenSim.Framework.Communications /// /// The LLSD request /// The response to send - public OSD LLSDLoginMethod(OSD request) + public LLSD LLSDLoginMethod(LLSD request) { // Temporary fix m_loginMutex.WaitOne(); @@ -335,9 +335,9 @@ namespace OpenSim.Framework.Communications UserProfileData userProfile = null; LoginResponse logResponse = new LoginResponse(); - if (request.Type == OSDType.Map) + if (request.Type == LLSDType.Map) { - OSDMap map = (OSDMap)request; + LLSDMap map = (LLSDMap)request; if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) { @@ -749,7 +749,7 @@ namespace OpenSim.Framework.Communications m_userManager.CreateAgent(profile, request); } - public void CreateAgent(UserProfileData profile, OSD request) + public void CreateAgent(UserProfileData profile, LLSD request) { m_userManager.CreateAgent(profile, request); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 4b5d2bb..7189eee 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -448,7 +448,7 @@ namespace OpenSim.Framework.Communications profile.CurrentAgent = agent; } - public void CreateAgent(UserProfileData profile, OSD request) + public void CreateAgent(UserProfileData profile, LLSD request) { UserAgentData agent = new UserAgentData(); -- cgit v1.1 From f518ca7feb33c0c1641ccb8f3956246b855f9b6c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 19 Nov 2008 06:25:34 +0000 Subject: Reapply r7369 r7367 r7366 r7370 r7381. This brings it back up to the new libOMV. --- .../Framework/Communications/Capabilities/Caps.cs | 16 +-- .../Communications/Capabilities/LLSDArray.cs | 4 +- .../Capabilities/LLSDAssetUploadRequest.cs | 2 +- .../Capabilities/LLSDAssetUploadResponse.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 22 ++-- .../Capabilities/LLSDInventoryItem.cs | 16 +-- .../Communications/Capabilities/LLSDItemUpdate.cs | 2 +- .../Communications/Capabilities/LLSDMapLayer.cs | 4 +- .../Capabilities/LLSDMapLayerResponse.cs | 2 +- .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 4 +- .../LLSDTaskInventoryUploadComplete.cs | 2 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 2 +- .../Communications/Capabilities/LLSDType.cs | 4 +- .../Capabilities/LLSDVoiceAccountResponse.cs | 2 +- OpenSim/Framework/Communications/LoginResponse.cs | 126 ++++++++++----------- OpenSim/Framework/Communications/LoginService.cs | 8 +- .../Framework/Communications/UserManagerBase.cs | 2 +- 19 files changed, 112 insertions(+), 112 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 28e56da..b4a0473 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.Warn("[SEED]: " + capsBase + m_requestPath); //m_capsHandlers["MapLayer"] = - // new LLSDStreamhandler("POST", + // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, // GetMapLayer); m_capsHandlers["NewFileAgentInventory"] = @@ -297,7 +297,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable inventoryhash = (Hashtable)foldersrequested[i]; LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - LLSDHelpers.DeserialiseLLSDMap(inventoryhash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); @@ -431,7 +431,7 @@ namespace OpenSim.Framework.Communications.Capabilities { m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); + mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); return mapResponse; } @@ -439,9 +439,9 @@ namespace OpenSim.Framework.Communications.Capabilities /// /// /// - protected static LLSDMapLayer GetLLSDMapLayerResponse() + protected static OSDMapLayer GetOSDMapLayerResponse() { - LLSDMapLayer mapLayer = new LLSDMapLayer(); + OSDMapLayer mapLayer = new OSDMapLayer(); mapLayer.Right = 5000; mapLayer.Top = 5000; mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); @@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications.Capabilities Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); @@ -600,10 +600,10 @@ namespace OpenSim.Framework.Communications.Capabilities OSHttpRequest httpRequest, OSHttpResponse httpResponse) { m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); - //OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); + //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 3579cc2..668ca79 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -30,11 +30,11 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("ARRAY")] - public class LLSDArray + public class OSDArray { public ArrayList Array = new ArrayList(); - public LLSDArray() + public OSDArray() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 5833b65..16547d5 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDAssetUploadRequest { public string asset_type = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 63b3351..04e9ed7 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -29,7 +29,7 @@ using System; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDAssetUploadResponse { public string uploader = String.Empty; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index 5ff21b8..d8a6265 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDCapEvent { public int id = 0; - public LLSDArray events = new LLSDArray(); + public OSDArray events = new OSDArray(); public LLSDCapEvent() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index b14bfdd..ae4a3db 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Capabilities XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.None; writer.WriteStartElement(String.Empty, "llsd", String.Empty); - SerializeLLSDType(writer, obj); + SerializeOSDType(writer, obj); writer.WriteEndElement(); writer.Close(); @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications.Capabilities return sw.ToString(); } - private static void SerializeLLSDType(XmlTextWriter writer, object obj) + private static void SerializeOSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Communications.Capabilities fieldName = fieldName.Replace("___", "-"); writer.WriteString(fieldName); writer.WriteEndElement(); - SerializeLLSDType(writer, fieldValue); + SerializeOSDType(writer, fieldValue); } else { @@ -87,13 +87,13 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.LLSD.FromObject(fieldValue)); + // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); } } writer.WriteEndElement(); break; case "ARRAY": - // LLSDArray arrayObject = obj as LLSDArray; + // OSDArray arrayObject = obj as OSDArray; // ArrayList a = arrayObject.Array; ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); if (a != null) @@ -101,7 +101,7 @@ namespace OpenSim.Framework.Communications.Capabilities writer.WriteStartElement(String.Empty, "array", String.Empty); foreach (object item in a) { - SerializeLLSDType(writer, item); + SerializeOSDType(writer, item); } writer.WriteEndElement(); } @@ -112,11 +112,11 @@ namespace OpenSim.Framework.Communications.Capabilities { LLSD.LLSDWriteOne(writer, obj); //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.LLSD.FromObject(obj)); + // writer, OpenMetaverse.StructuredData.OSD.FromObject(obj)); } } - public static object DeserialiseLLSDMap(Hashtable llsd, object obj) + public static object DeserialiseOSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); @@ -133,12 +133,12 @@ namespace OpenSim.Framework.Communications.Capabilities FieldInfo field = myType.GetField(keyName); if (field != null) { - // if (enumerator.Value is OpenMetaverse.StructuredData.LLSDMap) + // if (enumerator.Value is OpenMetaverse.StructuredData.OSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); - // DeserialiseLLSDMap((OpenMetaverse.StructuredData.LLSDMap) enumerator.Value, fieldValue); + DeserialiseOSDMap((Hashtable) enumerator.Value, fieldValue); + // DeserialiseOSDMap((OpenMetaverse.StructuredData.OSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index ff36821..3651513 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDInventoryItem { public UUID parent_id; @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int created_at; } - [LLSDMap] + [OSDMap] public class LLSDPermissions { public UUID creator_id; @@ -61,20 +61,20 @@ namespace OpenSim.Framework.Communications.Capabilities public bool is_owner_group; } - [LLSDMap] + [OSDMap] public class LLSDSaleInfo { public int sale_price; public string sale_type; } - [LLSDMap] + [OSDMap] public class LLSDInventoryDescendents { - public LLSDArray folders = new LLSDArray(); + public OSDArray folders = new OSDArray(); } - [LLSDMap] + [OSDMap] public class LLSDFetchInventoryDescendents { public UUID folder_id; @@ -84,13 +84,13 @@ namespace OpenSim.Framework.Communications.Capabilities public bool fetch_items; } - [LLSDMap] + [OSDMap] public class LLSDInventoryFolderContents { public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" public int descendents; public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names - public LLSDArray items = new LLSDArray(); + public OSDArray items = new OSDArray(); public UUID owner___id; // and of course we can't have field names with "-" in public int version; } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index c147bd3..4568732 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDItemUpdate { public UUID item_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index fc381e4..356fa5e 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -30,7 +30,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { [LLSDType("MAP")] - public class LLSDMapLayer + public class OSDMapLayer { public int Left = 0; public int Right = 0; @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.Capabilities public int Bottom = 0; public UUID ImageID = UUID.Zero; - public LLSDMapLayer() + public OSDMapLayer() { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 7dabbec..26815f9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class LLSDMapLayerResponse { public LLSDMapRequest AgentData = new LLSDMapRequest(); - public LLSDArray LayerData = new LLSDArray(); + public OSDArray LayerData = new OSDArray(); public LLSDMapLayerResponse() { diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index c045dcf..829a2a9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -30,7 +30,7 @@ using System.Collections; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDParcelVoiceInfoResponse { public int parcel_local_id; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 7fcbb81..c68a205 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -53,12 +53,12 @@ namespace OpenSim.Framework.Communications.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // OpenMetaverse.StructuredData.LLSDMap hash = (OpenMetaverse.StructuredData.LLSDMap) + // OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap) // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); TResponse response = m_method(llsdRequest); diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index b34cbf9..bcea657 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDTaskInventoryUploadComplete { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 730e95b..7401768 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDTaskScriptUpdate { /// diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 181a465..949e119 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -46,9 +46,9 @@ namespace OpenSim.Framework.Communications.Capabilities } [AttributeUsage(AttributeTargets.Class)] - public class LLSDMap : LLSDType + public class OSDMap : LLSDType { - public LLSDMap() : base("MAP") + public OSDMap() : base("MAP") { } } diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 8143233..6cd5ee3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -28,7 +28,7 @@ namespace OpenSim.Framework.Communications.Capabilities { - [LLSDMap] + [OSDMap] public class LLSDVoiceAccountResponse { public string username; diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index b2565b1..867e9e6 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -201,17 +201,17 @@ namespace OpenSim.Framework.Communications return (xmlRpcResponse); } - public LLSD GenerateFailureResponseLLSD(string reason, string message, string login) + public OSD GenerateFailureResponseLLSD(string reason, string message, string login) { - LLSDMap map = new LLSDMap(); + OSDMap map = new OSDMap(); // Ensure Login Failed message/reason; ErrorMessage = message; ErrorReason = reason; - map["reason"] = LLSD.FromString(ErrorReason); - map["message"] = LLSD.FromString(ErrorMessage); - map["login"] = LLSD.FromString(login); + map["reason"] = OSD.FromString(ErrorReason); + map["message"] = OSD.FromString(ErrorMessage); + map["login"] = OSD.FromString(login); return map; } @@ -221,7 +221,7 @@ namespace OpenSim.Framework.Communications return (CreateLoginFailedResponse()); } - public LLSD CreateFailedResponseLLSD() + public OSD CreateFailedResponseLLSD() { return CreateLoginFailedResponseLLSD(); } @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateLoginFailedResponseLLSD() + public OSD CreateLoginFailedResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -265,7 +265,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateAlreadyLoggedInResponseLLSD() + public OSD CreateAlreadyLoggedInResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateLoginBlockedResponseLLSD() + public OSD CreateLoginBlockedResponseLLSD() { return GenerateFailureResponseLLSD( "presence", @@ -299,7 +299,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateDeadRegionResponseLLSD() + public OSD CreateDeadRegionResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -315,7 +315,7 @@ namespace OpenSim.Framework.Communications "false")); } - public LLSD CreateGridErrorResponseLLSD() + public OSD CreateGridErrorResponseLLSD() { return GenerateFailureResponseLLSD( "key", @@ -404,90 +404,90 @@ namespace OpenSim.Framework.Communications } } - public LLSD ToLLSDResponse() + public OSD ToLLSDResponse() { try { - LLSDMap map = new LLSDMap(); + OSDMap map = new OSDMap(); - map["first_name"] = LLSD.FromString(Firstname); - map["last_name"] = LLSD.FromString(Lastname); - map["agent_access"] = LLSD.FromString(agentAccess); + map["first_name"] = OSD.FromString(Firstname); + map["last_name"] = OSD.FromString(Lastname); + map["agent_access"] = OSD.FromString(agentAccess); - map["sim_port"] = LLSD.FromInteger(SimPort); - map["sim_ip"] = LLSD.FromString(SimAddress); + map["sim_port"] = OSD.FromInteger(SimPort); + map["sim_ip"] = OSD.FromString(SimAddress); - map["agent_id"] = LLSD.FromUUID(AgentID); - map["session_id"] = LLSD.FromUUID(SessionID); - map["secure_session_id"] = LLSD.FromUUID(SecureSessionID); - map["circuit_code"] = LLSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = LLSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["secure_session_id"] = OSD.FromUUID(SecureSessionID); + map["circuit_code"] = OSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); #region Login Flags - LLSDMap loginFlagsLLSD = new LLSDMap(); - loginFlagsLLSD["daylight_savings"] = LLSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = LLSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = LLSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = LLSD.FromString(EverLoggedIn); - map["login-flags"] = WrapLLSDMap(loginFlagsLLSD); + OSDMap loginFlagsLLSD = new OSDMap(); + loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); + map["login-flags"] = WrapOSDMap(loginFlagsLLSD); #endregion Login Flags #region Global Textures - LLSDMap globalTexturesLLSD = new LLSDMap(); - globalTexturesLLSD["sun_texture_id"] = LLSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = LLSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = LLSD.FromString(MoonTexture); + OSDMap globalTexturesLLSD = new OSDMap(); + globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); - map["global-textures"] = WrapLLSDMap(globalTexturesLLSD); + map["global-textures"] = WrapOSDMap(globalTexturesLLSD); #endregion Global Textures - map["seed_capability"] = LLSD.FromString(seedCapability); + map["seed_capability"] = OSD.FromString(seedCapability); - map["event_categories"] = ArrayListToLLSDArray(eventCategories); - //map["event_notifications"] = new LLSDArray(); // todo - map["classified_categories"] = ArrayListToLLSDArray(classifiedCategories); + map["event_categories"] = ArrayListToOSDArray(eventCategories); + //map["event_notifications"] = new OSDArray(); // todo + map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); #region UI Config - LLSDMap uiConfigLLSD = new LLSDMap(); - uiConfigLLSD["allow_first_life"] = LLSD.FromString(allowFirstLife); - map["ui-config"] = WrapLLSDMap(uiConfigLLSD); + OSDMap uiConfigLLSD = new OSDMap(); + uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); + map["ui-config"] = WrapOSDMap(uiConfigLLSD); #endregion UI Config #region Inventory - map["inventory-skeleton"] = ArrayListToLLSDArray(agentInventory); + map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); - map["inventory-skel-lib"] = ArrayListToLLSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToLLSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToLLSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToLLSDArray(inventoryLibraryOwner); + map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); #endregion Inventory - map["gestures"] = ArrayListToLLSDArray(activeGestures); + map["gestures"] = ArrayListToOSDArray(activeGestures); - map["initial-outfit"] = ArrayListToLLSDArray(initialOutfit); - map["start_location"] = LLSD.FromString(startLocation); + map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); + map["start_location"] = OSD.FromString(startLocation); - map["seed_capability"] = LLSD.FromString(seedCapability); - map["home"] = LLSD.FromString(home); - map["look_at"] = LLSD.FromString(lookAt); - map["message"] = LLSD.FromString(welcomeMessage); - map["region_x"] = LLSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = LLSD.FromInteger(RegionY * Constants.RegionSize); + map["seed_capability"] = OSD.FromString(seedCapability); + map["home"] = OSD.FromString(home); + map["look_at"] = OSD.FromString(lookAt); + map["message"] = OSD.FromString(welcomeMessage); + map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); if (m_buddyList != null) { - map["buddy-list"] = ArrayListToLLSDArray(m_buddyList.ToArray()); + map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); } - map["login"] = LLSD.FromString("true"); + map["login"] = OSD.FromString("true"); return map; } @@ -499,24 +499,24 @@ namespace OpenSim.Framework.Communications } } - public LLSDArray ArrayListToLLSDArray(ArrayList arrlst) + public OSDArray ArrayListToOSDArray(ArrayList arrlst) { - LLSDArray llsdBack = new LLSDArray(); + OSDArray llsdBack = new OSDArray(); foreach (Hashtable ht in arrlst) { - LLSDMap mp = new LLSDMap(); + OSDMap mp = new OSDMap(); foreach (DictionaryEntry deHt in ht) { - mp.Add((string)deHt.Key, LLSDString.FromObject(deHt.Value)); + mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); } llsdBack.Add(mp); } return llsdBack; } - private static LLSDArray WrapLLSDMap(LLSDMap wrapMe) + private static OSDArray WrapOSDMap(OSDMap wrapMe) { - LLSDArray array = new LLSDArray(); + OSDArray array = new OSDArray(); array.Add(wrapMe); return array; } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 7fd1c3b..b4ee069 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -321,7 +321,7 @@ namespace OpenSim.Framework.Communications /// /// The LLSD request /// The response to send - public LLSD LLSDLoginMethod(LLSD request) + public OSD LLSDLoginMethod(OSD request) { // Temporary fix m_loginMutex.WaitOne(); @@ -335,9 +335,9 @@ namespace OpenSim.Framework.Communications UserProfileData userProfile = null; LoginResponse logResponse = new LoginResponse(); - if (request.Type == LLSDType.Map) + if (request.Type == OSDType.Map) { - LLSDMap map = (LLSDMap)request; + OSDMap map = (OSDMap)request; if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) { @@ -749,7 +749,7 @@ namespace OpenSim.Framework.Communications m_userManager.CreateAgent(profile, request); } - public void CreateAgent(UserProfileData profile, LLSD request) + public void CreateAgent(UserProfileData profile, OSD request) { m_userManager.CreateAgent(profile, request); } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 7189eee..4b5d2bb 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -448,7 +448,7 @@ namespace OpenSim.Framework.Communications profile.CurrentAgent = agent; } - public void CreateAgent(UserProfileData profile, LLSD request) + public void CreateAgent(UserProfileData profile, OSD request) { UserAgentData agent = new UserAgentData(); -- cgit v1.1 From 778d83d9f0c9b6b0e1dfd4f3bf1228867be7573a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 19 Nov 2008 07:03:39 +0000 Subject: Adjust to the Helpers->Utils rename --- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 44c4a05..e754256 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -561,7 +561,7 @@ namespace OpenSim.Framework.Communications.Capabilities endPos = FindEnd(llsd, 1); if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, - Helpers.EnUsCulture.NumberFormat, out value)) + Utils.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); -- cgit v1.1 From 02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 23 Nov 2008 03:38:40 +0000 Subject: Mantis#2660. Thank you kindly, Ruud Lathrop for a patch that: This patch adds the option of adding the email when you create a new user. This works in Gridmode as none Gridmode. This option is also added to RemoteAdminPlugin. With a new handler you can create a user with a email. --- .../Communications/CommunicationsManager.cs | 20 ++++++++++++--- OpenSim/Framework/Communications/IUserService.cs | 17 +++++++------ .../Framework/Communications/IUserServiceAdmin.cs | 26 +++++++++++++++---- .../Framework/Communications/UserManagerBase.cs | 29 ++++++++++++++++++---- 4 files changed, 70 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bb4a853..3f46776 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -255,14 +255,15 @@ namespace OpenSim.Framework.Communications /// /// /// + /// /// /// /// The UUID of the added user. Returns UUID.Zero if the add was unsuccessful - public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) + public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY); + m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY); UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); if (userProf == null) { @@ -276,11 +277,22 @@ namespace OpenSim.Framework.Communications } } - public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY, UUID SetUUID) + /// + /// Adds the user. + /// + /// The first name. + /// The last name. + /// The password. + /// The email. + /// The reg X. + /// The reg Y. + /// The set UUID. + /// + public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY, SetUUID); + m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY, SetUUID); UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); if (userProf == null) { diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 50c9917..178b5a0 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -35,15 +35,15 @@ namespace OpenSim.Framework.Communications /// /// Loads a user profile by name /// - /// First name - /// Last name + /// First name + /// Last name /// A user profile. Returns null if no profile is found UserProfileData GetUserProfile(string firstName, string lastName); /// /// Loads a user profile from a database by UUID /// - /// The target UUID + /// The target UUID /// A user profile. Returns null if no user profile is found. UserProfileData GetUserProfile(UUID userId); @@ -90,8 +90,8 @@ namespace OpenSim.Framework.Communications /// /// Logs off a user on the user server /// - /// UUID of the user - /// UUID of the Region + /// UUID of the user + /// UUID of the Region /// regionhandle /// final position /// final lookat @@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications /// /// Logs off a user on the user server (deprecated as of 2008-08-27) /// - /// UUID of the user - /// UUID of the Region + /// UUID of the user + /// UUID of the Region /// regionhandle /// final position x /// final position y @@ -118,7 +118,8 @@ namespace OpenSim.Framework.Communications /// Updates the current region the User is in /// /// User Region the Avatar is IN - /// User Region the Avatar is IN + /// User Region the Avatar is IN + /// User region handle void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle); /// diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs index 169385f..a120add 100644 --- a/OpenSim/Framework/Communications/IUserServiceAdmin.cs +++ b/OpenSim/Framework/Communications/IUserServiceAdmin.cs @@ -30,15 +30,31 @@ using OpenMetaverse; namespace OpenSim.Framework.Communications { public interface IUserServiceAdmin - { + { /// /// Add a new user profile /// - /// - UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + /// The first name. + /// The last name. + /// password of avatar + /// email of user + /// region X. + /// region Y. + /// + UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY); - // Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances! - UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID setUUID); + /// + /// Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances! + /// + /// The first name. + /// The last name. + /// password of avatar + /// email of user + /// region X. + /// region Y. + /// The set UUID. + /// + UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); /// /// Reset a user password diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 4b5d2bb..bc1a593 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -54,6 +54,7 @@ namespace OpenSim.Framework.Communications /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// /// The filename to the user server plugin DLL + /// public void AddPlugin(string provider, string connect) { PluginLoader loader = @@ -580,15 +581,32 @@ namespace OpenSim.Framework.Communications #endregion /// - /// + /// Add a new user profile /// - /// - public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + /// first name. + /// last name. + /// password + /// email. + /// location X. + /// location Y. + /// + public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY) { - return AddUserProfile(firstName, lastName, pass, regX, regY, UUID.Random()); + return AddUserProfile(firstName, lastName, pass, email, regX, regY, UUID.Random()); } - public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID SetUUID) + /// + /// Adds the user profile. + /// + /// first name. + /// last name. + /// password + /// email. + /// location X. + /// location Y. + /// UUID of avatar. + /// + public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID SetUUID) { UserProfileData user = new UserProfileData(); user.HomeLocation = new Vector3(128, 128, 100); @@ -601,6 +619,7 @@ namespace OpenSim.Framework.Communications user.HomeLookAt = new Vector3(100, 100, 100); user.HomeRegionX = regX; user.HomeRegionY = regY; + user.Email = email; foreach (IUserDataPlugin plugin in _plugins) { -- cgit v1.1 From cbd02218704287640ba5c7b564440a6590e038cf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 05:16:07 +0000 Subject: Plumb in the presence notifications and region shutdown/restart messages from the presence module to the message server, through the user server and on into the database. This should fix the "Already logged in" issue that grids see after a sim crashes, or a user crashes out of a sim. Not yet a 100% solution for friends, but getting there. --- OpenSim/Framework/Communications/UserManagerBase.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bc1a593..46b28d7 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -87,6 +87,14 @@ namespace OpenSim.Framework.Communications return null; } + public void LogoutUsers(UUID regionID) + { + foreach (IUserDataPlugin plugin in _plugins) + { + plugin.LogoutUsers(regionID); + } + } + public void ResetAttachments(UUID userID) { foreach (IUserDataPlugin plugin in _plugins) -- cgit v1.1 From fba9e3f513a0d9b4e0ccaf5a9fe24899d96e98c8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 20:39:51 +0000 Subject: Don't serve texture preview from other people's objects if you havenever seen that texture before. --- .../Communications/Cache/InventoryFolderImpl.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index f78cdee..8e624f9 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -138,6 +138,33 @@ namespace OpenSim.Framework.Communications.Cache return null; } + public InventoryItemBase FindAsset(UUID assetID) + { + lock (Items) + { + foreach (InventoryItemBase item in Items.Values) + { + if (item.AssetID == assetID) + return item; + } + } + + lock (SubFolders) + { + foreach (InventoryFolderImpl folder in SubFolders.Values) + { + InventoryItemBase item = folder.FindAsset(assetID); + + if (item != null) + { + return item; + } + } + } + + return null; + } + /// /// Deletes an item if it exists in this folder or any children /// -- cgit v1.1 From 4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 25 Nov 2008 11:44:31 +0000 Subject: * First step in refactoring the login code - extracting the authentication --- OpenSim/Framework/Communications/LoginService.cs | 92 +++++++++++++----------- 1 file changed, 49 insertions(+), 43 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index b4ee069..8199598 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -117,7 +117,8 @@ namespace OpenSim.Framework.Communications bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - bool GoodLogin = false; + + bool GoodLogin; string startLocationRequest = "last"; @@ -129,7 +130,12 @@ namespace OpenSim.Framework.Communications if (GoodXML) { - firstname = (string) requestData["first"]; + if (requestData.Contains("start")) + { + startLocationRequest = (string)requestData["start"]; + } + + firstname = (string)requestData["first"]; lastname = (string) requestData["last"]; m_log.InfoFormat( @@ -143,45 +149,13 @@ namespace OpenSim.Framework.Communications clientVersion = (string)requestData["version"]; } - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - } - m_log.DebugFormat( "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) + if( !TryAuthenticateUser(request, firstname, lastname, out userProfile ) ) { - m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); - return logResponse.CreateLoginFailedResponse(); } - - if (requestData.Contains("passwd")) - { - string passwd = (string)requestData["passwd"]; - GoodLogin = AuthenticateUser(userProfile, passwd); - } - else if (requestData.Contains("web_login_key")) - { - UUID webloginkey; - try - { - webloginkey = new UUID((string)requestData["web_login_key"]); - } - catch (Exception e) - { - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", - requestData["web_login_key"], firstname, lastname, e); - - return logResponse.CreateFailedResponse(); - } - GoodLogin = AuthenticateUser(userProfile, webloginkey); - - } } else { @@ -191,13 +165,7 @@ namespace OpenSim.Framework.Communications return logResponse.CreateGridErrorResponse(); } - if (!GoodLogin) - { - m_log.InfoFormat("[LOGIN END]: XMLRPC User {0} {1} failed authentication", firstname, lastname); - - return logResponse.CreateLoginFailedResponse(); - } - else if (userProfile.GodLevel < m_minLoginLevel) + if (userProfile.GodLevel < m_minLoginLevel) { return logResponse.CreateLoginBlockedResponse(); } @@ -303,7 +271,8 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[LOGIN END]: XMLRPC Login failed, " + e); + m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); + m_log.Error(e.StackTrace); } } @@ -316,6 +285,43 @@ namespace OpenSim.Framework.Communications } } + protected virtual bool TryAuthenticateUser(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodLogin = false; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); + } + else + { + if (requestData.Contains("passwd")) + { + string passwd = (string) requestData["passwd"]; + GoodLogin = AuthenticateUser(userProfile, passwd); + } + else if (requestData.Contains("web_login_key")) + { + try + { + UUID webloginkey = new UUID((string) requestData["web_login_key"]); + GoodLogin = AuthenticateUser(userProfile, webloginkey); + } + catch (Exception e) + { + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); + } + } + } + + return GoodLogin; + } + /// /// Called when we receive the client's initial LLSD login_to_simulator request message /// -- cgit v1.1 From dbe64197aecfad98ef04ceffc451f01dd2cab50f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 25 Nov 2008 11:46:15 +0000 Subject: * Adding some virtual hooks and making some privaets protected for great justice. --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 46b28d7..2a66260 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -119,7 +119,7 @@ namespace OpenSim.Framework.Communications } // see IUserService - public UserProfileData GetUserProfile(UUID uuid) + public virtual UserProfileData GetUserProfile(UUID uuid) { foreach (IUserDataPlugin plugin in _plugins) { -- cgit v1.1 From e187972377c19bdd85093677c4c54034e4f9196e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 25 Nov 2008 15:19:00 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2640 * This is Diva's hypergrid patch, as perviously discussed on the opensim-dev mailing list * Applied some minor prebuild.xml jiggling to resolve a dependency issue * Thanks Diva! --- OpenSim/Framework/Communications/IHyperlink.cs | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 OpenSim/Framework/Communications/IHyperlink.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs new file mode 100644 index 0000000..77815f1 --- /dev/null +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * 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 Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Text; + +using OpenSim.Framework; + +namespace OpenSim.Framework.Communications +{ + public interface IHyperlink + { + bool IsHyperlinkRegion(ulong handle); + RegionInfo GetHyperlinkRegion(ulong handle); + ulong FindRegionHandle(ulong handle); + } +} -- cgit v1.1 From fbf90b1ecec7bf26bb0e948f34877bb049e6f333 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 25 Nov 2008 15:41:42 +0000 Subject: * minor: eliminate mono compiler warnings --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 8199598..c3dcc90 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Communications bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - bool GoodLogin; + //bool GoodLogin; string startLocationRequest = "last"; -- cgit v1.1 From 518a8b9f2ac09a5060e2e59c913dfbe7faf397ef Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 25 Nov 2008 16:00:55 +0000 Subject: Update svn properties. --- OpenSim/Framework/Communications/IHyperlink.cs | 84 +++++++++++++------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs index 77815f1..02ba2c2 100644 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -1,42 +1,42 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * 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 Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Text; - -using OpenSim.Framework; - -namespace OpenSim.Framework.Communications -{ - public interface IHyperlink - { - bool IsHyperlinkRegion(ulong handle); - RegionInfo GetHyperlinkRegion(ulong handle); - ulong FindRegionHandle(ulong handle); - } -} +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * 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 Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Text; + +using OpenSim.Framework; + +namespace OpenSim.Framework.Communications +{ + public interface IHyperlink + { + bool IsHyperlinkRegion(ulong handle); + RegionInfo GetHyperlinkRegion(ulong handle); + ulong FindRegionHandle(ulong handle); + } +} -- cgit v1.1 From de052c48d1d59bd77651288066c2350b136eca8b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 25 Nov 2008 16:10:08 +0000 Subject: Add copyright headers. Minor formatting cleanup. --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index c3dcc90..d6d0e27 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -152,7 +152,7 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - if( !TryAuthenticateUser(request, firstname, lastname, out userProfile ) ) + if (!TryAuthenticateUser(request, firstname, lastname, out userProfile)) { return logResponse.CreateLoginFailedResponse(); } -- cgit v1.1 From 7c6c776ff783b30dfc26a065e63c267e46edc53b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Nov 2008 19:28:04 +0000 Subject: * test: Add the ability to add a plugin directory to the user and inventory services in order to extend unit tests for user and inventory information * I can't spend any longer in trying to get Mono.Addins to work with the unit tests, so this is not a proper plugin at this time --- .../Communications/CommunicationsManager.cs | 1 - .../Communications/InventoryServiceBase.cs | 19 +++++++++---- .../Framework/Communications/UserManagerBase.cs | 32 ++++++++++++++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 3f46776..bcf9bed 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -110,7 +110,6 @@ namespace OpenSim.Framework.Communications /// protected IUserServiceAdmin m_userServiceAdmin; - public BaseHttpServer HttpServer { get { return m_httpServer; } diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 5841151..777e15b 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -48,20 +48,29 @@ namespace OpenSim.Framework.Communications #region Plugin methods /// - /// Adds a new user server plugin - plugins will be requested in the order they were loaded. + /// Add a new inventory data plugin - plugins will be requested in the order they were added. /// - /// The filename to the user server plugin DLL + /// The plugin that will provide data + public void AddPlugin(IInventoryDataPlugin plugin) + { + m_plugins.Add(plugin); + } + + /// + /// Adds a new inventory data plugin - plugins will be requested in the order they were loaded. + /// + /// The filename of the inventory server plugin DLL public void AddPlugin(string provider, string connect) { PluginLoader loader = - new PluginLoader (new InventoryDataInitialiser (connect)); + new PluginLoader (new InventoryDataInitialiser(connect)); // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml - loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); + loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter(provider)); loader.Load(); - m_plugins = loader.Plugins; + m_plugins.AddRange(loader.Plugins); } #endregion diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 2a66260..a929317 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -48,12 +48,24 @@ namespace OpenSim.Framework.Communications private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// List of plugins to search for user data + /// private List _plugins = new List(); + + /// + /// Add a new user data plugin - plugins will be requested in the order they were added. + /// + /// The plugin that will provide user data + public void AddPlugin(IUserDataPlugin plugin) + { + _plugins.Add(plugin); + } /// - /// Adds a new user server plugin - user servers will be requested in the order they were loaded. + /// Add a new user data plugin - plugins will be requested in the order they were added. /// - /// The filename to the user server plugin DLL + /// The filename to the user data plugin DLL /// public void AddPlugin(string provider, string connect) { @@ -65,7 +77,7 @@ namespace OpenSim.Framework.Communications loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider)); loader.Load(); - _plugins = loader.Plugins; + _plugins.AddRange(loader.Plugins); } #region Get UserProfile @@ -637,7 +649,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -696,8 +708,11 @@ namespace OpenSim.Framework.Communications return false; } - /// Appearance - /// TODO: stubs for now to get us to a compiling state gently + /// + /// Get avatar appearance information + /// + /// + /// public AvatarAppearance GetUserAppearance(UUID user) { foreach (IUserDataPlugin plugin in _plugins) @@ -714,6 +729,11 @@ namespace OpenSim.Framework.Communications return null; } + /// + /// Update avatar appearance information + /// + /// + /// public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { foreach (IUserDataPlugin plugin in _plugins) -- cgit v1.1 From 45c50998c23657764918649b8966f429674b0c92 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 27 Nov 2008 19:43:26 +0000 Subject: * Remove unused and largely unimplemented UpdateUserCurrentRegion() * please say if this causes you a problem --- OpenSim/Framework/Communications/IUserService.cs | 8 -------- OpenSim/Framework/Communications/UserManagerBase.cs | 15 --------------- 2 files changed, 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 178b5a0..ecbbd32 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -115,14 +115,6 @@ namespace OpenSim.Framework.Communications List GetUserFriendList(UUID friendlistowner); /// - /// Updates the current region the User is in - /// - /// User Region the Avatar is IN - /// User Region the Avatar is IN - /// User region handle - void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle); - - /// /// Get's the User Appearance // AvatarAppearance GetUserAppearance(UUID user); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index a929317..a5ca654 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -265,21 +265,6 @@ namespace OpenSim.Framework.Communications return null; } - public void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle); - } - catch (Exception e) - { - m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - } - /// /// Loads a user's friend list /// -- cgit v1.1 From 27d9e715c02451b4c87ce94728a0fa00071c61e5 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 28 Nov 2008 12:31:30 +0000 Subject: * Changed name of auth function to better reflect actual use --- OpenSim/Framework/Communications/LoginService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d6d0e27..883f965 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -152,7 +152,7 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - if (!TryAuthenticateUser(request, firstname, lastname, out userProfile)) + if( !TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile ) ) { return logResponse.CreateLoginFailedResponse(); } @@ -193,6 +193,7 @@ namespace OpenSim.Framework.Communications return logResponse.CreateAlreadyLoggedInResponse(); } + // Otherwise... // Create a new agent session @@ -285,7 +286,7 @@ namespace OpenSim.Framework.Communications } } - protected virtual bool TryAuthenticateUser(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) + protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) { Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 0862627b341641ec0223bb4191dfee8d85724c9e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 15:34:30 +0000 Subject: * refactor: move CreateUser into UserServiceAdmin --- .../Communications/CommunicationsManager.cs | 63 ++------------------ .../Framework/Communications/IUserServiceAdmin.cs | 30 +++++----- .../Communications/InventoryServiceBase.cs | 1 - .../Framework/Communications/UserManagerBase.cs | 68 +++++++++++++++------- 4 files changed, 66 insertions(+), 96 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bcf9bed..a5ead3f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -106,8 +106,12 @@ namespace OpenSim.Framework.Communications protected NetworkServersInfo m_networkServersInfo; /// - /// Interface to administrative user service calls. + /// Interface to user service for administrating users. /// + public IUserServiceAdmin UserServiceAdmin + { + get { return m_userServiceAdmin; } + } protected IUserServiceAdmin m_userServiceAdmin; public BaseHttpServer HttpServer @@ -247,63 +251,6 @@ namespace OpenSim.Framework.Communications } #endregion - - /// - /// Persistently adds a user to OpenSim. - /// - /// - /// - /// - /// - /// - /// - /// The UUID of the added user. Returns UUID.Zero if the add was unsuccessful - public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) - { - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - - m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY); - UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); - if (userProf == null) - { - return UUID.Zero; - } - else - { - InterServiceInventoryService.CreateNewUserInventory(userProf.ID); - m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); - return userProf.ID; - } - } - - /// - /// Adds the user. - /// - /// The first name. - /// The last name. - /// The password. - /// The email. - /// The reg X. - /// The reg Y. - /// The set UUID. - /// - public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) - { - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - - m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY, SetUUID); - UserProfileData userProf = UserService.GetUserProfile(firstName, lastName); - if (userProf == null) - { - return UUID.Zero; - } - else - { - InterServiceInventoryService.CreateNewUserInventory(userProf.ID); - m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); - return userProf.ID; - } - } /// /// Reset a user password diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs index a120add..b1f974b 100644 --- a/OpenSim/Framework/Communications/IUserServiceAdmin.cs +++ b/OpenSim/Framework/Communications/IUserServiceAdmin.cs @@ -32,29 +32,29 @@ namespace OpenSim.Framework.Communications public interface IUserServiceAdmin { /// - /// Add a new user profile + /// Add a new user /// - /// The first name. - /// The last name. + /// The first name + /// The last name /// password of avatar /// email of user - /// region X. - /// region Y. - /// - UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY); + /// region X + /// region Y + /// The UUID of the created user profile. On failure, returns UUID.Zero + UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY); /// - /// Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances! + /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules! /// - /// The first name. - /// The last name. + /// The first name + /// The last name /// password of avatar /// email of user - /// region X. - /// region Y. - /// The set UUID. - /// - UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); + /// region X + /// region Y + /// The set UUID + /// The UUID of the created user profile. On failure, returns UUID.Zero + UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); /// /// Reset a user password diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 777e15b..7a44420 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -82,7 +82,6 @@ namespace OpenSim.Framework.Communications get { return "default"; } } - // See IInventoryServices public List GetInventorySkeleton(UUID userId) { // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index a5ca654..3946ea3 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -52,6 +52,17 @@ namespace OpenSim.Framework.Communications /// List of plugins to search for user data /// private List _plugins = new List(); + + private IInterServiceInventoryServices m_interServiceInventoryService; + + /// + /// Constructor + /// + /// + public UserManagerBase(IInterServiceInventoryServices interServiceInventoryService) + { + m_interServiceInventoryService = interServiceInventoryService; + } /// /// Add a new user data plugin - plugins will be requested in the order they were added. @@ -80,7 +91,7 @@ namespace OpenSim.Framework.Communications _plugins.AddRange(loader.Plugins); } - #region Get UserProfile + #region Get UserProfile // see IUserService public UserProfileData GetUserProfile(string fname, string lname) @@ -586,39 +597,42 @@ namespace OpenSim.Framework.Communications #endregion /// - /// Add a new user profile + /// Add a new user /// - /// first name. - /// last name. - /// password - /// email. - /// location X. - /// location Y. - /// - public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY) + /// first name + /// last name + /// password + /// email + /// location X + /// location Y + /// The UUID of the created user profile. On failure, returns UUID.Zero + public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) { - return AddUserProfile(firstName, lastName, pass, email, regX, regY, UUID.Random()); + return AddUser(firstName, lastName, password, email, regX, regY, UUID.Random()); } /// - /// Adds the user profile. + /// Add a new user /// - /// first name. - /// last name. - /// password - /// email. - /// location X. - /// location Y. + /// first name + /// last name + /// password + /// email + /// location X + /// location Y /// UUID of avatar. - /// - public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID SetUUID) + /// The UUID of the created user profile. On failure, returns UUID.Zero + public UUID AddUser( + string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); + UserProfileData user = new UserProfileData(); user.HomeLocation = new Vector3(128, 128, 100); user.ID = SetUUID; user.FirstName = firstName; user.SurName = lastName; - user.PasswordHash = pass; + user.PasswordHash = md5PasswdHash; user.PasswordSalt = String.Empty; user.Created = Util.UnixTimeSinceEpoch(); user.HomeLookAt = new Vector3(100, 100, 100); @@ -638,7 +652,17 @@ namespace OpenSim.Framework.Communications } } - return user.ID; + UserProfileData userProf = GetUserProfile(firstName, lastName); + if (userProf == null) + { + return UUID.Zero; + } + else + { + m_interServiceInventoryService.CreateNewUserInventory(userProf.ID); + + return userProf.ID; + } } /// -- cgit v1.1 From 63851f14417e8027d51150daa93413b1bc6888ed Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 15:47:01 +0000 Subject: * refactor: move ResetUserPassword into UserServiceAdmin --- OpenSim/Framework/Communications/CommunicationsManager.cs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index a5ead3f..c4adfa5 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -251,18 +251,6 @@ namespace OpenSim.Framework.Communications } #endregion - - /// - /// Reset a user password - /// - /// - /// - /// - /// true if the update was successful, false otherwise - public bool ResetUserPassword(string firstName, string lastName, string newPassword) - { - return m_userServiceAdmin.ResetUserPassword(firstName, lastName, newPassword); - } #region Friend Methods -- cgit v1.1 From 18974b77668553a9fd1bba0b646bfc7a0d788bcb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 16:04:01 +0000 Subject: * refactor: rename UserServiceAdmin to UserAdminService --- .../Communications/CommunicationsManager.cs | 6 +- .../Framework/Communications/IUserAdminService.cs | 71 ++++++++++++++++++++++ .../Framework/Communications/IUserServiceAdmin.cs | 68 --------------------- .../Framework/Communications/UserManagerBase.cs | 2 +- 4 files changed, 75 insertions(+), 72 deletions(-) create mode 100644 OpenSim/Framework/Communications/IUserAdminService.cs delete mode 100644 OpenSim/Framework/Communications/IUserServiceAdmin.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index c4adfa5..72c01bd 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -108,11 +108,11 @@ namespace OpenSim.Framework.Communications /// /// Interface to user service for administrating users. /// - public IUserServiceAdmin UserServiceAdmin + public IUserAdminService UserAdminService { - get { return m_userServiceAdmin; } + get { return m_userAdminService; } } - protected IUserServiceAdmin m_userServiceAdmin; + protected IUserAdminService m_userAdminService; public BaseHttpServer HttpServer { diff --git a/OpenSim/Framework/Communications/IUserAdminService.cs b/OpenSim/Framework/Communications/IUserAdminService.cs new file mode 100644 index 0000000..3b7ba6e --- /dev/null +++ b/OpenSim/Framework/Communications/IUserAdminService.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; + +namespace OpenSim.Framework.Communications +{ + /// + /// Interface for the service for administrating users + /// + public interface IUserAdminService + { + /// + /// Add a new user + /// + /// The first name + /// The last name + /// password of avatar + /// email of user + /// region X + /// region Y + /// The UUID of the created user profile. On failure, returns UUID.Zero + UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY); + + /// + /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules! + /// + /// The first name + /// The last name + /// password of avatar + /// email of user + /// region X + /// region Y + /// The set UUID + /// The UUID of the created user profile. On failure, returns UUID.Zero + UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); + + /// + /// Reset a user password + /// + /// + /// + /// + /// true if the update was successful, false otherwise + bool ResetUserPassword(string firstName, string lastName, string newPassword); + } +} diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs deleted file mode 100644 index b1f974b..0000000 --- a/OpenSim/Framework/Communications/IUserServiceAdmin.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IUserServiceAdmin - { - /// - /// Add a new user - /// - /// The first name - /// The last name - /// password of avatar - /// email of user - /// region X - /// region Y - /// The UUID of the created user profile. On failure, returns UUID.Zero - UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY); - - /// - /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules! - /// - /// The first name - /// The last name - /// password of avatar - /// email of user - /// region X - /// region Y - /// The set UUID - /// The UUID of the created user profile. On failure, returns UUID.Zero - UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); - - /// - /// Reset a user password - /// - /// - /// - /// - /// true if the update was successful, false otherwise - bool ResetUserPassword(string firstName, string lastName, string newPassword); - } -} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 3946ea3..8bfb2d7 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService, IMessagingService + public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 71e05a5707f1eaed098592dc1c3feb3389731634 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 19:39:46 +0000 Subject: * test: Add a wodge of code in order to be able to slightly extend a test to deliver a taken object to a user inventory folder without throwing an exception * test doesn't actually double check for the presence of the item yet --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d242cb3..4212fbc 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -214,7 +214,6 @@ namespace OpenSim.Framework.Communications.Cache /// public void InventoryReceive(ICollection folders, ICollection items) { - // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these // are simply being swallowed -- cgit v1.1 From 5f9ccd486f9f8317cce3badcb62d646766c5642c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 28 Nov 2008 20:58:12 +0000 Subject: * test: Extend take object test to finally check that the object made it into user inventory and that it was removed from the scene --- OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 72c01bd..b4af991 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications /// public class CommunicationsManager { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_nameRequestCache = new Dictionary(); -- cgit v1.1 From 077314cdd3b0acdebb2d39eb0c0108814313f8f0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 30 Nov 2008 00:51:40 +0000 Subject: Update svn properties. Add copyright header. Minor formatting cleanup. --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 883f965..e4e00a7 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -152,7 +152,7 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat( "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - if( !TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile ) ) + if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) { return logResponse.CreateLoginFailedResponse(); } -- cgit v1.1 From 8f7c2ba91bb768ab41327c6fda32d1169d4e88fe Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 2 Dec 2008 13:15:10 +0000 Subject: changed UserManagerBase. IInterServiceInventoryServices m_interServiceInventoryService from private to protected --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 8bfb2d7..3f2b902 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -53,7 +53,7 @@ namespace OpenSim.Framework.Communications /// private List _plugins = new List(); - private IInterServiceInventoryServices m_interServiceInventoryService; + protected IInterServiceInventoryServices m_interServiceInventoryService; /// /// Constructor -- cgit v1.1 From 38ca31b37a6ac8fe74b77e4488112eb77d612827 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 4 Dec 2008 19:57:36 +0000 Subject: * Put in the code necessary to allow inventory transfer of whole folders (and their contents) between agents, not just single items * However, this is not currently activated since it's not absolutely fully tested and there's a bug lurking in there to do with the sending of the BulkInventoryUpdate packets --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 5 ++++- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 4212fbc..b4e7bfa 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -556,8 +556,10 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Add an item to the user's inventory + /// Add an item to the user's inventory. /// + /// If the item has no folder set (i.e. it is UUID.Zero), then it is placed in the most appropriate folder + /// for that type. /// public void AddItem(InventoryItemBase item) { @@ -572,6 +574,7 @@ namespace OpenSim.Framework.Communications.Cache item.Folder = RootFolder.ID; } ItemReceive(item, null); + if (m_commsManager.SecureInventoryService != null) { m_commsManager.SecureInventoryService.AddItem(item, m_session_id); diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 8e624f9..0704232 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -358,6 +358,10 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } + /// + /// The total number of items in this folder and in the immediate child folders (though not from other + /// descendants). + /// public int TotalCount { get -- cgit v1.1 From 2cb30b3435e79f60f153fb03fc01a0639de73152 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 5 Dec 2008 10:31:34 +0000 Subject: some small refactoring of the LoginService to allow sub classes to override the LLSD login authentication --- OpenSim/Framework/Communications/LoginService.cs | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e4e00a7..90c5206 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -323,6 +323,21 @@ namespace OpenSim.Framework.Communications return GoodLogin; } + protected virtual bool TryAuthenticateLLSDLogin( string firstname, string lastname, string passwd, out UserProfileData userProfile) + { + bool GoodLogin = false; + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); + + return false; + } + + GoodLogin = AuthenticateUser(userProfile, passwd); + return GoodLogin; + } + /// /// Called when we receive the client's initial LLSD login_to_simulator request message /// @@ -359,23 +374,15 @@ namespace OpenSim.Framework.Communications } m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname+"' '"+lastname+"' / "+passwd); - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) + if (!TryAuthenticateLLSDLogin( firstname, lastname, passwd, out userProfile)) { - m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); - return logResponse.CreateLoginFailedResponseLLSD(); } - - GoodLogin = AuthenticateUser(userProfile, passwd); } } - if (!GoodLogin) - { - return logResponse.CreateLoginFailedResponseLLSD(); - } - else if (userProfile.GodLevel < m_minLoginLevel) + + if (userProfile.GodLevel < m_minLoginLevel) { return logResponse.CreateLoginBlockedResponseLLSD(); } -- cgit v1.1 From bdffd56a454a5adebc2022d6f1c39f288e62c0d9 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 5 Dec 2008 15:28:03 +0000 Subject: killing warnings, reformatting RemoteAdminPlugin --- OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs | 9 ++++----- OpenSim/Framework/Communications/LoginService.cs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 8e88844..3ed9172 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -270,11 +270,10 @@ namespace OpenSim.Framework.Communications.Cache // passphrase and salt value. The password will be created using // the specified hash algorithm. Password creation can be done in // several iterations. - PasswordDeriveBytes password = new PasswordDeriveBytes( - passPhrase, - saltValueBytes, - hashAlgorithm, - passwordIterations); + PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, + saltValueBytes, + hashAlgorithm, + passwordIterations); // Use the password to generate pseudo-random bytes for the encryption // key. Specify the size of the key in bytes (instead of bits). diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 90c5206..24e9ca9 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications try { - bool GoodLogin = false; + // bool GoodLogin = false; string startLocationRequest = "last"; -- cgit v1.1 From 6ab09bc1391b5fa1429a01dcb00bdbf2fb507972 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 6 Dec 2008 22:51:41 +0000 Subject: Send the creation-date of items to the viewer. This fixes Mantis#2769. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index b4a0473..c83c2a6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -397,7 +397,7 @@ namespace OpenSim.Framework.Communications.Capabilities { LLSDInventoryItem llsdItem = new LLSDInventoryItem(); llsdItem.asset_id = invItem.AssetID; - llsdItem.created_at = 1000; + llsdItem.created_at = invItem.CreationDate; llsdItem.desc = invItem.Description; llsdItem.flags = 0; llsdItem.item_id = invItem.ID; -- cgit v1.1 From 762712c02e4abf332d2d9a0ba583d6fe6f406aff Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 9 Dec 2008 18:35:09 +0000 Subject: * Actually update subfolders of parent folders in the inventory cache when a folder gets moved * This was causing inventory folder transfer code to not work properly (this is still temporarily disabled) --- .../Communications/Cache/CachedUserInfo.cs | 34 +++++++++++++++----- .../Communications/Cache/InventoryFolderImpl.cs | 36 ++++++++++++++++++++++ .../Cache/UserProfileCacheService.cs | 4 +-- 3 files changed, 65 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b4e7bfa..c8656d5 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -397,14 +397,14 @@ namespace OpenSim.Framework.Communications.Cache /// /// Handle a client request to update the inventory folder + /// /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, - /// and needs to be changed. - /// + /// and needs to be changed. /// /// /// @@ -461,6 +461,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// + /// + /// true if the delete was successful, or if it was queued pending folder receipt + /// false if the folder to be deleted did not exist. + /// public bool MoveFolder(UUID folderID, UUID parentID) { // m_log.DebugFormat( @@ -482,10 +486,27 @@ namespace OpenSim.Framework.Communications.Cache { m_commsManager.InventoryService.MoveFolder(baseFolder); } - + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - if (folder != null) - folder.ParentID = parentID; + InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); + if (parentFolder != null && folder != null) + { + InventoryFolderImpl oldParentFolder = RootFolder.FindFolder(folder.ParentID); + + if (oldParentFolder != null) + { + oldParentFolder.RemoveChildFolder(folderID); + parentFolder.AddChildFolder(folder); + } + else + { + return false; + } + } + else + { + return false; + } return true; } @@ -502,10 +523,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// This method will delete all the items and folders in the given folder. - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. - /// /// /// public bool PurgeFolder(UUID folderID) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 0704232..83ac239 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -92,6 +92,42 @@ namespace OpenSim.Framework.Communications.Cache return null; } + + /// + /// Add a folder that already exists. + /// + /// + public void AddChildFolder(InventoryFolderImpl folder) + { + lock (SubFolders) + { + folder.ParentID = ID; + SubFolders[folder.ID] = folder; + } + } + + /// + /// Removes the given child subfolder. + /// + /// + /// + /// The folder removed, or null if the folder was not present. + /// + public InventoryFolderImpl RemoveChildFolder(UUID folderID) + { + InventoryFolderImpl removedFolder = null; + + lock (SubFolders) + { + if (SubFolders.ContainsKey(folderID)) + { + removedFolder = SubFolders[folderID]; + SubFolders.Remove(folderID); + } + } + + return removedFolder; + } /// /// Delete all the folders and items in this folder. diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 45102d8..b4f3e9f 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -274,8 +274,8 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.MoveFolder(folderID, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", - remoteClient.Name, remoteClient.AgentId); + "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}", + folderID, parentID, remoteClient.Name); } } else -- cgit v1.1 From 9e02a639e563ef45788ae24adf568be028e041be Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 10 Dec 2008 16:50:11 +0000 Subject: * Apply the other patch from http://opensimulator.org/mantis/view.php?id=2315 * This means that LL RAW terrains (one source being the upload/download buttons on the estate dialog in the viewer) are now imported the 'right' way around rather than being flipped on the y axis * Existing RAW terrains before this patch will need to be flipped with the "terrain flip y" command from the console after import * More details on the mailing lists soon. -This line, and those below, will be ignored-- M OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs M OpenSim/Framework/Communications/Cache/CachedUserInfo.cs M OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 3 ++- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c8656d5..d3e715f 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -329,10 +329,11 @@ namespace OpenSim.Framework.Communications.Cache /// /// Create a folder in this agent's inventory. + /// /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. - /// + /// /// /// public bool CreateFolder(string folderName, UUID folderID, ushort folderType, UUID parentID) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b4f3e9f..46df2b7 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -224,11 +224,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Handle a client request to update the inventory folder + /// /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, /// and needs to be changed. - /// + /// /// /// /// -- cgit v1.1 From 93977c2d4715211d97c7adfd7cf78ff711a5b7eb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 10 Dec 2008 17:43:45 +0000 Subject: * Establish OpenSim.Framework.Communications.Tests beachhead * No valid tests yet --- .../Tests/UserProfileCacheServiceTests.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs new file mode 100644 index 0000000..0d239aa --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using NUnit.Framework; + +namespace OpenSim.Framework.Communications.Tests +{ + /// + /// User profile cache service tests + /// + [TestFixture] + public class UserProfileCacheServiceTests + { + /// + /// Test folder moving. Doesn't do what is says on the tin yet + /// + [Test] + public void TestMoveFolder() + { + // Temporarily empty + } + } +} -- cgit v1.1 From f38c35b60947fd926246fd95cfce5b9674967124 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 10 Dec 2008 19:12:59 +0000 Subject: * refactor: Move inventory handlers out from UserProfileCacheService * This means that UserProfileCacheService no longer needs to know about IClientAPI and can leave it to callers to do their own error logging * This is also more consistent with the way that item inventory manipulation is handled * I don't really think Scene.PacketHandlers.cs should be a permanent home for these handlers - this is just for convenience --- .../Cache/UserProfileCacheService.cs | 279 --------------------- .../Tests/Cache/UserProfileCacheServiceTests.cs | 48 ++++ .../Tests/UserProfileCacheServiceTests.cs | 48 ---- 3 files changed, 48 insertions(+), 327 deletions(-) create mode 100644 OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs delete mode 100644 OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 46df2b7..958ef4e 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -185,289 +185,10 @@ namespace OpenSim.Framework.Communications.Cache } else { - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData); m_userProfiles.Add(userID, userInfo); } } } - - /// - /// Handle an inventory folder creation request from the client. - /// - /// - /// - /// - /// - /// - public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, - string folderName, UUID parentID) - { - CachedUserInfo userProfile; - - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID)) - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - - /// - /// Handle a client request to update the inventory folder - /// - /// - /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE - /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, - /// and needs to be changed. - /// - /// - /// - /// - /// - /// - public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name, - UUID parentID) - { -// m_log.DebugFormat( -// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); - - CachedUserInfo userProfile; - - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (!userProfile.UpdateFolder(name, folderID, type, parentID)) - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to update folder for user {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - - /// - /// Handle an inventory folder move request from the client. - /// - /// - /// - /// - public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) - { - CachedUserInfo userProfile; - - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (!userProfile.MoveFolder(folderID, parentID)) - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}", - folderID, parentID, remoteClient.Name); - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - - /// - /// Tell the client about the various child items and folders contained in the requested folder. - /// - /// - /// - /// - /// - /// - /// - public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder) - { - // FIXME MAYBE: We're not handling sortOrder! - - InventoryFolderImpl fold = null; - if ((fold = LibraryRoot.FindFolder(folderID)) != null) - { - remoteClient.SendInventoryFolderDetails( - LibraryRoot.Owner, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fetchFolders, fetchItems); - - return; - } - - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems); - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - - /// - /// Handle the caps inventory descendents fetch. - /// - /// Since the folder structure is sent to the client on login, I believe we only need to handle items. - /// - /// - /// - /// - /// - /// - /// - /// null if the inventory look up failed - public List HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder) - { -// m_log.DebugFormat( -// "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", -// fetchFolders, fetchItems, folderID, agentID); - - // FIXME MAYBE: We're not handling sortOrder! - - InventoryFolderImpl fold; - if ((fold = LibraryRoot.FindFolder(folderID)) != null) - { - return fold.RequestListOfItems(); - } - - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(agentID, out userProfile)) - { - // XXX: When a client crosses into a scene, their entire inventory is fetched - // asynchronously. If the client makes a request before the inventory is received, we need - // to give the inventory a chance to come in. - // - // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad - // in CAPS as doing this with the udp request, since here it won't hold up other packets. - // In fact, here we'll be generous and try for longer. - if (!userProfile.HasReceivedInventory) - { - int attempts = 0; - while (attempts++ < 30) - { - m_log.DebugFormat( - "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}", - attempts, folderID, agentID); - - Thread.Sleep(2000); - - if (userProfile.HasReceivedInventory) - { - break; - } - } - } - - if (userProfile.HasReceivedInventory) - { - if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null) - { - return fold.RequestListOfItems(); - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}", - folderID, agentID); - - return null; - } - } - else - { - m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID); - - return null; - } - } - else - { - m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID); - - return null; - } - } - - /// - /// This should delete all the items and folders in the given directory. - /// - /// - /// - public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) - { - CachedUserInfo userProfile; - - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (!userProfile.PurgeFolder(folderID)) - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } - - public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) - { - if (ownerID == LibraryRoot.Owner) - { - //Console.WriteLine("request info for library item"); - - return; - } - - CachedUserInfo userProfile; - if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) - { - if (userProfile.HasReceivedInventory) - { - InventoryItemBase item = null; - if ( userProfile.RootFolder == null ) - m_log.ErrorFormat( - "[AGENT INVENTORY]: User {0} {1} does not have a root folder.", - remoteClient.Name, remoteClient.AgentId); - else - item = userProfile.RootFolder.FindItem(itemID); - if (item != null) - { - remoteClient.SendInventoryItemDetails(ownerID, item); - } - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find user profile for {0} {1}", - remoteClient.Name, remoteClient.AgentId); - } - } } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs new file mode 100644 index 0000000..0d239aa --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using NUnit.Framework; + +namespace OpenSim.Framework.Communications.Tests +{ + /// + /// User profile cache service tests + /// + [TestFixture] + public class UserProfileCacheServiceTests + { + /// + /// Test folder moving. Doesn't do what is says on the tin yet + /// + [Test] + public void TestMoveFolder() + { + // Temporarily empty + } + } +} diff --git a/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs deleted file mode 100644 index 0d239aa..0000000 --- a/OpenSim/Framework/Communications/Tests/UserProfileCacheServiceTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using NUnit.Framework; - -namespace OpenSim.Framework.Communications.Tests -{ - /// - /// User profile cache service tests - /// - [TestFixture] - public class UserProfileCacheServiceTests - { - /// - /// Test folder moving. Doesn't do what is says on the tin yet - /// - [Test] - public void TestMoveFolder() - { - // Temporarily empty - } - } -} -- cgit v1.1 From c4b45449ee571d919836caaf57ab63ff10110335 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 17:23:55 +0000 Subject: * test: Add simple user profile test that checks for non-existing users --- .../Communications/Cache/UserProfileCacheService.cs | 6 +++++- .../Tests/Cache/UserProfileCacheServiceTests.cs | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 958ef4e..0cbb717 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -54,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// The root library folder. /// - public readonly LibraryRootFolder LibraryRoot; + public readonly InventoryFolderImpl LibraryRoot; /// /// Constructor @@ -70,6 +70,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// + /// + /// It isn't strictly necessary to make this call since user data can be lazily requested later on. However, + /// it might be helpful in order to avoid an initial response delay later on + /// /// public void AddNewUser(UUID userID) { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 0d239aa..03f4586 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -27,6 +27,11 @@ using System; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Communications.Local; +using OpenSim.Tests.Infra.Mock; namespace OpenSim.Framework.Communications.Tests { @@ -37,12 +42,19 @@ namespace OpenSim.Framework.Communications.Tests public class UserProfileCacheServiceTests { /// - /// Test folder moving. Doesn't do what is says on the tin yet + /// Test user details get. /// [Test] - public void TestMoveFolder() + public void TestGetUserDetails() { - // Temporarily empty + UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + + CommunicationsManager commsManager = new TestCommunicationsManager(); + ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + + CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly exists!"); } } } -- cgit v1.1 From 230eb06d34a36a61b7ca14bb0abb6274f3bc3b03 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 17:30:57 +0000 Subject: * Extend test to probe for user details that should exist --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 03f4586..62a42a9 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -48,13 +48,19 @@ namespace OpenSim.Framework.Communications.Tests public void TestGetUserDetails() { UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); CommunicationsManager commsManager = new TestCommunicationsManager(); - ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddPlugin(new TestUserDataPlugin()); ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); - Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly exists!"); + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); + CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId); + Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); } } } -- cgit v1.1 From bec39938491a2be01805627018c07430d0df4710 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 18:07:23 +0000 Subject: * Fold mock classes into existing OpenSim/Tests/Common assembly rather than sprouting another one --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 62a42a9..e496e45 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -31,7 +31,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; -using OpenSim.Tests.Infra.Mock; +using OpenSim.Tests.Common.Mock; namespace OpenSim.Framework.Communications.Tests { -- cgit v1.1 From 04a07daa5b4a19d61d70d63e32818ac65a322167 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 18:56:04 +0000 Subject: minor: Add request inventory test --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index e496e45..6fd9440 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -61,6 +61,27 @@ namespace OpenSim.Framework.Communications.Tests lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId); Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); - } + } + + /// + /// Test moving a folder + /// + [Test] + public void TestRequestInventoryForUser() + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000003"); + + CommunicationsManager commsManager = new TestCommunicationsManager(); + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddPlugin(new TestUserDataPlugin()); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); + + commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + Assert.That(userInfo.HasReceivedInventory, Is.True); + } } } -- cgit v1.1 From c9aabe2b9015475b71b7f29da28110ee5eacc1e2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 19:11:19 +0000 Subject: * Pop in a missing using statement without which UserProfileCacheServiceTests.cs fails on Windows (but not mono) --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 6fd9440..054c746 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -29,6 +29,7 @@ using System; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; @@ -64,7 +65,7 @@ namespace OpenSim.Framework.Communications.Tests } /// - /// Test moving a folder + /// Test requesting inventory for a user /// [Test] public void TestRequestInventoryForUser() @@ -83,5 +84,13 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); Assert.That(userInfo.HasReceivedInventory, Is.True); } + + /// + /// Test moving an inventory folder + /// + [Test] + public void TestMoveFolder() + { + } } } -- cgit v1.1 From 30213e141bf41e1240d5bceb42a154dacc05e643 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 19:57:12 +0000 Subject: * Add create folder userinfo test --- .../Communications/Cache/InventoryFolderImpl.cs | 2 +- .../Tests/Cache/UserProfileCacheServiceTests.cs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 83ac239..ad55c44 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Create a new subfolder. This exists only in the cache. + /// Create a new subfolder. /// /// /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 054c746..d73d3d5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -89,8 +89,28 @@ namespace OpenSim.Framework.Communications.Tests /// Test moving an inventory folder /// [Test] - public void TestMoveFolder() + public void TestCreateFolder() { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000004"); + + CommunicationsManager commsManager = new TestCommunicationsManager(); + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddPlugin(new TestUserDataPlugin()); + TestInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); + + commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + + UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); + Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.False); + + userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); + Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.True); } } } -- cgit v1.1 From f23856a575bf6c72de56a1eee60eca72f1724df0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 20:36:46 +0000 Subject: * Add get child folder test --- .../Communications/Cache/InventoryFolderImpl.cs | 17 ++++++++++++++ .../Tests/Cache/UserProfileCacheServiceTests.cs | 27 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index ad55c44..933d40a 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -107,6 +107,23 @@ namespace OpenSim.Framework.Communications.Cache } /// + /// Get a child folder + /// + /// + /// The folder if it exists, null if it doesn't + public InventoryFolderImpl GetChildFolder(UUID folderID) + { + InventoryFolderImpl folder = null; + + lock (SubFolders) + { + SubFolders.TryGetValue(folderID, out folder); + } + + return folder; + } + + /// /// Removes the given child subfolder. /// /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index d73d3d5..f209fd4 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -112,5 +112,32 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.True); } + + /// + /// Test retrieving a child folder + /// + [Test] + public void TestGetChildFolder() + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); + + CommunicationsManager commsManager = new TestCommunicationsManager(); + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddPlugin(new TestUserDataPlugin()); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); + + commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + + UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); + + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); + userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); + } } } -- cgit v1.1 From 80e267dcfec335c5402922c4eb5587df9603f94d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 20:58:11 +0000 Subject: * refactor: Stop exposing InventoryFolderImpl.SubFolders publicly --- .../Communications/Cache/CachedUserInfo.cs | 45 +++++------ .../Communications/Cache/InventoryFolderImpl.cs | 93 ++++++++++++++-------- .../Communications/Cache/LibraryRootFolder.cs | 2 +- .../Tests/Cache/UserProfileCacheServiceTests.cs | 4 +- 4 files changed, 84 insertions(+), 60 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d3e715f..d597aad 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -161,29 +161,27 @@ namespace OpenSim.Framework.Communications.Cache List resolvedFolders = new List(); // Folders we've resolved with this invocation foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID]) { - lock (parentFolder.SubFolders) + if (parentFolder.ContainsChildFolder(folder.ID)) { - if (parentFolder.SubFolders.ContainsKey(folder.ID)) + m_log.WarnFormat( + "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", + folder.Name, folder.ID); + } + else + { + if (resolvedFolderDictionary.ContainsKey(folder.ID)) { m_log.WarnFormat( - "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", + "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", folder.Name, folder.ID); } else { - if ( resolvedFolderDictionary.ContainsKey( folder.ID ) ) { - m_log.WarnFormat( - "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", - folder.Name, folder.ID); - } - else - { - resolvedFolders.Add(folder); - resolvedFolderDictionary[folder.ID] = folder; - parentFolder.SubFolders.Add(folder.ID, folder); - } - } - } // lock (parentFolder.SubFolders) + resolvedFolders.Add(folder); + resolvedFolderDictionary[folder.ID] = folder; + parentFolder.AddChildFolder(folder); + } + } } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) receivedFolderDictionary.Remove(parentFolder.ID); @@ -738,20 +736,17 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Find an appropriate folder for the given asset type + /// + /// + /// null if no appropriate folder exists public InventoryFolderImpl FindFolderForType(int type) { if (RootFolder == null) return null; - lock (RootFolder.SubFolders) - { - foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values) - { - if (f.Type == type) - return f; - } - } - return null; + return RootFolder.FindFolderForType(type); } } diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 933d40a..4c629f4 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Child folders that are contained in this folder /// - public Dictionary SubFolders = new Dictionary(); + protected Dictionary m_childFolders = new Dictionary(); // Constructors public InventoryFolderImpl(InventoryFolderBase folderbase) @@ -74,9 +74,9 @@ namespace OpenSim.Framework.Communications.Cache /// The newly created subfolder. Returns null if the folder already exists public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) { - lock (SubFolders) + lock (m_childFolders) { - if (!SubFolders.ContainsKey(folderID)) + if (!m_childFolders.ContainsKey(folderID)) { InventoryFolderImpl subFold = new InventoryFolderImpl(); subFold.Name = folderName; @@ -84,7 +84,7 @@ namespace OpenSim.Framework.Communications.Cache subFold.Type = (short) type; subFold.ParentID = this.ID; subFold.Owner = Owner; - SubFolders.Add(subFold.ID, subFold); + m_childFolders.Add(subFold.ID, subFold); return subFold; } @@ -99,14 +99,24 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddChildFolder(InventoryFolderImpl folder) { - lock (SubFolders) + lock (m_childFolders) { folder.ParentID = ID; - SubFolders[folder.ID] = folder; + m_childFolders[folder.ID] = folder; } } /// + /// Does this folder contain the given child folder? + /// + /// + /// + public bool ContainsChildFolder(UUID folderID) + { + return m_childFolders.ContainsKey(folderID); + } + + /// /// Get a child folder /// /// @@ -115,9 +125,9 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl folder = null; - lock (SubFolders) + lock (m_childFolders) { - SubFolders.TryGetValue(folderID, out folder); + m_childFolders.TryGetValue(folderID, out folder); } return folder; @@ -134,12 +144,12 @@ namespace OpenSim.Framework.Communications.Cache { InventoryFolderImpl removedFolder = null; - lock (SubFolders) + lock (m_childFolders) { - if (SubFolders.ContainsKey(folderID)) + if (m_childFolders.ContainsKey(folderID)) { - removedFolder = SubFolders[folderID]; - SubFolders.Remove(folderID); + removedFolder = m_childFolders[folderID]; + m_childFolders.Remove(folderID); } } @@ -151,12 +161,12 @@ namespace OpenSim.Framework.Communications.Cache /// public void Purge() { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { folder.Purge(); } - SubFolders.Clear(); + m_childFolders.Clear(); Items.Clear(); } @@ -175,9 +185,9 @@ namespace OpenSim.Framework.Communications.Cache } } - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { InventoryItemBase item = folder.FindItem(itemID); @@ -202,9 +212,9 @@ namespace OpenSim.Framework.Communications.Cache } } - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { InventoryItemBase item = folder.FindAsset(assetID); @@ -236,9 +246,9 @@ namespace OpenSim.Framework.Communications.Cache } } - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { found = folder.DeleteItem(itemID); @@ -262,9 +272,9 @@ namespace OpenSim.Framework.Communications.Cache if (folderID == ID) return this; - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { InventoryFolderImpl returnFolder = folder.FindFolder(folderID); @@ -274,7 +284,26 @@ namespace OpenSim.Framework.Communications.Cache } return null; - } + } + + /// + /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it. + /// + /// + /// Returns null if no such folder is found + public InventoryFolderImpl FindFolderForType(int type) + { + lock (m_childFolders) + { + foreach (InventoryFolderImpl f in m_childFolders.Values) + { + if (f.Type == type) + return f; + } + } + + return null; + } /// /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder @@ -297,9 +326,9 @@ namespace OpenSim.Framework.Communications.Cache string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { if (folder.Name == components[0]) if (components.Length > 1) @@ -344,9 +373,9 @@ namespace OpenSim.Framework.Communications.Cache } else { - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { if (folder.Name == components[0]) return folder.FindItemByPath(components[1]); @@ -385,9 +414,9 @@ namespace OpenSim.Framework.Communications.Cache { List folderList = new List(); - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderBase folder in SubFolders.Values) + foreach (InventoryFolderBase folder in m_childFolders.Values) { folderList.Add(folder); } @@ -400,9 +429,9 @@ namespace OpenSim.Framework.Communications.Cache { List folderList = new List(); - lock (SubFolders) + lock (m_childFolders) { - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { folderList.Add(folder); } @@ -421,7 +450,7 @@ namespace OpenSim.Framework.Communications.Cache { int total = Items.Count; - foreach (InventoryFolderImpl folder in SubFolders.Values) + foreach (InventoryFolderImpl folder in m_childFolders.Values) { total = total + folder.TotalCount; } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 437e5e4..cf3490b 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -142,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; libraryFolders.Add(folderInfo.ID, folderInfo); - parentFolder.SubFolders.Add(folderInfo.ID, folderInfo); + parentFolder.AddChildFolder(folderInfo); // m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); } diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index f209fd4..9c07734 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); - Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.False); + Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); - Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.True); + Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } /// -- cgit v1.1 From a7e145bdfdb994f4c171d32740790cffc3fc4ad3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 18:48:29 +0000 Subject: * refactor: pull out common user profile test code into utility functions --- .../Communications/Cache/CachedUserInfo.cs | 1 - .../Tests/Cache/UserProfileCacheServiceTests.cs | 61 ++++++---------------- 2 files changed, 16 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d597aad..b6ac6c9 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -141,7 +141,6 @@ namespace OpenSim.Framework.Communications.Cache } } - /// /// Recursively, in depth-first order, add all the folders we've received (stored /// in a dictionary indexed by parent ID) into the tree that describes user folder diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 9c07734..6632643 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -48,20 +48,17 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetUserDetails() { - UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); + + Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); + CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); - Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); - CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId); - Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); } /// @@ -70,18 +67,9 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestRequestInventoryForUser() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000003"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); Assert.That(userInfo.HasReceivedInventory, Is.True); } @@ -91,19 +79,12 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestCreateFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000004"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - TestInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); @@ -119,18 +100,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetChildFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); -- cgit v1.1 From b60d980f7ca1a986891a8503d87c90dcd8ab0cd2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 18:59:06 +0000 Subject: * Add file missing from last commit --- .../Tests/Cache/UserProfileTestUtils.cs | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs new file mode 100644 index 0000000..ea209fd --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Communications.Local; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Framework.Communications.Tests +{ + /// + /// Utility functions for carrying out user profile relate tests. + /// + public class UserProfileTestUtils + { + /// + /// Set up standard services required for user tests. + /// + /// CommunicationsManager used to access these services + public static CommunicationsManager SetupServices() + { + return SetupServices(new TestUserDataPlugin(), new TestInventoryDataPlugin()); + } + + /// + /// Set up standard services required for user tests. + /// + /// + /// + /// CommunicationsManager used to access these services + public static CommunicationsManager SetupServices( + IUserDataPlugin userDataPlugin, IInventoryDataPlugin inventoryDataPlugin) + { + CommunicationsManager commsManager = new TestCommunicationsManager(); + + ((LocalUserServices)commsManager.UserService).AddPlugin(userDataPlugin); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); + + return commsManager; + } + + /// + /// Create a test user with a standard inventory + /// + /// + /// + public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); + return CreateUserWithInventory(commsManager, userId); + } + + /// + /// Create a test user with a standard inventory + /// + /// + /// Explicit user id to use for user creation + /// + public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) + { + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); + + commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + + return commsManager.UserProfileCacheService.GetUserDetails(userId); + } + } +} -- cgit v1.1 From f8ce49875597bafb39642b62e2a61b644ecf489a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 19:04:10 +0000 Subject: * extend user profile create folder test to check that one can't create a folder with a non-existant parent folder id --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 6632643..a229e2a 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Communications.Tests } /// - /// Test moving an inventory folder + /// Test creating an inventory folder /// [Test] public void TestCreateFolder() @@ -89,7 +89,18 @@ namespace OpenSim.Framework.Communications.Tests UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); - userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + // 1: Try a folder create that should fail because the parent id given does not exist + UUID missingFolderId = UUID.Random(); + + Assert.That( + userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); + Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Null); + Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); + Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); + + // 2: Try a folder create that should work + Assert.That( + userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } -- cgit v1.1 From 7bbab121589a6e42e7744ffad37b35e62775b2f9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 19:24:45 +0000 Subject: * Add user info move inventory folder test --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 55 ++++++++++++++++++---- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index a229e2a..215fa81 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -72,6 +72,23 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.HasReceivedInventory, Is.True); } + + /// + /// Test retrieving a child folder + /// + [Test] + public void TestGetChildFolder() + { + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + + UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); + + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); + userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); + } /// /// Test creating an inventory folder @@ -104,22 +121,42 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } - + /// - /// Test retrieving a child folder + /// Test moving an inventory folder /// [Test] - public void TestGetChildFolder() + public void TestMoveFolder() { - CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + + UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); + UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); - UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); + InventoryFolderImpl rootFolder = userInfo.RootFolder; - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); - userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); + InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); + userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); + InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); - } + // Check folder is currently in folder1 + userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id); + Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True); + + userInfo.MoveFolder(folderToMoveId, folder2Id); + + // Check folder is now in folder2 and no trace remains in folder1 + Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); + Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id)); + + Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); + } } } -- cgit v1.1 From 9f6e567cb13a123ddaac4cc738594dd70c089c74 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 19:37:51 +0000 Subject: * add purge folder test --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 215fa81..2196d25 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -137,8 +137,7 @@ namespace OpenSim.Framework.Communications.Tests UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); - UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); - + UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); InventoryFolderImpl rootFolder = userInfo.RootFolder; userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); @@ -158,5 +157,29 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } + + /// + /// Test purging an inventory folder + /// + public void TestPurgeFolder() + { + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + + UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); + InventoryFolderImpl rootFolder = userInfo.RootFolder; + + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); + + // Test purge + userInfo.PurgeFolder(rootFolder.ID); + + Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); + Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Null); + } } } -- cgit v1.1 From 1531035b14367cfa44986e4a733524391d58af93 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 20:04:58 +0000 Subject: * Actually properly enable the purge folders test and correct some problems --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 2196d25..0914bfb 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -26,6 +26,7 @@ */ using System; +using log4net; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; @@ -161,8 +162,11 @@ namespace OpenSim.Framework.Communications.Tests /// /// Test purging an inventory folder /// + [Test] public void TestPurgeFolder() { + //log4net.Config.XmlConfigurator.Configure(); + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); @@ -174,6 +178,7 @@ namespace OpenSim.Framework.Communications.Tests InventoryFolderImpl rootFolder = userInfo.RootFolder; userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); + Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Not.Null); // Test purge userInfo.PurgeFolder(rootFolder.ID); -- cgit v1.1 From 42ec7f4935294da556201d3116555408823cee46 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 20:10:39 +0000 Subject: * minor: make AddRequest() protected since in principle it shouldn't be used outside the class and its descendents --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b6ac6c9..80fd1ae 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache /// is executed immediately instead. /// /// - public void AddRequest(IInventoryRequest request) + protected void AddRequest(IInventoryRequest request) { lock (m_pendingRequests) { -- cgit v1.1 From b1f018aa2600281cc379128f17c3c141b478f39d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 20:43:42 +0000 Subject: * Create update folder test * Correct small logic elidation --- .../Communications/Cache/CachedUserInfo.cs | 1 + .../Tests/Cache/UserProfileCacheServiceTests.cs | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 80fd1ae..dcf63cc 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -436,6 +436,7 @@ namespace OpenSim.Framework.Communications.Cache if (folder != null) { folder.Name = name; + folder.Type = (short)type; folder.ParentID = parentID; } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 0914bfb..41c8e3c 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -122,6 +122,38 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } + + /// + /// Test updating a folder + /// + [Test] + public void TestUpdateFolder() + { + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + + UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + InventoryFolderImpl rootFolder = userInfo.RootFolder; + + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); + + // 1: Test updates that don't involve moving the folder + string newFolderName1 = "newFolderName1"; + ushort folderType1 = (ushort)AssetType.Texture; + userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); + + InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); + Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); + Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); + + InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); + Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); + Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); + } /// /// Test moving an inventory folder -- cgit v1.1 From 71960f17bc7f5f80dc689ee9e215cfc5f1727e73 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 21:06:07 +0000 Subject: * Extend update test to test situation where it also moves the folder * Correct logic so that update folder behaves as expected --- .../Communications/Cache/CachedUserInfo.cs | 15 +++---- .../Tests/Cache/UserProfileCacheServiceTests.cs | 47 +++++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index dcf63cc..a1b658f 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -415,6 +415,12 @@ namespace OpenSim.Framework.Communications.Cache if (m_hasReceivedInventory) { + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); + + // Delegate movement if updated parent id isn't the same as the existing parentId + if (folder.ParentID != parentID) + MoveFolder(folderID, parentID); + InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = m_userProfile.ID; baseFolder.ID = folderID; @@ -432,13 +438,8 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager.InventoryService.UpdateFolder(baseFolder); } - InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - if (folder != null) - { - folder.Name = name; - folder.Type = (short)type; - folder.ParentID = parentID; - } + folder.Name = name; + folder.Type = (short)type; } else { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 41c8e3c..807afcc 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -142,17 +142,44 @@ namespace OpenSim.Framework.Communications.Tests userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); // 1: Test updates that don't involve moving the folder - string newFolderName1 = "newFolderName1"; - ushort folderType1 = (ushort)AssetType.Texture; - userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); - - InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); - Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); - Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); + { + string newFolderName1 = "newFolderName1"; + ushort folderType1 = (ushort)AssetType.Texture; + userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); + + InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); + Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); + Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); + + InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); + Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); + Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); + } + + // 2: Test an update that also involves moving the folder + { + UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061"); + userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); + InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); + + string newFolderName2 = "newFolderName2"; + ushort folderType2 = (ushort)AssetType.Bodypart; + userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); + + InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id); + Assert.That(newFolderName2, Is.EqualTo(folder1.Name)); + Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type)); + Assert.That(folder2Id, Is.EqualTo(folder1.ParentID)); + + Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); + Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); + + InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); + Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); + Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); + Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); + } - InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); - Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); - Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); } /// -- cgit v1.1 From 8fffdac7fa724c651935acb46725bc101cf8dfee Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 15 Dec 2008 20:45:40 +0000 Subject: Attempt at restoring inventory access after TPs/crossings. RemoveClient in Scene was being too aggressive at nixing the user out of the cache. We're now relying on NeedSceneCacheClear to decide whether to nix it or not. All other mods in other files are for better debugging messages. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index a1b658f..99a982b 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -194,6 +194,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void DropInventory() { + m_log.Debug("[INVENTORY CACHE]: DropInventory called"); // Make sure there aren't pending requests around when we do this // FIXME: There is still a race condition where an inventory operation can be requested (since these aren't being locked). // Will have to extend locking to exclude this very soon. -- cgit v1.1 From b4680f653dbc1c6f712898af79c4ea22bca3f678 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 17 Dec 2008 16:11:03 +0000 Subject: * Implement 'Save Object Back to My Inventory'. On the Linden client this is in the Tools menu available when editing an object * This facility allows you to save changes to an object that you've rezzed into a region back into their original inventory item without having to take a copy of the rezzed object. --- OpenSim/Framework/Communications/IUserService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index ecbbd32..206fb1e 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -109,7 +109,8 @@ namespace OpenSim.Framework.Communications void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz); /// - /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship + /// for UUID friendslistowner /// /// The agent that we're retreiving the friends Data. List GetUserFriendList(UUID friendlistowner); -- cgit v1.1 From 9af9f648efe5ec3b59d05a453e15cbe975ab24be Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 21 Dec 2008 02:25:14 +0000 Subject: Small null check in DeregisterHandlers. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index c83c2a6..91acfbe 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -221,9 +221,12 @@ namespace OpenSim.Framework.Communications.Capabilities /// public void DeregisterHandlers() { - foreach (string capsName in m_capsHandlers.Caps) + if (m_capsHandlers != null) { - m_capsHandlers.Remove(capsName); + foreach (string capsName in m_capsHandlers.Caps) + { + m_capsHandlers.Remove(capsName); + } } } -- cgit v1.1 From e9411a4c59113cfb41a6f73b0978652229690424 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 27 Dec 2008 21:50:19 +0000 Subject: * Eliminate a possible null reference from the LLSDLogin method. --- OpenSim/Framework/Communications/LoginService.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 24e9ca9..3f53c2f 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -379,7 +379,11 @@ namespace OpenSim.Framework.Communications return logResponse.CreateLoginFailedResponseLLSD(); } } + else + return logResponse.CreateLoginFailedResponseLLSD(); } + else + return logResponse.CreateLoginFailedResponseLLSD(); if (userProfile.GodLevel < m_minLoginLevel) -- cgit v1.1 From 266d0fbaaeac0dad06da98ceda8d19b8f3d732d6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 29 Dec 2008 16:56:48 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2927 with some changes * This allows configuration of the assetset and library control file paths to be other than ./inventory/Libraries.xml and ./assets/AssetSets.xml * This is controlled via the LibrariesXMLFile and AssetSetsXMLFile configuration settings in [StandAlone] in OpenSim.ini (in standalone) and via the user and asset config xml files for grid mode * Thanks to SirKimba for the patch --- .../Communications/Cache/AssetServerBase.cs | 4 ++-- .../Communications/Cache/LibraryRootFolder.cs | 27 ++++++++++------------ 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index a289fb7..137bde9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Cache } } - public virtual void LoadDefaultAssets() + public virtual void LoadDefaultAssets(string pAssetSetsXml) { m_log.Info("[ASSET SERVER]: Setting up asset database"); - assetLoader.ForEachDefaultXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); } public AssetServerBase() diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index cf3490b..0b05adf 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -52,11 +52,9 @@ namespace OpenSim.Framework.Communications.Cache /// protected Dictionary libraryFolders = new Dictionary(); - - public LibraryRootFolder() + + public LibraryRootFolder(string pLibrariesLocation) { - m_log.Info("[LIBRARY INVENTORY]: Loading library inventory"); - Owner = libOwner; ID = new UUID("00000112-000f-0000-0000-000100bba000"); Name = "OpenSim Library"; @@ -66,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache libraryFolders.Add(ID, this); - LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); + LoadLibraries(pLibrariesLocation); } public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, @@ -96,9 +94,7 @@ namespace OpenSim.Framework.Communications.Cache /// protected void LoadLibraries(string librariesControlPath) { - m_log.InfoFormat( - "[LIBRARY INVENTORY]: Loading libraries control file {0}", librariesControlPath); - + m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath); LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); } @@ -106,17 +102,18 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library set from config /// /// - protected void ReadLibraryFromConfig(IConfig config) + protected void ReadLibraryFromConfig(IConfig config, string path) { + string basePath = Path.GetDirectoryName(path); string foldersPath = Path.Combine( - Util.inventoryDir(), config.GetString("foldersFile", String.Empty)); + basePath, config.GetString("foldersFile", String.Empty)); LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); string itemsPath = Path.Combine( - Util.inventoryDir(), config.GetString("itemsFile", String.Empty)); + basePath, config.GetString("itemsFile", String.Empty)); LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); } @@ -125,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library inventory folder from a loaded configuration /// /// - private void ReadFolderFromConfig(IConfig config) + private void ReadFolderFromConfig(IConfig config, string path) { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); @@ -158,7 +155,7 @@ namespace OpenSim.Framework.Communications.Cache /// Read a library inventory item metadata from a loaded configuration /// /// - private void ReadItemFromConfig(IConfig config) + private void ReadItemFromConfig(IConfig config, string path) { InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; @@ -195,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache } } - private delegate void ConfigAction(IConfig config); + private delegate void ConfigAction(IConfig config, string path); /// /// Load the given configuration at a path and perform an action on each Config contained within it @@ -213,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < source.Configs.Count; i++) { - action(source.Configs[i]); + action(source.Configs[i], path); } } catch (XmlException e) -- cgit v1.1 From 158de95bde7cdee09334c40baee5122fd8f196e2 Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 3 Jan 2009 07:05:33 +0000 Subject: Another interregion comms change that will not work well with previous versions. This commit moves InformRegionOfChildAgent from OGS1 to RESTComms, effectively having the complete child agent life cycle over REST: create=POST, update=PUT, close=DELETE. Additional changes include more functions in the IHyperlink interface, and some refactorings in the HG code for better reuse in RESTComms. --- OpenSim/Framework/Communications/IHyperlink.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs index 02ba2c2..fa088d6 100644 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -38,5 +38,7 @@ namespace OpenSim.Framework.Communications bool IsHyperlinkRegion(ulong handle); RegionInfo GetHyperlinkRegion(ulong handle); ulong FindRegionHandle(ulong handle); + bool SendUserInformation(RegionInfo region, AgentCircuitData aCircuit); + void AdjustUserInformation(AgentCircuitData aCircuit); } } -- cgit v1.1 From 0b8d22ab544910a2b9b89b4bee2926a90b0da63f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 16:30:35 +0000 Subject: * Check in login service tests beachhead --- OpenSim/Framework/Communications/LoginService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 3f53c2f..b2434c2 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -160,7 +160,7 @@ namespace OpenSim.Framework.Communications else { m_log.Info( - "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); + "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); return logResponse.CreateGridErrorResponse(); } @@ -259,25 +259,25 @@ namespace OpenSim.Framework.Communications StatsManager.UserStats.AddSuccessfulLogin(); m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", firstname, lastname); return logResponse.ToXmlRpcResponse(); } else { - m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); + m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); return logResponse.CreateDeadRegionResponse(); } } catch (Exception e) { - m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); + m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); m_log.Error(e.StackTrace); } } - m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); + m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); return response; } finally @@ -329,7 +329,7 @@ namespace OpenSim.Framework.Communications userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); return false; } -- cgit v1.1 From 04ffcce7ea4fd303cd05e31aa8ece999c17f45b0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 17:38:39 +0000 Subject: * Extend stub to test the successful login of a user on the local login service * Test does not do authentication --- OpenSim/Framework/Communications/LoginService.cs | 2 - .../Communications/Tests/LoginServiceTests.cs | 96 ++++++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Framework/Communications/Tests/LoginServiceTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index b2434c2..f34f10c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -117,8 +117,6 @@ namespace OpenSim.Framework.Communications bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - - //bool GoodLogin; string startLocationRequest = "last"; diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs new file mode 100644 index 0000000..51adba1 --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -0,0 +1,96 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Net; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using Nwc.XmlRpc; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Communications.Local; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Framework.Communications.Tests +{ + /// + /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService + /// is abstract + /// + [TestFixture] + public class LoginServiceTests + { + /// + /// Test the normal response to a login. Does not test authentication. Doesn't yet do what it says on the tin. + /// + [Test] + public void TestNormalLoginResponse() + { + log4net.Config.XmlConfigurator.Configure(); + + string firstName = "Timmy"; + string lastName = "Mallet"; + + CommunicationsManager commsManager + = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); + + ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + + commsManager.GridService.RegisterRegion( + new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); + commsManager.GridService.RegionLoginsEnabled = true; + + LoginService loginService + = new LocalLoginService( + (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, + (LocalBackEndServices)commsManager.GridService, + commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); + + Hashtable loginParams = new Hashtable(); + loginParams["first"] = firstName; + loginParams["last"] = lastName; + loginParams["passwd"] = "boingboing"; + + ArrayList sendParams = new ArrayList(); + sendParams.Add(loginParams); + + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); + + XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + + // TODO: Not check inventory part of response yet. + // TODO: Not checking all of login response thoroughly yet. + + Assert.That( + responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); + Assert.That(responseData["first_name"], Is.EqualTo(firstName)); + Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + } + } +} -- cgit v1.1 From 0b07c9762b4c70b6d234b70fb9e591c770dc1bf1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 18:00:53 +0000 Subject: * Simplify test code by always setting up mock 'in memory' user and inventory data plugins for every TestCommunicationsManager * imo the gain in simplcity of test code outweighs the very small cost of setting up some stuff that some tests will never use --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 40 +++++++++++----------- .../Tests/Cache/UserProfileTestUtils.cs | 28 +-------------- .../Communications/Tests/LoginServiceTests.cs | 5 +-- 3 files changed, 22 insertions(+), 51 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 807afcc..44a28a2 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -52,7 +52,7 @@ namespace OpenSim.Framework.Communications.Tests UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestRequestInventoryForUser() { - CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); Assert.That(userInfo.HasReceivedInventory, Is.True); @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetChildFolder() { - CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); @@ -96,12 +96,12 @@ namespace OpenSim.Framework.Communications.Tests /// [Test] public void TestCreateFolder() - { - IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); - IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + { + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + + IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; + IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - CommunicationsManager commsManager - = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); @@ -129,11 +129,11 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestUpdateFolder() { - IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); - IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + + IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; + IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - CommunicationsManager commsManager - = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); @@ -188,11 +188,11 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestMoveFolder() { - IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); - IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + + IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; + IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - CommunicationsManager commsManager - = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); @@ -226,11 +226,11 @@ namespace OpenSim.Framework.Communications.Tests { //log4net.Config.XmlConfigurator.Configure(); - IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); - IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + + IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; + IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - CommunicationsManager commsManager - = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index ea209fd..cf07ae5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -37,33 +37,7 @@ namespace OpenSim.Framework.Communications.Tests /// Utility functions for carrying out user profile relate tests. /// public class UserProfileTestUtils - { - /// - /// Set up standard services required for user tests. - /// - /// CommunicationsManager used to access these services - public static CommunicationsManager SetupServices() - { - return SetupServices(new TestUserDataPlugin(), new TestInventoryDataPlugin()); - } - - /// - /// Set up standard services required for user tests. - /// - /// - /// - /// CommunicationsManager used to access these services - public static CommunicationsManager SetupServices( - IUserDataPlugin userDataPlugin, IInventoryDataPlugin inventoryDataPlugin) - { - CommunicationsManager commsManager = new TestCommunicationsManager(); - - ((LocalUserServices)commsManager.UserService).AddPlugin(userDataPlugin); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); - - return commsManager; - } - + { /// /// Create a test user with a standard inventory /// diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 51adba1..1e1fa73 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestNormalLoginResponse() { - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); string firstName = "Timmy"; string lastName = "Mallet"; @@ -58,9 +58,6 @@ namespace OpenSim.Framework.Communications.Tests CommunicationsManager commsManager = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); - ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - commsManager.GridService.RegisterRegion( new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); commsManager.GridService.RegionLoginsEnabled = true; -- cgit v1.1 From fcab408cc49508efb85d612029dee271a88d13d0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 18:30:56 +0000 Subject: * Add seed cap check to login test --- .../Communications/Tests/LoginServiceTests.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 1e1fa73..2dc644a 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Net; +using System.Text.RegularExpressions; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using Nwc.XmlRpc; @@ -43,9 +44,9 @@ namespace OpenSim.Framework.Communications.Tests /// [TestFixture] public class LoginServiceTests - { + { /// - /// Test the normal response to a login. Does not test authentication. Doesn't yet do what it says on the tin. + /// Test the normal response to a login. Does not test authentication. /// [Test] public void TestNormalLoginResponse() @@ -54,12 +55,14 @@ namespace OpenSim.Framework.Communications.Tests string firstName = "Timmy"; string lastName = "Mallet"; + string regionExternalName = "localhost"; + IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); CommunicationsManager commsManager = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); commsManager.GridService.RegisterRegion( - new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); + new RegionInfo(42, 43, capsEndPoint, regionExternalName)); commsManager.GridService.RegionLoginsEnabled = true; LoginService loginService @@ -84,10 +87,17 @@ namespace OpenSim.Framework.Communications.Tests // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. + Assert.That(responseData["first_name"], Is.EqualTo(firstName)); + Assert.That(responseData["last_name"], Is.EqualTo(lastName)); Assert.That( responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); - Assert.That(responseData["first_name"], Is.EqualTo(firstName)); - Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + + Regex capsSeedPattern + = new Regex("^http://" + + regionExternalName + + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + + Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); } } } -- cgit v1.1 From 9d62dee531624880a87f2882ae75eaf1191a29fc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 18:52:43 +0000 Subject: * Add prereqs and usings required by the Windows compiler --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 2dc644a..a78e093 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -29,6 +29,8 @@ using System; using System.Collections; using System.Net; using System.Text.RegularExpressions; +using System.Xml; +using Nini; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using Nwc.XmlRpc; -- cgit v1.1 From e7ac639f3a8a05858df03a8b5fd611826a56ae97 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 5 Jan 2009 19:36:48 +0000 Subject: * Centralize references to the well known blank texture 5748decc-f629-461c-9a36-a35a221fe21f to a constant in OpenSim.Framework.Util --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index a78e093..6c18d06 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -95,9 +95,8 @@ namespace OpenSim.Framework.Communications.Tests responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); Regex capsSeedPattern - = new Regex("^http://" - + regionExternalName - + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + = new Regex("^http://" + regionExternalName + ":" + NetworkServersInfo.DefaultHttpListenerPort + + "/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); } -- cgit v1.1 From 47a693ff1a9379c9f18e9bfcc51725ed20045a62 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 15:26:30 +0000 Subject: * remove mono compiler warnings --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 44a28a2..827a03b 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -98,8 +98,6 @@ namespace OpenSim.Framework.Communications.Tests public void TestCreateFolder() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); - - IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); @@ -130,8 +128,6 @@ namespace OpenSim.Framework.Communications.Tests public void TestUpdateFolder() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); - - IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); @@ -189,8 +185,6 @@ namespace OpenSim.Framework.Communications.Tests public void TestMoveFolder() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); - - IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); @@ -227,8 +221,6 @@ namespace OpenSim.Framework.Communications.Tests //log4net.Config.XmlConfigurator.Configure(); TestCommunicationsManager commsManager = new TestCommunicationsManager(); - - IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); -- cgit v1.1 From 251387a391eb2a40a397eaedb027d9d348c2504c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 16:39:08 +0000 Subject: * Remove unused CAPSService --- OpenSim/Framework/Communications/CAPSService.cs | 55 ------------------------- 1 file changed, 55 deletions(-) delete mode 100644 OpenSim/Framework/Communications/CAPSService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs deleted file mode 100644 index 0507173..0000000 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenSim.Framework.Servers; - -namespace OpenSim.Framework.Communications -{ - public class CAPSService - { - private readonly BaseHttpServer m_server; - - public CAPSService(BaseHttpServer httpServer) - { - m_server = httpServer; - AddCapsSeedHandler("/CapsSeed/", CapsRequest); - } - - private void AddCapsSeedHandler(string path, RestMethod restMethod) - { - m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); - } - - public string CapsRequest(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - System.Console.WriteLine("new caps request " + request + " from path " + path); - return String.Empty; - } - } -} -- cgit v1.1 From e8dba512473a09d6215b04d96e6fa5716a233628 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 17:30:37 +0000 Subject: * Yeah, might just want to add the new class as well - sigh --- .../Communications/Capabilities/CapsUtil.cs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 OpenSim/Framework/Communications/Capabilities/CapsUtil.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs new file mode 100644 index 0000000..cbd6465 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Capabilities +{ + /// + /// Capabilities utility methods + /// + public class CapsUtil + { + public static string GetRandomCapsPath() + { + UUID caps = UUID.Random(); + string capsPath = caps.ToString(); + capsPath = capsPath.Remove(capsPath.Length - 4, 4); + return capsPath; + } + } +} -- cgit v1.1 From 715a776f7d62d2af7610dbd3137e3e753fdbc25c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 18:06:53 +0000 Subject: * Move common string aggregation for caps seed path to a method in CapsUtil --- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index cbd6465..27ce402 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -35,6 +35,16 @@ namespace OpenSim.Framework.Communications.Capabilities /// public class CapsUtil { + /// + /// Generate a CAPS seed path using a previously generated CAPS object path component + /// + /// + /// + public static string GetCapsSeedPath(string capsObjectPath) + { + return "/CAPS/" + capsKey + "0000/"; + } + public static string GetRandomCapsPath() { UUID caps = UUID.Random(); -- cgit v1.1 From 498cd4f9874ba45825b8018a340fce189ba318e2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 18:12:22 +0000 Subject: * Fix build break - forgot that I had renamed an argument --- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index 27ce402..fe9780d 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// public static string GetCapsSeedPath(string capsObjectPath) { - return "/CAPS/" + capsKey + "0000/"; + return "/CAPS/" + capsObjectPath + "0000/"; } public static string GetRandomCapsPath() -- cgit v1.1 From 31b0f07085eafd63039681b6c57aca289b9fe532 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 18:26:27 +0000 Subject: * Rename GetRandomCapsPath() to GetRandomCapsObjectPath() to fit in with terminology used elsewhere * Last build break was probably a Bamboo failure - hopefully this should succeed --- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index fe9780d..829b4e5 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -45,7 +45,11 @@ namespace OpenSim.Framework.Communications.Capabilities return "/CAPS/" + capsObjectPath + "0000/"; } - public static string GetRandomCapsPath() + /// + /// Get a random CAPS object path component that will be used as the identifying part of all future CAPS requests + /// + /// + public static string GetRandomCapsObjectPath() { UUID caps = UUID.Random(); string capsPath = caps.ToString(); -- cgit v1.1 From a31792ee5cb1ce619f21f5b428926c4709c3f14b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 6 Jan 2009 21:39:55 +0000 Subject: * prune and regrade log messages relating to client login and logout --- .../Communications/Cache/UserProfileCacheService.cs | 3 +-- OpenSim/Framework/Communications/Capabilities/Caps.cs | 12 ++++++++---- OpenSim/Framework/Communications/UserManagerBase.cs | 3 --- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 0cbb717..22aab10 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache if (userID == UUID.Zero) return; - m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); + //m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); GetUserDetails(userID); } @@ -95,7 +95,6 @@ namespace OpenSim.Framework.Communications.Cache { if (m_userProfiles.ContainsKey(userId)) { - m_log.DebugFormat("[USER CACHE]: Removing user {0}", userId); m_userProfiles.Remove(userId); return true; } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 91acfbe..6adf68c 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -157,7 +157,9 @@ namespace OpenSim.Framework.Communications.Capabilities { // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); - m_log.Warn("[SEED]: " + capsBase + m_requestPath); + m_log.DebugFormat( + "[CAPS]: Registering seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); + //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, @@ -209,7 +211,7 @@ namespace OpenSim.Framework.Communications.Capabilities public void RegisterHandler(string capName, IRequestHandler handler) { m_capsHandlers[capName] = handler; - m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); + //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); } /// @@ -242,10 +244,12 @@ namespace OpenSim.Framework.Communications.Capabilities public string CapsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); - //Console.WriteLine("caps request " + request); + //m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); + string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); + //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); + return result; } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 3f2b902..2e3efd5 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -547,9 +547,6 @@ namespace OpenSim.Framework.Communications if (userProfile != null) { - // This line needs to be in side the above if statement or the UserServer will crash on some logouts. - m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + position.X + "," + position.Y + "," + position.Z + ")"); - UserAgentData userAgent = userProfile.CurrentAgent; if (userAgent != null) { -- cgit v1.1 From d770bea2912e9fe02644183dce424193fe87ab7d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 12 Jan 2009 15:33:56 +0000 Subject: Enhanced LoginServiceTests to test for authentication and response Expanded TestUserDataPlugin to cover new methods From: Arthur Rodrigo S Valadares --- .../Communications/Tests/LoginServiceTests.cs | 215 +++++++++++++++++++-- 1 file changed, 197 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 6c18d06..8111add 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -44,35 +44,35 @@ namespace OpenSim.Framework.Communications.Tests /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService /// is abstract /// - [TestFixture] + [TestFixture] public class LoginServiceTests - { + { /// /// Test the normal response to a login. Does not test authentication. - /// + /// [Test] - public void TestNormalLoginResponse() + public void T010_NormalLoginResponse() { //log4net.Config.XmlConfigurator.Configure(); - + string firstName = "Timmy"; string lastName = "Mallet"; string regionExternalName = "localhost"; IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); - CommunicationsManager commsManager + CommunicationsManager commsManager = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); - + commsManager.GridService.RegisterRegion( new RegionInfo(42, 43, capsEndPoint, regionExternalName)); commsManager.GridService.RegionLoginsEnabled = true; - - LoginService loginService + + LoginService loginService = new LocalLoginService( - (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, - (LocalBackEndServices)commsManager.GridService, + (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, + (LocalBackEndServices)commsManager.GridService, commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); - + Hashtable loginParams = new Hashtable(); loginParams["first"] = firstName; loginParams["last"] = lastName; @@ -85,20 +85,199 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); Hashtable responseData = (Hashtable)response.Value; - + + Assert.That(responseData["first_name"], Is.EqualTo(firstName)); + Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + Assert.That( + responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); + + Regex capsSeedPattern + = new Regex("^http://" + + regionExternalName + + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + + Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); + } + + [Test] + public void T011_Auth_Login() + { + string firstName = "Adam"; + string lastName = "West"; + string regionExternalName = "localhost"; + IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); + + CommunicationsManager commsManager + = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); + + commsManager.GridService.RegisterRegion( + new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + commsManager.GridService.RegionLoginsEnabled = true; + + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + + lus.AddUser(firstName,lastName,"boingboing","abc@ftw.com",42,43); + + + LoginService loginService + = new LocalLoginService( + (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, + (LocalBackEndServices)commsManager.GridService, + commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); + + // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. - + + // 1) Test for positive authentication + + Hashtable loginParams = new Hashtable(); + loginParams["first"] = firstName; + loginParams["last"] = lastName; + loginParams["passwd"] = "boingboing"; + + ArrayList sendParams = new ArrayList(); + sendParams.Add(loginParams); + + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); + + XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + + UserProfileData uprof = lus.GetUserProfile(firstName,lastName); + + UserAgentData uagent = uprof.CurrentAgent; + Assert.That(uagent,Is.Not.Null); + + Assert.That(responseData["first_name"], Is.Not.Null); Assert.That(responseData["first_name"], Is.EqualTo(firstName)); Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + Assert.That(responseData["agent_id"], Is.EqualTo(uagent.ProfileID.ToString())); + Assert.That(responseData["session_id"], Is.EqualTo(uagent.SessionID.ToString())); + Assert.That(responseData["secure_session_id"], Is.EqualTo(uagent.SecureSessionID.ToString())); + ArrayList invlibroot = (ArrayList) responseData["inventory-lib-root"]; + Hashtable invlibroothash = (Hashtable) invlibroot[0]; + Assert.That(invlibroothash["folder_id"],Is.EqualTo("00000112-000f-0000-0000-000100bba000")); Assert.That( responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); + Assert.That(responseData["message"], Is.EqualTo("Hello folks")); + Assert.That(responseData["buddy-list"], Is.Empty); + Assert.That(responseData["start_location"], Is.EqualTo("last")); + + Regex capsSeedPattern + = new Regex("^http://" + + regionExternalName + + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + + Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); + + // 1.1) Test for budddies! + lus.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); + lus.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); + + UserProfileData friend1 = lus.GetUserProfile("Friend","Number1"); + UserProfileData friend2 = lus.GetUserProfile("Friend","Number2"); + lus.AddNewUserFriend(friend1.ID,uprof.ID,1); + lus.AddNewUserFriend(friend1.ID,friend2.ID,2); + + loginParams = new Hashtable(); + loginParams["first"] = "Friend"; + loginParams["last"] = "Number1"; + loginParams["passwd"] = "boingboing"; + + sendParams = new ArrayList(); + sendParams.Add(loginParams); + + request = new XmlRpcRequest("login_to_simulator", sendParams); + + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + + ArrayList friendslist = (ArrayList) responseData["buddy-list"]; + + Assert.That(friendslist,Is.Not.Null); + + + Hashtable buddy1 = (Hashtable) friendslist[0]; + Hashtable buddy2 = (Hashtable) friendslist[1]; + Assert.That(friendslist.Count, Is.EqualTo(2)); + Assert.That(uprof.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); + Assert.That(friend2.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); + + // 2) Test for negative authentication + // + string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; + string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; + string error_already_logged = "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner. " + + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; + string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; + // 2.1) Test for wrong user name + loginParams = new Hashtable(); + loginParams["first"] = lastName; + loginParams["last"] = firstName; + loginParams["passwd"] = "boingboing"; + + sendParams = new ArrayList(); + sendParams.Add(loginParams); + + request = new XmlRpcRequest("login_to_simulator", sendParams); + + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); + + // 2.2) Test for wrong password + loginParams = new Hashtable(); + loginParams["first"] = "Friend"; + loginParams["last"] = "Number2"; + loginParams["passwd"] = "boing"; + + sendParams = new ArrayList(); + sendParams.Add(loginParams); + + request = new XmlRpcRequest("login_to_simulator", sendParams); + + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); + + // 2.3) Bad XML + loginParams = new Hashtable(); + loginParams["first"] = "Friend"; + loginParams["banana"] = "Banana"; + loginParams["passwd"] = "boingboing"; + + sendParams = new ArrayList(); + sendParams.Add(loginParams); + + request = new XmlRpcRequest("login_to_simulator", sendParams); + + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); - Regex capsSeedPattern - = new Regex("^http://" + regionExternalName + ":" + NetworkServersInfo.DefaultHttpListenerPort - + "/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + // 2.4) Already logged in and sucessfull post login + loginParams = new Hashtable(); + loginParams["first"] = "Adam"; + loginParams["last"] = "West"; + loginParams["passwd"] = "boingboing"; + + sendParams = new ArrayList(); + sendParams.Add(loginParams); + + request = new XmlRpcRequest("login_to_simulator", sendParams); + + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); + + request = new XmlRpcRequest("login_to_simulator", sendParams); - Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); + response = loginService.XmlRpcLoginMethod(request); + responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo("Hello folks")); } } } -- cgit v1.1 From 1baa921463712306ba339a073c9fad493176cea0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 13 Jan 2009 18:35:20 +0000 Subject: * minor: remove some mono compiler warnings --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 8111add..ffa3c5f 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -212,7 +212,7 @@ namespace OpenSim.Framework.Communications.Tests "If this is not the case please wait for your session to timeout. " + "If this takes longer than a few minutes please contact the grid owner. " + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; - string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; + //string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; // 2.1) Test for wrong user name loginParams = new Hashtable(); loginParams["first"] = lastName; -- cgit v1.1 From 92e6bbcd63d08a8f2d6accf668f630165a924d1d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 19 Jan 2009 02:30:51 +0000 Subject: No longer append a "texture" parameter on texture asset requests. The asset server doesn't check for the existence of this parameter since r2744. --- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 1c947dc..e27c4f4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -56,8 +56,6 @@ namespace OpenSim.Framework.Communications.Cache RestClient rc = new RestClient(_assetServerUrl); rc.AddResourcePath("assets"); rc.AddResourcePath(req.AssetID.ToString()); - if (req.IsTexture) - rc.AddQueryParameter("texture"); rc.RequestMethod = "GET"; -- cgit v1.1 From 792ebca5f37a9d7f727530f063191b108d7634ee Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 21 Jan 2009 02:29:56 +0000 Subject: Set request method for REST requests with no input. --- OpenSim/Framework/Communications/RestClient.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7d45186..970f2a9 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -283,6 +283,7 @@ namespace OpenSim.Framework.Communications _request.KeepAlive = false; _request.ContentType = "application/xml"; _request.Timeout = 200000; + _request.Method = RequestMethod; _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); -- cgit v1.1 From 0e7aac0f65a66ac1d643962371b09d0f71a0ab09 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 21 Jan 2009 10:20:32 +0000 Subject: - remove extra "; in http_loginform.html.example; fix issue 3025 - sync up default HTML generated in LoginService.cs with that in http_loginform.html.example --- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index f34f10c..1abfc78 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -685,10 +685,10 @@ namespace OpenSim.Framework.Communications responseString += ""; responseString += "
Connecting...
"; - responseString += "
"; + responseString += "
"; responseString += "
[$channel] | [$version]=[$lang]
"; responseString += ""; -- cgit v1.1 From 37fa6775488ab237a4537d49b92a8d52b0497b98 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 21 Jan 2009 21:14:17 +0000 Subject: * refactor: Extract caps related code from scene and put into a region module * No functional changes in this revision --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6adf68c..a6acd68 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -158,7 +158,7 @@ namespace OpenSim.Framework.Communications.Capabilities // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.DebugFormat( - "[CAPS]: Registering seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); + "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", -- cgit v1.1 From 664f983943dd94d35184f5c0f69f8c58a011ba3a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 23 Jan 2009 19:24:36 +0000 Subject: * Extend archive test to check for the presence of a control file in a saved archive --- OpenSim/Framework/Communications/GenericAsyncResult.cs | 3 ++- OpenSim/Framework/Communications/LoginService.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index e85289a..62a921a 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -41,7 +41,7 @@ namespace OpenSim.Framework.Communications private byte m_completed; /// - /// Did process complete synchroneously? + /// Did process complete synchronously? /// /// I have a hard time imagining a scenario where this is the case, again, same issue about /// booleans and VolatileRead as m_completed @@ -87,6 +87,7 @@ namespace OpenSim.Framework.Communications } } } + return m_waitHandle; } } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 1abfc78..fe904b5 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -108,6 +108,7 @@ namespace OpenSim.Framework.Communications { // Temporary fix m_loginMutex.WaitOne(); + try { //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. -- cgit v1.1 From dbd2b4523319758c8c0e093a89be8bcb9b2e4ee1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 23 Jan 2009 20:38:44 +0000 Subject: * Write a simple archive loading test which doesn't actually do any testing yet apart from not blow up --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 436f175..653597b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -41,16 +41,12 @@ namespace OpenSim.Framework.Communications.Cache /// /// Manages local cache of assets and their sending to viewers. - /// + /// + /// /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and - /// AssetNotFound(), which means they do share the same asset and texture caches. - /// - /// TODO: Assets in this cache are effectively immortal (they are never disposed of through old age). - /// This is not a huge problem at the moment since other memory use usually dwarfs that used by assets - /// but it's something to bear in mind. - ///
+ /// AssetNotFound(), which means they do share the same asset and texture caches.I agr public class AssetCache : IAssetReceiver { protected ICache m_memcache = new SimpleMemoryCache(); -- cgit v1.1 From f8e45e8e981bfd87f3765d7452046515e11a9345 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:03 +0000 Subject: Rename IAssetProviderPlugin to IAssetDataPlugin aligning with the other data plugins. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 137bde9..7fb06b9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -43,9 +43,9 @@ namespace OpenSim.Framework.Communications.Cache protected IAssetReceiver m_receiver; protected BlockingQueue m_assetRequests; protected Thread m_localAssetServerThread; - protected IAssetProviderPlugin m_assetProvider; + protected IAssetDataPlugin m_assetProvider; - public IAssetProviderPlugin AssetProviderPlugin + public IAssetDataPlugin AssetProviderPlugin { get { return m_assetProvider; } } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 2f72e11..00dbad0 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache AddPlugin(pluginName, connect); } - public SQLAssetServer(IAssetProviderPlugin assetProvider) + public SQLAssetServer(IAssetDataPlugin assetProvider) { m_assetProvider = assetProvider; } @@ -54,12 +54,12 @@ namespace OpenSim.Framework.Communications.Cache { if (!pluginType.IsAbstract) { - Type typeInterface = pluginType.GetInterface("IAssetProviderPlugin", true); + Type typeInterface = pluginType.GetInterface("IAssetDataPlugin", true); if (typeInterface != null) { - IAssetProviderPlugin plug = - (IAssetProviderPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetDataPlugin plug = + (IAssetDataPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProvider = plug; m_assetProvider.Initialise(connect); -- cgit v1.1 From e12b0a249674bbe4b1980c74f13d8f09cc2e4432 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:16 +0000 Subject: - move IAssetDataPlugin from OpenSim/Framework/IAssetProvider.cs to OpenSim/Data/IAssetData.cs - remove some trailing whitespace --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 1 + OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7fb06b9..cc5ba8e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -32,6 +32,7 @@ using OpenMetaverse; using log4net; using OpenSim.Framework.AssetLoader.Filesystem; using OpenSim.Framework.Statistics; +using OpenSim.Data; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 00dbad0..6266bf0 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -28,6 +28,7 @@ using System; using System.Reflection; using log4net; +using OpenSim.Data; namespace OpenSim.Framework.Communications.Cache { -- cgit v1.1 From 9377c6f2b28c75a093fa554d64e0d63e6bdf2fa5 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:26 +0000 Subject: - move OpenSim/Framework/IInventoryData.cs to OpenSim/Data/IInventoryData.cs - trim trailing whitespace --- .../Communications/InventoryServiceBase.cs | 6 +- .../Tests/Cache/UserProfileCacheServiceTests.cs | 111 +++++++++++---------- 2 files changed, 60 insertions(+), 57 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 7a44420..ec5c493 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -33,6 +33,8 @@ using System.Threading; using OpenMetaverse; using log4net; +using OpenSim.Data; + namespace OpenSim.Framework.Communications { /// @@ -50,12 +52,12 @@ namespace OpenSim.Framework.Communications /// /// Add a new inventory data plugin - plugins will be requested in the order they were added. /// - /// The plugin that will provide data + /// The plugin that will provide data public void AddPlugin(IInventoryDataPlugin plugin) { m_plugins.Add(plugin); } - + /// /// Adds a new inventory data plugin - plugins will be requested in the order they were loaded. /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 827a03b..86d85b1 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -30,19 +30,20 @@ using log4net; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; -using OpenSim.Framework; +//using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; +using OpenSim.Data; namespace OpenSim.Framework.Communications.Tests -{ +{ /// /// User profile cache service tests /// - [TestFixture] + [TestFixture] public class UserProfileCacheServiceTests - { + { /// /// Test user details get. /// @@ -51,17 +52,17 @@ namespace OpenSim.Framework.Communications.Tests { UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); - + Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); - + CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); - - Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); + + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); } - + /// /// Test requesting inventory for a user /// @@ -69,11 +70,11 @@ namespace OpenSim.Framework.Communications.Tests public void TestRequestInventoryForUser() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Assert.That(userInfo.HasReceivedInventory, Is.True); } - + /// /// Test retrieving a child folder /// @@ -82,45 +83,45 @@ namespace OpenSim.Framework.Communications.Tests { TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - + UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); - - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); + + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); - + Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); - } - + } + /// /// Test creating an inventory folder /// [Test] public void TestCreateFolder() - { + { TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - - UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); + + UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); - + // 1: Try a folder create that should fail because the parent id given does not exist UUID missingFolderId = UUID.Random(); - + Assert.That( userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); - + // 2: Try a folder create that should work Assert.That( userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } - + /// /// Test updating a folder /// @@ -129,54 +130,54 @@ namespace OpenSim.Framework.Communications.Tests { TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - + UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); InventoryFolderImpl rootFolder = userInfo.RootFolder; - + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - + // 1: Test updates that don't involve moving the folder { string newFolderName1 = "newFolderName1"; ushort folderType1 = (ushort)AssetType.Texture; userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); - + InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); - + InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); } - + // 2: Test an update that also involves moving the folder { UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061"); userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); - + string newFolderName2 = "newFolderName2"; ushort folderType2 = (ushort)AssetType.Bodypart; userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); - + InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id); Assert.That(newFolderName2, Is.EqualTo(folder1.Name)); Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type)); Assert.That(folder2Id, Is.EqualTo(folder1.ParentID)); - + Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); - + InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); - Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); + Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); } - - } + + } /// /// Test moving an inventory folder @@ -186,32 +187,32 @@ namespace OpenSim.Framework.Communications.Tests { TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); - UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); + UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); InventoryFolderImpl rootFolder = userInfo.RootFolder; - + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); - + // Check folder is currently in folder1 userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id); Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True); - + userInfo.MoveFolder(folderToMoveId, folder2Id); - + // Check folder is now in folder2 and no trace remains in folder1 Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id)); - + Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } - + /// /// Test purging an inventory folder /// @@ -219,21 +220,21 @@ namespace OpenSim.Framework.Communications.Tests public void TestPurgeFolder() { //log4net.Config.XmlConfigurator.Configure(); - + TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - + UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); InventoryFolderImpl rootFolder = userInfo.RootFolder; - + userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Not.Null); - + // Test purge userInfo.PurgeFolder(rootFolder.ID); - + Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Null); } -- cgit v1.1 From d3eae4073e75d1482467eee54230df141bdbb568 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:35 +0000 Subject: - move OpenSim/Framework/IUserData.cs to OpenSim/Data/IUserData.cs - trim trailing whitespace --- .../Framework/Communications/UserManagerBase.cs | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 2e3efd5..b12abb3 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -35,8 +35,8 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; -using OpenSim.Framework; using OpenSim.Framework.Statistics; +using OpenSim.Data; namespace OpenSim.Framework.Communications { @@ -52,22 +52,22 @@ namespace OpenSim.Framework.Communications /// List of plugins to search for user data /// private List _plugins = new List(); - + protected IInterServiceInventoryServices m_interServiceInventoryService; - + /// /// Constructor /// /// public UserManagerBase(IInterServiceInventoryServices interServiceInventoryService) { - m_interServiceInventoryService = interServiceInventoryService; - } - + m_interServiceInventoryService = interServiceInventoryService; + } + /// /// Add a new user data plugin - plugins will be requested in the order they were added. /// - /// The plugin that will provide user data + /// The plugin that will provide user data public void AddPlugin(IUserDataPlugin plugin) { _plugins.Add(plugin); @@ -85,13 +85,13 @@ namespace OpenSim.Framework.Communications // loader will try to load all providers (MySQL, MSSQL, etc) // unless it is constrainted to the correct "Provider" entry in the addin.xml - loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider)); + loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider)); loader.Load(); _plugins.AddRange(loader.Plugins); } - #region Get UserProfile + #region Get UserProfile // see IUserService public UserProfileData GetUserProfile(string fname, string lname) @@ -109,7 +109,7 @@ namespace OpenSim.Framework.Communications return null; } - + public void LogoutUsers(UUID regionID) { foreach (IUserDataPlugin plugin in _plugins) @@ -117,7 +117,7 @@ namespace OpenSim.Framework.Communications plugin.LogoutUsers(regionID); } } - + public void ResetAttachments(UUID userID) { foreach (IUserDataPlugin plugin in _plugins) @@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications plugin.ResetAttachments(userID); } } - + public UserAgentData GetAgentByUUID(UUID userId) { foreach (IUserDataPlugin plugin in _plugins) @@ -140,7 +140,7 @@ namespace OpenSim.Framework.Communications return null; } - + // see IUserService public virtual UserProfileData GetUserProfile(UUID uuid) { @@ -173,7 +173,7 @@ namespace OpenSim.Framework.Communications return new List(); } } - + return pickerlist; } @@ -216,8 +216,8 @@ namespace OpenSim.Framework.Communications try { UserAgentData result = plugin.GetAgentByUUID(uuid); - - if (result != null) + + if (result != null) { return result; } @@ -288,8 +288,8 @@ namespace OpenSim.Framework.Communications try { List result = plugin.GetUserFriendList(ownerID); - - if (result != null) + + if (result != null) { return result; } @@ -310,8 +310,8 @@ namespace OpenSim.Framework.Communications try { Dictionary result = plugin.GetFriendRegionInfos(uuids); - - if (result != null) + + if (result != null) { return result; } @@ -396,7 +396,7 @@ namespace OpenSim.Framework.Communications { return; } - + profile.CurrentAgent = null; UpdateUserProfile(profile); @@ -623,7 +623,7 @@ namespace OpenSim.Framework.Communications string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); - + UserProfileData user = new UserProfileData(); user.HomeLocation = new Vector3(128, 128, 100); user.ID = SetUUID; @@ -657,9 +657,9 @@ namespace OpenSim.Framework.Communications else { m_interServiceInventoryService.CreateNewUserInventory(userProf.ID); - + return userProf.ID; - } + } } /// @@ -672,22 +672,22 @@ namespace OpenSim.Framework.Communications public bool ResetUserPassword(string firstName, string lastName, string newPassword) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); - + UserProfileData profile = GetUserProfile(firstName, lastName); - + if (null == profile) { m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName); return false; } - + profile.PasswordHash = md5PasswdHash; profile.PasswordSalt = String.Empty; - + UpdateUserProfile(profile); - + return true; - } + } public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); -- cgit v1.1 From d259238c748aafe366fd1d04e0248ef23116fd28 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 3 Feb 2009 05:20:44 +0000 Subject: - moved data plugin loading code from various places to OpenSim/Data/DataPluginFactory.cs - removed dependencies on a few executable assemblies in bin/OpenSim.Data.addin.xml - trim trailing whitespace --- .../Communications/InventoryServiceBase.cs | 20 +++++++++----------- OpenSim/Framework/Communications/UserManagerBase.cs | 21 +++++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index ec5c493..a031bdf 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -59,20 +59,18 @@ namespace OpenSim.Framework.Communications } /// - /// Adds a new inventory data plugin - plugins will be requested in the order they were loaded. + /// Adds a list of inventory data plugins, as described by `provider' + /// and `connect', to `m_plugins'. /// - /// The filename of the inventory server plugin DLL + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// public void AddPlugin(string provider, string connect) { - PluginLoader loader = - new PluginLoader (new InventoryDataInitialiser(connect)); - - // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.xml - loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter(provider)); - loader.Load(); - - m_plugins.AddRange(loader.Plugins); + m_plugins.AddRange(DataPluginFactory.LoadInventoryDataPlugins(provider, connect)); } #endregion diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b12abb3..886900d 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -74,21 +74,18 @@ namespace OpenSim.Framework.Communications } /// - /// Add a new user data plugin - plugins will be requested in the order they were added. + /// Adds a list of user data plugins, as described by `provider' and + /// `connect', to `_plugins'. /// - /// The filename to the user data plugin DLL - /// + /// + /// The filename of the inventory server plugin DLL. + /// + /// + /// The connection string for the storage backend. + /// public void AddPlugin(string provider, string connect) { - PluginLoader loader = - new PluginLoader(new UserDataInitialiser(connect)); - - // loader will try to load all providers (MySQL, MSSQL, etc) - // unless it is constrainted to the correct "Provider" entry in the addin.xml - loader.Add("/OpenSim/UserData", new PluginProviderFilter(provider)); - loader.Load(); - - _plugins.AddRange(loader.Plugins); + _plugins.AddRange(DataPluginFactory.LoadUserDataPlugins(provider, connect)); } #region Get UserProfile -- cgit v1.1 From 0c03a48fb2060eda4d288e2d2ca4e650ce000b4b Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 4 Feb 2009 00:01:36 +0000 Subject: - add OpenSim.Framework.AssetMetadata class. AssetBase is now composed of it - trim trailing whitespace --- .../Framework/Communications/Cache/AssetCache.cs | 84 +++++++++++----------- .../Communications/Cache/CryptoGridAssetClient.cs | 46 ++++++------ .../Communications/Cache/FileAssetClient.cs | 4 +- .../Communications/Cache/GridAssetClient.cs | 2 +- .../Framework/Communications/Capabilities/Caps.cs | 18 ++--- 5 files changed, 77 insertions(+), 77 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 653597b..2b2467c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Manages local cache of assets and their sending to viewers. /// - /// + /// /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache private Dictionary RequestLists; /// - /// The 'server' from which assets can be requested and to which assets are persisted. + /// The 'server' from which assets can be requested and to which assets are persisted. /// private readonly IAssetServer m_assetServer; @@ -211,7 +211,7 @@ namespace OpenSim.Framework.Communications.Cache else { // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - + NewAssetRequest req = new NewAssetRequest(callback); AssetRequestsList requestList; @@ -228,10 +228,10 @@ namespace OpenSim.Framework.Communications.Cache // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); requestList = new AssetRequestsList(); requestList.TimeRequested = DateTime.Now; - requestList.Requests.Add(req); - - RequestLists.Add(assetId, requestList); - + requestList.Requests.Add(req); + + RequestLists.Add(assetId, requestList); + m_assetServer.RequestAsset(assetId, isTexture); } } @@ -247,7 +247,7 @@ namespace OpenSim.Framework.Communications.Cache /// the allowed number of polls. This isn't a very good way of doing things since a single thread /// is processing inbound packets, so if the asset server is slow, we could block this for up to /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() - /// + /// /// /// /// null if the asset could not be retrieved @@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications.Cache { return asset; } - + m_assetServer.RequestAsset(assetID, isTexture); do @@ -275,7 +275,7 @@ namespace OpenSim.Framework.Communications.Cache { return asset; } - } + } while (--maxPolls > 0); m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", @@ -290,17 +290,17 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { - if (!m_memcache.Contains(asset.FullID)) + if (!m_memcache.Contains(asset.Metadata.FullID)) { - m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); + m_log.Info("[CACHE] Caching " + asset.Metadata.FullID + " for 24 hours from last access"); // Use 24 hour rolling asset cache. - m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); + m_memcache.AddOrUpdate(asset.Metadata.FullID, asset, TimeSpan.FromHours(24)); - // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the + // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the // information is stored locally. It could disappear, in which case we could send the - // ImageNotInDatabase packet to tell the client this. + // ImageNotInDatabase packet to tell the client this. // - // However, this doesn't quite appear to work with local textures that are part of an avatar's + // However, this doesn't quite appear to work with local textures that are part of an avatar's // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake // and reupload by the client, if those assets aren't pushed to the asset server anyway, then // on crossing onto another region server, other avatars can no longer get the required textures. @@ -314,7 +314,7 @@ namespace OpenSim.Framework.Communications.Cache // But for now, we're going to take the easy way out and store local assets globally. // // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. - if (!asset.Temporary || asset.Local) + if (!asset.Metadata.Temporary || asset.Metadata.Local) { m_assetServer.StoreAsset(asset); } @@ -345,25 +345,25 @@ namespace OpenSim.Framework.Communications.Cache { AssetInfo assetInf = new AssetInfo(asset); - if (!m_memcache.Contains(assetInf.FullID)) + if (!m_memcache.Contains(assetInf.Metadata.FullID)) { - m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); + m_memcache.AddOrUpdate(assetInf.Metadata.FullID, assetInf, TimeSpan.FromHours(24)); if (StatsManager.SimExtraStats != null) { StatsManager.SimExtraStats.AddAsset(assetInf); } - if (RequestedAssets.ContainsKey(assetInf.FullID)) + if (RequestedAssets.ContainsKey(assetInf.Metadata.FullID)) { - AssetRequest req = RequestedAssets[assetInf.FullID]; + AssetRequest req = RequestedAssets[assetInf.Metadata.FullID]; req.AssetInf = assetInf; req.NumPackets = CalculateNumPackets(assetInf.Data); - RequestedAssets.Remove(assetInf.FullID); + RequestedAssets.Remove(assetInf.Metadata.FullID); // If it's a direct request for a script, drop it // because it's a hacked client - if (req.AssetRequestSource != 2 || assetInf.Type != 10) + if (req.AssetRequestSource != 2 || assetInf.Metadata.Type != 10) AssetRequests.Add(req); } } @@ -373,8 +373,8 @@ namespace OpenSim.Framework.Communications.Cache lock (RequestLists) { - if (RequestLists.TryGetValue(asset.FullID, out reqList)) - RequestLists.Remove(asset.FullID); + if (RequestLists.TryGetValue(asset.Metadata.FullID, out reqList)) + RequestLists.Remove(asset.Metadata.FullID); } if (reqList != null) @@ -385,8 +385,8 @@ namespace OpenSim.Framework.Communications.Cache foreach (NewAssetRequest req in reqList.Requests) { // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked - // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); - req.Callback(asset.FullID, asset); + // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.Metadata.FullID); + req.Callback(asset.Metadata.FullID, asset); } } } @@ -398,12 +398,12 @@ namespace OpenSim.Framework.Communications.Cache // Remember the fact that this asset could not be found to prevent delays from repeated requests m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); - + // Notify requesters for this asset AssetRequestsList reqList; lock (RequestLists) { - if (RequestLists.TryGetValue(assetID, out reqList)) + if (RequestLists.TryGetValue(assetID, out reqList)) RequestLists.Remove(assetID); } @@ -411,7 +411,7 @@ namespace OpenSim.Framework.Communications.Cache { if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); - + foreach (NewAssetRequest req in reqList.Requests) { req.Callback(assetID, null); @@ -461,7 +461,7 @@ namespace OpenSim.Framework.Communications.Cache source = 3; //Console.WriteLine("asset request " + requestID); } - + //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); if (!m_memcache.Contains(requestID)) @@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications.Cache } // Scripts cannot be retrieved by direct request - if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) + if (transferRequest.TransferInfo.SourceType == 2 && asset.Metadata.Type == 10) return; // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list @@ -520,7 +520,7 @@ namespace OpenSim.Framework.Communications.Cache //no requests waiting return; } - + // if less than 5, do all of them int num = Math.Min(5, AssetRequests.Count); @@ -580,10 +580,10 @@ namespace OpenSim.Framework.Communications.Cache public AssetInfo(AssetBase aBase) { Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - Name = aBase.Name; - Description = aBase.Description; + Metadata.FullID = aBase.Metadata.FullID; + Metadata.Type = aBase.Metadata.Type; + Metadata.Name = aBase.Metadata.Name; + Metadata.Description = aBase.Metadata.Description; } } @@ -592,10 +592,10 @@ namespace OpenSim.Framework.Communications.Cache public TextureImage(AssetBase aBase) { Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - Name = aBase.Name; - Description = aBase.Description; + Metadata.FullID = aBase.Metadata.FullID; + Metadata.Type = aBase.Metadata.Type; + Metadata.Name = aBase.Metadata.Name; + Metadata.Description = aBase.Metadata.Description; } } @@ -608,7 +608,7 @@ namespace OpenSim.Framework.Communications.Cache /// A list of requests for assets /// public List Requests = new List(); - + /// /// Record the time that this request was first made. /// diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 3ed9172..1b3e70d 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -86,11 +86,11 @@ namespace OpenSim.Framework.Communications.Cache #region Rjindael /// - /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and + /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and /// decrypt data. As long as encryption and decryption routines use the same /// parameters to generate the keys, the keys are guaranteed to be the same. /// The class uses static functions with duplicate code to make it easier to - /// demonstrate encryption and decryption logic. In a real-life application, + /// demonstrate encryption and decryption logic. In a real-life application, /// this may not be the most efficient way of handling encryption, so - as /// soon as you feel comfortable with it - you may want to redesign this class. /// @@ -123,11 +123,11 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// Initialization vector (or IV). This value is required to encrypt the - /// first block of plaintext data. For RijndaelManaged class IV must be + /// first block of plaintext data. For RijndaelManaged class IV must be /// exactly 16 ASCII characters long. /// /// - /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. + /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. /// Longer keys are more secure than shorter keys. /// /// @@ -143,7 +143,7 @@ namespace OpenSim.Framework.Communications.Cache { // Convert strings into byte arrays. // Let us assume that strings only contain ASCII codes. - // If strings include Unicode characters, use Unicode, UTF7, or UTF8 + // If strings include Unicode characters, use Unicode, UTF7, or UTF8 // encoding. byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); @@ -153,8 +153,8 @@ namespace OpenSim.Framework.Communications.Cache byte[] plainTextBytes = plainText; // First, we must create a password, from which the key will be derived. - // This password will be generated from the specified passphrase and - // salt value. The password will be created using the specified hash + // This password will be generated from the specified passphrase and + // salt value. The password will be created using the specified hash // algorithm. Password creation can be done in several iterations. PasswordDeriveBytes password = new PasswordDeriveBytes( passPhrase, @@ -173,8 +173,8 @@ namespace OpenSim.Framework.Communications.Cache // (CBC). Use default options for other symmetric key parameters. symmetricKey.Mode = CipherMode.CBC; - // Generate encryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key + // Generate encryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key // bytes. ICryptoTransform encryptor = symmetricKey.CreateEncryptor( keyBytes, @@ -265,8 +265,8 @@ namespace OpenSim.Framework.Communications.Cache // Convert our ciphertext into a byte array. byte[] cipherTextBytes = cipherText; - // First, we must create a password, from which the key will be - // derived. This password will be generated from the specified + // First, we must create a password, from which the key will be + // derived. This password will be generated from the specified // passphrase and salt value. The password will be created using // the specified hash algorithm. Password creation can be done in // several iterations. @@ -286,8 +286,8 @@ namespace OpenSim.Framework.Communications.Cache // (CBC). Use default options for other symmetric key parameters. symmetricKey.Mode = CipherMode.CBC; - // Generate decryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key + // Generate decryptor from the existing key bytes and initialization + // vector. Key size will be defined based on the number of the key // bytes. ICryptoTransform decryptor = symmetricKey.CreateDecryptor( keyBytes, @@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache for (i = 0; i < decryptedByteCount; i++) plainText[i] = plainTextBytes[i]; - // Return decrypted string. + // Return decrypted string. return plainText; } } @@ -403,17 +403,17 @@ namespace OpenSim.Framework.Communications.Cache string salt = Convert.ToBase64String(rand); x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); - x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", - "OPENSIM_AES_AF1", - file.AlsoKnownAs, - salt, - x.Description); + x.Metadata.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", + "OPENSIM_AES_AF1", + file.AlsoKnownAs, + salt, + x.Metadata.Description); } private bool DecryptAssetBase(AssetBase x) { // Check it's encrypted first. - if (!x.Description.Contains("ENCASS")) + if (!x.Metadata.Description.Contains("ENCASS")) return true; // ENCASS:ALG:AKA:SALT:Description @@ -421,7 +421,7 @@ namespace OpenSim.Framework.Communications.Cache string[] splitchars = new string[1]; splitchars[0] = "#:~:#"; - string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); + string[] meta = x.Metadata.Description.Split(splitchars, StringSplitOptions.None); if (meta.Length < 5) { m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); @@ -432,7 +432,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_keyfiles.ContainsKey(meta[2])) { RjinKeyfile deckey = m_keyfiles[meta[2]]; - x.Description = meta[4]; + x.Metadata.Description = meta[4]; switch (meta[1]) { case "OPENSIM_AES_AF1": @@ -506,7 +506,7 @@ namespace OpenSim.Framework.Communications.Cache { string assetUrl = _assetServerUrl + "/assets/"; - m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); + m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID); RestObjectPoster.BeginPostObject(assetUrl, asset); } diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index 5f15c3e..8b8172e 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Cache } public override void StoreAsset(AssetBase asset) { - byte[] idBytes = asset.FullID.Guid.ToByteArray(); + byte[] idBytes = asset.Metadata.FullID.Guid.ToByteArray(); string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] + Path.DirectorySeparatorChar + idBytes[1]; @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Communications.Cache if (!Directory.Exists(cdir)) Directory.CreateDirectory(cdir); - FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); + FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.Metadata.FullID + ".xml", FileMode.Create); m_xs.Serialize(x, asset); x.Flush(); diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index e27c4f4..1cc9833 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache // rc.Request(s); //m_log.InfoFormat("[ASSET]: Stored {0}", rc); - m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); + m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID); RestObjectPoster.BeginPostObject(assetUrl, asset); } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a6acd68..a370eea 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.DebugFormat( "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); - + //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, @@ -247,9 +247,9 @@ namespace OpenSim.Framework.Communications.Capabilities //m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); - + //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); - + return result; } @@ -569,7 +569,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - + string protocol = "http://"; if (m_httpListener.UseSSL) @@ -648,7 +648,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { - if (llsdRequest.asset_type == "texture" || + if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { @@ -741,9 +741,9 @@ namespace OpenSim.Framework.Communications.Capabilities AssetBase asset; asset = new AssetBase(); - asset.FullID = assetID; - asset.Type = assType; - asset.Name = assetName; + asset.Metadata.FullID = assetID; + asset.Metadata.Type = assType; + asset.Metadata.Name = assetName; asset.Data = data; m_assetCache.AddAsset(asset); @@ -751,7 +751,7 @@ namespace OpenSim.Framework.Communications.Capabilities item.Owner = m_agentID; item.Creator = m_agentID; item.ID = inventoryItem; - item.AssetID = asset.FullID; + item.AssetID = asset.Metadata.FullID; item.Description = assetDescription; item.Name = assetName; item.AssetType = assType; -- cgit v1.1 From a1da6057066b2dadfa96ddb2f64df83a0b246ee4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 4 Feb 2009 18:56:12 +0000 Subject: * Introduce a new "default" option for asset_database in the [STORAGE] section * This option makes OpenSim use the usual db based asset service in standalone, and the grid based one in grid mode * The other options can (local, grid, etc) can still be used explicitly as before * Also change OpenSim.ini.example and the surrounding explanative text --- OpenSim/Framework/Communications/Cache/FileAssetClient.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index 8b8172e..9a60b53 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -43,6 +43,7 @@ namespace OpenSim.Framework.Communications.Cache } m_dir = dir; } + public override void StoreAsset(AssetBase asset) { byte[] idBytes = asset.Metadata.FullID.Guid.ToByteArray(); -- cgit v1.1 From 9b66108081a8c8cf79faaa6c541554091c40850e Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 6 Feb 2009 16:55:34 +0000 Subject: This changeset is the step 1 of 2 in refactoring OpenSim.Region.Environment into a "framework" part and a modules only part. This first changeset refactors OpenSim.Region.Environment.Scenes, OpenSim.Region.Environment.Interfaces, and OpenSim.Region.Interfaces into OpenSim.Region.Framework.{Interfaces,Scenes} leaving only region modules in OpenSim.Region.Environment. The next step will be to move region modules up from OpenSim.Region.Environment.Modules to OpenSim.Region.CoreModules and then sort out which modules are really core modules and which should move out to forge. I've been very careful to NOT BREAK anything. i hope i've succeeded. as this is the work of a whole week i hope i managed to keep track with the applied patches of the last week --- could any of you that did check in stuff have a look at whether it survived? thx! --- .../Framework/Communications/Cache/CryptoGridAssetClient.cs | 10 ++++++++-- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 1b3e70d..038c591 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -163,8 +163,11 @@ namespace OpenSim.Framework.Communications.Cache passwordIterations); // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead of bits). + // key. Specify the size of the key in bytes (instead + // of bits). + #pragma warning disable 0618 byte[] keyBytes = password.GetBytes(keySize / 8); + #pragma warning restore 0618 // Create uninitialized Rijndael encryption object. RijndaelManaged symmetricKey = new RijndaelManaged(); @@ -276,8 +279,11 @@ namespace OpenSim.Framework.Communications.Cache passwordIterations); // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead of bits). + // key. Specify the size of the key in bytes (instead + // of bits). + #pragma warning disable 0618 byte[] keyBytes = password.GetBytes(keySize / 8); + #pragma warning restore 0618 // Create uninitialized Rijndael encryption object. RijndaelManaged symmetricKey = new RijndaelManaged(); diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a370eea..25a69f7 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -35,7 +35,7 @@ using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Framework; -using OpenSim.Region.Interfaces; +// using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Framework.Communications.Capabilities { -- cgit v1.1 From 369eef5fcd8e6566d5f953db6a6b093cf674269c Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 9 Feb 2009 00:33:44 +0000 Subject: The DataPluginFactory is now a set of generic methods instead of multiple duplicates of the same code. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index a031bdf..8753c64 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Communications /// public void AddPlugin(string provider, string connect) { - m_plugins.AddRange(DataPluginFactory.LoadInventoryDataPlugins(provider, connect)); + m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); } #endregion diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 886900d..0af9652 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -85,7 +85,7 @@ namespace OpenSim.Framework.Communications /// public void AddPlugin(string provider, string connect) { - _plugins.AddRange(DataPluginFactory.LoadUserDataPlugins(provider, connect)); + _plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); } #region Get UserProfile -- cgit v1.1 From 8088802c218d7eb4a47018b5b3bb70e7463a03b1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 9 Feb 2009 21:47:55 +0000 Subject: From Alan Webb These changes replace all direct references to the AssetCache with IAssetCache. There is no change to functionality. Everything works as before. This is laying the groundwork for making it possible to register alternative asset caching mechanisms without disrupting other parts of OpenSim or their dependencies upon AssetCache functionality. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 7 ++++--- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- OpenSim/Framework/Communications/CommunicationsManager.cs | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2b2467c..2296e46 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -37,7 +37,7 @@ using GlynnTucker.Cache; namespace OpenSim.Framework.Communications.Cache { - public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); + // public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); /// /// Manages local cache of assets and their sending to viewers. @@ -47,7 +47,8 @@ namespace OpenSim.Framework.Communications.Cache /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and /// AssetNotFound(), which means they do share the same asset and texture caches.I agr - public class AssetCache : IAssetReceiver + + public class AssetCache : IAssetCache, IAssetReceiver { protected ICache m_memcache = new SimpleMemoryCache(); @@ -148,7 +149,7 @@ namespace OpenSim.Framework.Communications.Cache /// Process the asset queue which holds data which is packeted up and sent /// directly back to the client. /// - public void RunAssetManager() + private void RunAssetManager() { while (true) { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 25a69f7..cfe9002 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications.Capabilities //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; private UUID m_agentID; - private AssetCache m_assetCache; + private IAssetCache m_assetCache; private int m_eventQueueCount = 1; private Queue m_capsEventQueue = new Queue(); private bool m_dumpAssetsToFile; @@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Capabilities public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; public GetClientDelegate GetClient = null; - public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, + public Caps(IAssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, UUID agent, bool dumpAssetsToFile, string regionName) { m_assetCache = assetCache; diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index b4af991..2107f63 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications } protected IAvatarService m_avatarService; - public AssetCache AssetCache + public IAssetCache AssetCache { get { return m_assetCache; } } - protected AssetCache m_assetCache; + protected IAssetCache m_assetCache; public IInterServiceInventoryServices InterServiceInventoryService { @@ -127,7 +127,7 @@ namespace OpenSim.Framework.Communications /// /// /// - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, IAssetCache assetCache, bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; -- cgit v1.1 From 801da4346aeb3c08969c4845f5c595135a64470a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 12 Feb 2009 09:53:12 +0000 Subject: * optimized usings. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 ++-- OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs | 1 - OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 +--- .../Framework/Communications/Cache/CryptoGridAssetClient.cs | 4 ++-- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 1 + OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- .../Framework/Communications/Cache/UserProfileCacheService.cs | 4 +--- OpenSim/Framework/Communications/Capabilities/Caps.cs | 5 ++--- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 1 - .../Framework/Communications/Capabilities/LLSDStreamHandler.cs | 1 - OpenSim/Framework/Communications/CommunicationsManager.cs | 3 --- OpenSim/Framework/Communications/GridInfoService.cs | 1 - OpenSim/Framework/Communications/IAvatarService.cs | 3 --- OpenSim/Framework/Communications/IHyperlink.cs | 5 ----- OpenSim/Framework/Communications/ISecureInventoryService.cs | 4 +--- OpenSim/Framework/Communications/InventoryServiceBase.cs | 6 +----- OpenSim/Framework/Communications/LoginResponse.cs | 4 ++-- OpenSim/Framework/Communications/LoginService.cs | 4 ++-- OpenSim/Framework/Communications/RestClient.cs | 2 +- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 7 ++----- .../Communications/Tests/Cache/UserProfileTestUtils.cs | 2 -- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 10 ++++------ OpenSim/Framework/Communications/UserManagerBase.cs | 7 +++---- OpenSim/Framework/Communications/XMPP/XmppError.cs | 2 -- OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs | 2 -- OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs | 2 -- OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs | 2 -- OpenSim/Framework/Communications/XMPP/XmppSerializer.cs | 4 ---- OpenSim/Framework/Communications/XMPP/XmppStanza.cs | 1 - OpenSim/Framework/Communications/XMPP/XmppWriter.cs | 1 - 31 files changed, 28 insertions(+), 75 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2296e46..1c8f9d6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -29,11 +29,11 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Threading; +using GlynnTucker.Cache; +using log4net; using OpenMetaverse; using OpenMetaverse.Packets; -using log4net; using OpenSim.Framework.Statistics; -using GlynnTucker.Cache; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index cc5ba8e..5c902ec 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -28,11 +28,11 @@ using System; using System.Reflection; using System.Threading; -using OpenMetaverse; using log4net; +using OpenMetaverse; +using OpenSim.Data; using OpenSim.Framework.AssetLoader.Filesystem; using OpenSim.Framework.Statistics; -using OpenSim.Data; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs index be10e96..d56e48a 100644 --- a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs +++ b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs @@ -27,7 +27,6 @@ using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 99a982b..15066cd 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -28,10 +28,8 @@ using System; using System.Collections.Generic; using System.Reflection; -using System.Threading; - -using OpenMetaverse; using log4net; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 038c591..55db289 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://www.openmetaverse.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -34,11 +34,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Security.Cryptography; using System.Text; using System.Xml.Serialization; using log4net; using OpenSim.Framework.Servers; -using System.Security.Cryptography; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 4c629f4..58c3269 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using OpenMetaverse; + //using System.Reflection; //using log4net; diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 0b05adf..93f126f 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -30,9 +30,9 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Xml; -using OpenMetaverse; using log4net; using Nini.Config; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 22aab10..ef190c8 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -25,12 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections.Generic; using System.Reflection; -using System.Threading; -using OpenMetaverse; using log4net; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index cfe9002..b68083e 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -30,11 +30,10 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; -using OpenMetaverse; using log4net; -using OpenSim.Framework.Communications.Cache; +using OpenMetaverse; using OpenSim.Framework.Servers; -using OpenSim.Framework; + // using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Framework.Communications.Capabilities diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index 829b4e5..874a27f 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using OpenMetaverse; namespace OpenSim.Framework.Communications.Capabilities diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index c68a205..906f5d5 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -27,7 +27,6 @@ using System.Collections; using System.IO; -using System.Net; using System.Text; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2107f63..936e583 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,11 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections.Generic; -using System.Reflection; using OpenMetaverse; -using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index bd108c1..488ce8e 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -34,7 +34,6 @@ using log4net; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework.Servers; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 25b26dd..3822e9f 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -25,9 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; -using System.Text; using OpenMetaverse; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs index fa088d6..6c61d82 100644 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -25,11 +25,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Framework; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index 6d4ce46..6da13fe 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System.Collections.Generic; using OpenMetaverse; -using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 8753c64..de76415 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -25,14 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections.Generic; using System.Reflection; -using System.Threading; - -using OpenMetaverse; using log4net; - +using OpenMetaverse; using OpenSim.Data; namespace OpenSim.Framework.Communications diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index 867e9e6..d1b9258 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -29,10 +29,10 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; -using OpenMetaverse; -using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index fe904b5..ae16715 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -33,10 +33,10 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using System.Web; -using OpenMetaverse; -using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 970f2a9..69932fc 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -291,7 +291,7 @@ namespace OpenSim.Framework.Communications { _response = (HttpWebResponse) _request.GetResponse(); } - catch (System.Net.WebException e) + catch (WebException e) { m_log.ErrorFormat("[ASSET] Error fetching asset from asset server"); m_log.Debug(e.ToString()); diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 86d85b1..cda9d5c 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -25,16 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using log4net; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; -//using OpenSim.Framework; +using OpenSim.Data; using OpenSim.Framework.Communications.Cache; -using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; -using OpenSim.Data; +//using OpenSim.Framework; namespace OpenSim.Framework.Communications.Tests { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index cf07ae5..85cc940 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -26,10 +26,8 @@ */ using OpenMetaverse; -using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; -using OpenSim.Tests.Common.Mock; namespace OpenSim.Framework.Communications.Tests { diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index ffa3c5f..57ed0f5 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -29,8 +29,6 @@ using System; using System.Collections; using System.Net; using System.Text.RegularExpressions; -using System.Xml; -using Nini; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using Nwc.XmlRpc; @@ -61,7 +59,7 @@ namespace OpenSim.Framework.Communications.Tests IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); CommunicationsManager commsManager - = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); + = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); commsManager.GridService.RegisterRegion( new RegionInfo(42, 43, capsEndPoint, regionExternalName)); @@ -89,7 +87,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(responseData["first_name"], Is.EqualTo(firstName)); Assert.That(responseData["last_name"], Is.EqualTo(lastName)); Assert.That( - responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); + responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); Regex capsSeedPattern = new Regex("^http://" @@ -108,7 +106,7 @@ namespace OpenSim.Framework.Communications.Tests IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); CommunicationsManager commsManager - = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); + = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); commsManager.GridService.RegisterRegion( new RegionInfo(42, 43, capsEndPoint, regionExternalName)); @@ -159,7 +157,7 @@ namespace OpenSim.Framework.Communications.Tests Hashtable invlibroothash = (Hashtable) invlibroot[0]; Assert.That(invlibroothash["folder_id"],Is.EqualTo("00000112-000f-0000-0000-000100bba000")); Assert.That( - responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); + responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); Assert.That(responseData["message"], Is.EqualTo("Hello folks")); Assert.That(responseData["buddy-list"], Is.Empty); Assert.That(responseData["start_location"], Is.EqualTo("last")); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0af9652..62c3f89 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -26,17 +26,16 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Net; using System.Reflection; using System.Security.Cryptography; -using OpenMetaverse; -using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; -using OpenSim.Framework.Statistics; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using OpenSim.Data; +using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/XMPP/XmppError.cs b/OpenSim/Framework/Communications/XMPP/XmppError.cs index 1698b6a..8b7e502 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppError.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppError.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Xml; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs index 1789536..26a98ec 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Xml; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs index fd4cd5f..d150708 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Xml; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs index d63a0d1..95d2ca3 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Xml; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs index eb9dabe..888686b 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs @@ -27,12 +27,8 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; using System.Xml; using System.Xml.Serialization; -using log4net; namespace OpenSim.Framework.Communications.XMPP { diff --git a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs index 00df14a..db3c5eb 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs @@ -26,7 +26,6 @@ */ using System; -using System.Xml; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.XMPP diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs index c5ad9b4..4937f7a 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs @@ -28,7 +28,6 @@ using System.IO; using System.Text; using System.Xml; - using IOStream = System.IO.Stream; namespace OpenSim.Framework.Communications.XMPP -- cgit v1.1 From 31ca3a8d4d53fc82a3b4cb62ad4edaebc4111302 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 12 Feb 2009 17:07:44 +0000 Subject: * refactor: Move RequestInventoryForUser() from service to CachedUserInfo * This simplifies callers in most cases - CachedUserInfo is already handling the rest of the fetch inventory work anyway --- .../Communications/Cache/CachedUserInfo.cs | 19 ++++++++++++++ .../Cache/UserProfileCacheService.cs | 30 ---------------------- .../Tests/Cache/UserProfileCacheServiceTests.cs | 2 +- .../Tests/Cache/UserProfileTestUtils.cs | 5 ++-- 4 files changed, 23 insertions(+), 33 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 15066cd..c5bbd6a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -202,6 +202,25 @@ namespace OpenSim.Framework.Communications.Cache m_rootFolder = null; } } + + /// + /// Fetch inventory for this user. + /// + /// This has to be executed as a separate step once user information is retreived. + /// This will occur synchronously if the inventory service is in the same process as this class, and + /// asynchronously otherwise. + public void FetchInventory() + { + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.RequestInventoryForUser( + UserProfile.ID, SessionID, InventoryReceive); + } + else + { + m_commsManager.InventoryService.RequestInventoryForUser(UserProfile.ID, InventoryReceive); + } + } /// /// Callback invoked when the inventory is received from an async request to the inventory service diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index ef190c8..b1ce3e7 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -105,36 +105,6 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Request the inventory data for the given user. This will occur asynchronously if running on a grid - /// - /// - /// - public void RequestInventoryForUser(UUID userID) - { - CachedUserInfo userInfo = GetUserDetails(userID); - if (userInfo != null) - { - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.RequestInventoryForUser(userID, userInfo.SessionID, userInfo.InventoryReceive); - } - else - { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - } - //IInventoryServices invService = userInfo.GetInventoryService(); - //if (invService != null) - //{ - // invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - //} - } - else - { - m_log.ErrorFormat("[USER CACHE]: RequestInventoryForUser() - user profile for user {0} not found", userID); - } - } - - /// /// Get cached details of the given user. If the user isn't in cache then the user is requested from the /// profile service. /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index cda9d5c..e2576ef 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Tests /// Test requesting inventory for a user /// [Test] - public void TestRequestInventoryForUser() + public void TestFetchInventory() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index 85cc940..93ce916 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -59,9 +59,10 @@ namespace OpenSim.Framework.Communications.Tests lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + userInfo.FetchInventory(); - return commsManager.UserProfileCacheService.GetUserDetails(userId); + return userInfo; } } } -- cgit v1.1 From f4bec00057fb6987f4ea166347156e1abb985ec1 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Feb 2009 12:20:31 +0000 Subject: From: Alan Webb The change makes two principal implementation changes: [1] It removes the hard coded set of possible asset server client implementations, allowing any arbitrary implementation that has been identified to the PluginLoader as an appropriate extension. The extension point for asset server client extension is /OpenSim/AssetServerClient. All of the old configuration rules have been preserved, and any of the legacy configuration values will still work as they did before, except the implementation is now loaded as a plug-in, rather than as a hard-coded instantiation of a specific class. The re-hashing of IAssetServer as an extension of IPlugin made upgrading of the implementation classes a necessity. Caveat: I have not been able to meaningfully test the crypto-grid clients. I believe they should work correctly, but the refactoring necessary to handle plug-in based initialization (vs constructor-based initialisation) admits the possibility of a problem. [2] The asset cache implementation, previously introduce as a hard-code class instantiation is now implemented as an IPlugin. Once again the previous (configurationless) behavior has been preserved. But now it is possible for those interested in experimenting with cache technologies to do so simply by introducing a new extension for the asset cache extension point (/OpenSim/AssetCache). I've tested all of the configuration settings, after applying the patch to a newly extracted tree, and they seem to work OK. --- .../Framework/Communications/Cache/AssetCache.cs | 80 ++++++++++++++++++---- .../Communications/Cache/AssetServerBase.cs | 55 +++++++++++++++ .../Communications/Cache/CryptoGridAssetClient.cs | 48 ++++++++++--- .../Communications/Cache/FileAssetClient.cs | 37 +++++++++- .../Communications/Cache/GridAssetClient.cs | 31 ++++++++- .../Communications/Cache/SQLAssetServer.cs | 29 ++++++++ .../Communications/Resources/AssetCache.addin.xml | 17 +++++ 7 files changed, 271 insertions(+), 26 deletions(-) create mode 100644 OpenSim/Framework/Communications/Resources/AssetCache.addin.xml (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 1c8f9d6..76c6045 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -48,8 +48,67 @@ namespace OpenSim.Framework.Communications.Cache /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and /// AssetNotFound(), which means they do share the same asset and texture caches.I agr - public class AssetCache : IAssetCache, IAssetReceiver + public class AssetCache : IAssetCache { + + #region IPlugin + + /// + /// The methods and properties in this section are needed to + /// support the IPlugin interface. They cann all be overridden + /// as needed by a derived class. + /// + + public virtual string Name + { + get { return "OpenSim.Framework.Communications.Cache.AssetCache"; } + } + + public virtual string Version + { + get { return "1.0"; } + } + + public virtual void Initialise() + { + m_log.Debug("[ASSET CACHE]: Asset cache null initialisation"); + } + + public virtual void Initialise(IAssetServer assetServer) + { + m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation"); + m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version); + + Initialize(); + + m_assetServer = assetServer; + m_assetServer.SetReceiver(this); + + Thread assetCacheThread = new Thread(RunAssetManager); + assetCacheThread.Name = "AssetCacheThread"; + assetCacheThread.IsBackground = true; + assetCacheThread.Start(); + ThreadTracker.Add(assetCacheThread); + + } + + public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer) + { + m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation"); + Initialise(assetServer); + } + + public AssetCache() + { + m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)"); + } + + public void Dispose() + { + } + + #endregion + protected ICache m_memcache = new SimpleMemoryCache(); private static readonly ILog m_log @@ -83,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// The 'server' from which assets can be requested and to which assets are persisted. /// - private readonly IAssetServer m_assetServer; + private IAssetServer m_assetServer; public IAssetServer AssetServer { @@ -132,17 +191,8 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - m_log.Info("[ASSET CACHE]: Creating Asset cache"); - Initialize(); - - m_assetServer = assetServer; - m_assetServer.SetReceiver(this); - - Thread assetCacheThread = new Thread(RunAssetManager); - assetCacheThread.Name = "AssetCacheThread"; - assetCacheThread.IsBackground = true; - assetCacheThread.Start(); - ThreadTracker.Add(assetCacheThread); + m_log.Info("[ASSET CACHE]: Asset cache direct constructor"); + Initialise(assetServer); } /// @@ -342,7 +392,7 @@ namespace OpenSim.Framework.Communications.Cache } // See IAssetReceiver - public void AssetReceived(AssetBase asset, bool IsTexture) + public virtual void AssetReceived(AssetBase asset, bool IsTexture) { AssetInfo assetInf = new AssetInfo(asset); @@ -393,7 +443,7 @@ namespace OpenSim.Framework.Communications.Cache } // See IAssetReceiver - public void AssetNotFound(UUID assetID, bool IsTexture) + public virtual void AssetNotFound(UUID assetID, bool IsTexture) { // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 5c902ec..7bb2ab9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -46,6 +46,61 @@ namespace OpenSim.Framework.Communications.Cache protected Thread m_localAssetServerThread; protected IAssetDataPlugin m_assetProvider; + #region IPlugin + + /// + /// The methods and properties in this region are needed to implement + /// the IPlugin interface and its local extensions. + /// These can all be overridden as appropriate by a derived class. + /// These methods are only applicable when a class is loaded by the + /// IPlugin mechanism. + /// + /// Note that in the case of AssetServerBase, all initialization is + /// performed by the default constructor, so nothing additional is + /// required here. A derived class may wish to do more. + /// + + public virtual string Name + { + // get { return "OpenSim.Framework.Communications.Cache.AssetServerBase"; } + get { return "AssetServerBase"; } + } + + public virtual string Version + { + get { return "1.0"; } + } + + public virtual void Initialise() + { + m_log.Debug("[ASSET SERVER]: IPlugin null initialization"); + } + + public virtual void Initialise(ConfigSettings settings) + { + m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(1)"); + m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); + } + + public virtual void Initialise(ConfigSettings settings, string p_url) + { + m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(2)"); + m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); + } + + public virtual void Initialise(ConfigSettings settings, string p_url, string p_dir, bool p_t) + { + m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(3)"); + m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); + } + + public virtual void Dispose() + { + m_log.Debug("[ASSET SERVER]: dispose"); + } + + #endregion + public IAssetDataPlugin AssetProviderPlugin { get { return m_assetProvider; } diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 55db289..0f4e8ac 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -44,9 +44,37 @@ namespace OpenSim.Framework.Communications.Cache { public class CryptoGridAssetClient : AssetServerBase { + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string _assetServerUrl; + private bool m_encryptOnUpload; + private RjinKeyfile m_encryptKey; + private readonly Dictionary m_keyfiles = new Dictionary(); + + #region IPlugin + + public override string Name + { + get { return "Crypto"; } + } + + public override string Version + { + get { return "1.0"; } + } + + public override void Initialise(ConfigSettings p_set, string p_url, string p_dir, bool p_t) + { + m_log.Debug("[CRYPTOGRID] Plugin configured initialisation"); + Initialise(p_url, p_dir, p_t); + } + + #endregion + #region Keyfile Classes [Serializable] - private class RjinKeyfile + public class RjinKeyfile { public string Secret; public string AlsoKnownAs; @@ -94,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache /// this may not be the most efficient way of handling encryption, so - as /// soon as you feel comfortable with it - you may want to redesign this class. /// - private class UtilRijndael + public class UtilRijndael { /// /// Encrypts specified plaintext using Rijndael symmetric key algorithm @@ -332,15 +360,19 @@ namespace OpenSim.Framework.Communications.Cache } #endregion - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private readonly string _assetServerUrl; - private readonly bool m_encryptOnUpload; - private readonly RjinKeyfile m_encryptKey; - private readonly Dictionary m_keyfiles = new Dictionary(); + public CryptoGridAssetClient() {} public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) { + m_log.Debug("[CRYPTOGRID] Direct constructor"); + Initialise(serverUrl, keydir, decOnly); + } + + public void Initialise(string serverUrl, string keydir, bool decOnly) + { + + m_log.Debug("[CRYPTOGRID] Common constructor"); + _assetServerUrl = serverUrl; string[] keys = Directory.GetFiles(keydir, "*.deckey"); diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index 9a60b53..e6574a1 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -26,16 +26,49 @@ */ using System.IO; +using System.Reflection; +using log4net; using System.Xml.Serialization; namespace OpenSim.Framework.Communications.Cache { public class FileAssetClient : AssetServerBase { - private readonly string m_dir; + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region IPlugin + + public override string Name + { + get { return "File"; } + } + + public override string Version + { + get { return "1.0"; } + } + + public override void Initialise(ConfigSettings p_set, string p_url) + { + m_log.Debug("[FILEASSET] Plugin configured initialisation"); + Initialise(p_url); + } + + #endregion + + private string m_dir; private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); - public FileAssetClient(string dir) + public FileAssetClient() {} + + public FileAssetClient(string p_url) + { + m_log.Debug("[FILEASSET] Direct constructor"); + Initialise(p_url); + } + + public void Initialise(string dir) { if (!Directory.Exists(dir)) { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 1cc9833..6522ad0 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -36,11 +36,40 @@ namespace OpenSim.Framework.Communications.Cache { public class GridAssetClient : AssetServerBase { + + #region IPlugin + + public override string Name + { + get { return "Grid"; } + } + + public override string Version + { + get { return "1.0"; } + } + + public override void Initialise(ConfigSettings p_set, string p_url) + { + m_log.Debug("[GRIDASSET] Plugin configured initialisation"); + Initialise(p_url); + } + + #endregion + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string _assetServerUrl; - public GridAssetClient(string serverUrl) + public GridAssetClient() {} + + public GridAssetClient(string p_url) + { + m_log.Debug("[GRIDASSET] Direct constructor"); + Initialise(p_url); + } + + public void Initialise(string serverUrl) { _assetServerUrl = serverUrl; } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 6266bf0..5274288 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -34,10 +34,39 @@ namespace OpenSim.Framework.Communications.Cache { public class SQLAssetServer : AssetServerBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + #region IPlugin + + public override string Name + { + get { return "SQL"; } + } + + public override string Version + { + get { return "1.0"; } + } + + public override void Initialise(ConfigSettings p_set) + { + m_log.Debug("[SQLASSET] Plugin configured initialisation"); + Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource); + } + + #endregion + + public SQLAssetServer() {} + public SQLAssetServer(string pluginName, string connect) { + m_log.Debug("[SQLASSET] Direct constructor"); + Initialise(pluginName, connect); + } + + public void Initialise(string pluginName, string connect) + { AddPlugin(pluginName, connect); } diff --git a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml new file mode 100644 index 0000000..61a9f0f --- /dev/null +++ b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + -- cgit v1.1 From 76c0935ec744f2d230489398f879eb7f42b11d37 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Tue, 17 Feb 2009 01:36:44 +0000 Subject: - remove the Metadata property from AssetBase and return all previous properties as before - prefix private variables with m_ in AssetBase.cs - related to Mantis #3122, as mentioned in https://lists.berlios.de/pipermail/opensim-dev/2009-February/005088.html - all services will likely need to be upgraded after this commit --- .../Framework/Communications/Cache/AssetCache.cs | 46 +++++++++++----------- .../Communications/Cache/CryptoGridAssetClient.cs | 18 ++++----- .../Communications/Cache/FileAssetClient.cs | 4 +- .../Communications/Cache/GridAssetClient.cs | 2 +- .../Framework/Communications/Capabilities/Caps.cs | 8 ++-- 5 files changed, 39 insertions(+), 39 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 76c6045..0e1f948 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -341,11 +341,11 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddAsset(AssetBase asset) { - if (!m_memcache.Contains(asset.Metadata.FullID)) + if (!m_memcache.Contains(asset.FullID)) { - m_log.Info("[CACHE] Caching " + asset.Metadata.FullID + " for 24 hours from last access"); + m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); // Use 24 hour rolling asset cache. - m_memcache.AddOrUpdate(asset.Metadata.FullID, asset, TimeSpan.FromHours(24)); + m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the // information is stored locally. It could disappear, in which case we could send the @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications.Cache // But for now, we're going to take the easy way out and store local assets globally. // // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. - if (!asset.Metadata.Temporary || asset.Metadata.Local) + if (!asset.Temporary || asset.Local) { m_assetServer.StoreAsset(asset); } @@ -396,25 +396,25 @@ namespace OpenSim.Framework.Communications.Cache { AssetInfo assetInf = new AssetInfo(asset); - if (!m_memcache.Contains(assetInf.Metadata.FullID)) + if (!m_memcache.Contains(assetInf.FullID)) { - m_memcache.AddOrUpdate(assetInf.Metadata.FullID, assetInf, TimeSpan.FromHours(24)); + m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); if (StatsManager.SimExtraStats != null) { StatsManager.SimExtraStats.AddAsset(assetInf); } - if (RequestedAssets.ContainsKey(assetInf.Metadata.FullID)) + if (RequestedAssets.ContainsKey(assetInf.FullID)) { - AssetRequest req = RequestedAssets[assetInf.Metadata.FullID]; + AssetRequest req = RequestedAssets[assetInf.FullID]; req.AssetInf = assetInf; req.NumPackets = CalculateNumPackets(assetInf.Data); - RequestedAssets.Remove(assetInf.Metadata.FullID); + RequestedAssets.Remove(assetInf.FullID); // If it's a direct request for a script, drop it // because it's a hacked client - if (req.AssetRequestSource != 2 || assetInf.Metadata.Type != 10) + if (req.AssetRequestSource != 2 || assetInf.Type != 10) AssetRequests.Add(req); } } @@ -424,8 +424,8 @@ namespace OpenSim.Framework.Communications.Cache lock (RequestLists) { - if (RequestLists.TryGetValue(asset.Metadata.FullID, out reqList)) - RequestLists.Remove(asset.Metadata.FullID); + if (RequestLists.TryGetValue(asset.FullID, out reqList)) + RequestLists.Remove(asset.FullID); } if (reqList != null) @@ -436,8 +436,8 @@ namespace OpenSim.Framework.Communications.Cache foreach (NewAssetRequest req in reqList.Requests) { // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked - // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.Metadata.FullID); - req.Callback(asset.Metadata.FullID, asset); + // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); + req.Callback(asset.FullID, asset); } } } @@ -545,7 +545,7 @@ namespace OpenSim.Framework.Communications.Cache } // Scripts cannot be retrieved by direct request - if (transferRequest.TransferInfo.SourceType == 2 && asset.Metadata.Type == 10) + if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) return; // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list @@ -631,10 +631,10 @@ namespace OpenSim.Framework.Communications.Cache public AssetInfo(AssetBase aBase) { Data = aBase.Data; - Metadata.FullID = aBase.Metadata.FullID; - Metadata.Type = aBase.Metadata.Type; - Metadata.Name = aBase.Metadata.Name; - Metadata.Description = aBase.Metadata.Description; + FullID = aBase.FullID; + Type = aBase.Type; + Name = aBase.Name; + Description = aBase.Description; } } @@ -643,10 +643,10 @@ namespace OpenSim.Framework.Communications.Cache public TextureImage(AssetBase aBase) { Data = aBase.Data; - Metadata.FullID = aBase.Metadata.FullID; - Metadata.Type = aBase.Metadata.Type; - Metadata.Name = aBase.Metadata.Name; - Metadata.Description = aBase.Metadata.Description; + FullID = aBase.FullID; + Type = aBase.Type; + Name = aBase.Name; + Description = aBase.Description; } } diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 0f4e8ac..f1c19fa 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -441,17 +441,17 @@ namespace OpenSim.Framework.Communications.Cache string salt = Convert.ToBase64String(rand); x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); - x.Metadata.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", - "OPENSIM_AES_AF1", - file.AlsoKnownAs, - salt, - x.Metadata.Description); + x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", + "OPENSIM_AES_AF1", + file.AlsoKnownAs, + salt, + x.Description); } private bool DecryptAssetBase(AssetBase x) { // Check it's encrypted first. - if (!x.Metadata.Description.Contains("ENCASS")) + if (!x.Description.Contains("ENCASS")) return true; // ENCASS:ALG:AKA:SALT:Description @@ -459,7 +459,7 @@ namespace OpenSim.Framework.Communications.Cache string[] splitchars = new string[1]; splitchars[0] = "#:~:#"; - string[] meta = x.Metadata.Description.Split(splitchars, StringSplitOptions.None); + string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); if (meta.Length < 5) { m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); @@ -470,7 +470,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_keyfiles.ContainsKey(meta[2])) { RjinKeyfile deckey = m_keyfiles[meta[2]]; - x.Metadata.Description = meta[4]; + x.Description = meta[4]; switch (meta[1]) { case "OPENSIM_AES_AF1": @@ -544,7 +544,7 @@ namespace OpenSim.Framework.Communications.Cache { string assetUrl = _assetServerUrl + "/assets/"; - m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID); + m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); RestObjectPoster.BeginPostObject(assetUrl, asset); } diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs index e6574a1..8d03f56 100644 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs @@ -79,7 +79,7 @@ namespace OpenSim.Framework.Communications.Cache public override void StoreAsset(AssetBase asset) { - byte[] idBytes = asset.Metadata.FullID.Guid.ToByteArray(); + byte[] idBytes = asset.FullID.Guid.ToByteArray(); string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] + Path.DirectorySeparatorChar + idBytes[1]; @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications.Cache if (!Directory.Exists(cdir)) Directory.CreateDirectory(cdir); - FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.Metadata.FullID + ".xml", FileMode.Create); + FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); m_xs.Serialize(x, asset); x.Flush(); diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 6522ad0..3b6dc52 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -126,7 +126,7 @@ namespace OpenSim.Framework.Communications.Cache // rc.Request(s); //m_log.InfoFormat("[ASSET]: Stored {0}", rc); - m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID); + m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); RestObjectPoster.BeginPostObject(assetUrl, asset); } diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index b68083e..a4c847d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -740,9 +740,9 @@ namespace OpenSim.Framework.Communications.Capabilities AssetBase asset; asset = new AssetBase(); - asset.Metadata.FullID = assetID; - asset.Metadata.Type = assType; - asset.Metadata.Name = assetName; + asset.FullID = assetID; + asset.Type = assType; + asset.Name = assetName; asset.Data = data; m_assetCache.AddAsset(asset); @@ -750,7 +750,7 @@ namespace OpenSim.Framework.Communications.Capabilities item.Owner = m_agentID; item.Creator = m_agentID; item.ID = inventoryItem; - item.AssetID = asset.Metadata.FullID; + item.AssetID = asset.FullID; item.Description = assetDescription; item.Name = assetName; item.AssetType = assType; -- cgit v1.1 From d03c32aa695117b16307bb89fea4142167e42bfb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 17 Feb 2009 18:46:42 +0000 Subject: * Allow inventory archives to be saved from the 'root' inventory directory * Reload doesn't currently obey structure information * Not yet ready for use --- .../Framework/Communications/Cache/InventoryFolderImpl.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 58c3269..a625c7e 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -307,7 +307,8 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder + /// Find a folder given a PATH_DELIMITER delimited path starting from this folder + /// /// /// This method does not handle paths that contain multiple delimitors /// @@ -315,15 +316,21 @@ namespace OpenSim.Framework.Communications.Cache /// XPath like expression /// /// FIXME: Delimitors which occur in names themselves are not currently escapable. - /// + /// /// - /// The path to the required folder. It this is empty then this folder itself is returned. + /// The path to the required folder. + /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. /// /// null if the folder is not found public InventoryFolderImpl FindFolderByPath(string path) { if (path == string.Empty) return this; + + path = path.Trim(); + + if (path == PATH_DELIMITER) + return this; string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); -- cgit v1.1 From 8ed631307b97025bf25a5a08fa49223c3ad39eda Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 18 Feb 2009 13:15:07 +0000 Subject: From: Alan Webb I've changed the extension point name, and the internal references that used the same string. I also fixed up the messaging around the asset loader so that it is more explicit. --- .../Framework/Communications/Resources/AssetCache.addin.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml index 61a9f0f..2ac6dca 100644 --- a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml +++ b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml @@ -8,10 +8,10 @@ - - - - - + + + + + -- cgit v1.1 From b5502ef3c322e787640a8a9b3cb474b2f8abaaaa Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 19 Feb 2009 18:40:32 +0000 Subject: * Extracted IAssetData and moved it to OpenSim.Framework to prepare to get rid of ugly CoreModules dependency on AssetServer.exe * And yes, the IAssetDataPlugin is misnomed, which became apparent on extracting it. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 1 - OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 1 - 2 files changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7bb2ab9..91e8720 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -30,7 +30,6 @@ using System.Reflection; using System.Threading; using log4net; using OpenMetaverse; -using OpenSim.Data; using OpenSim.Framework.AssetLoader.Filesystem; using OpenSim.Framework.Statistics; diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 5274288..1306ef4 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -28,7 +28,6 @@ using System; using System.Reflection; using log4net; -using OpenSim.Data; namespace OpenSim.Framework.Communications.Cache { -- cgit v1.1 From b99d9bdeb1d5177a3dfff1d402d374fbd079ebaa Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 19 Feb 2009 19:32:53 +0000 Subject: * Reverted the AssetServer fix, apparently something was dependent on IAssetDataPlugin being in OpenSim.Data --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 1 + OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 91e8720..7bb2ab9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -30,6 +30,7 @@ using System.Reflection; using System.Threading; using log4net; using OpenMetaverse; +using OpenSim.Data; using OpenSim.Framework.AssetLoader.Filesystem; using OpenSim.Framework.Statistics; diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 1306ef4..5274288 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -28,6 +28,7 @@ using System; using System.Reflection; using log4net; +using OpenSim.Data; namespace OpenSim.Framework.Communications.Cache { -- cgit v1.1 From e725e485fa72bcdba03df9ed7d0b007b6e548eb3 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 20 Feb 2009 00:18:18 +0000 Subject: This moves the 2 friends-related interregion messages out of OGS1 and into the FriendsModule. No functional changes. Those messages were sent over XMLRPC, and that's how it continues to be for now. Just moving this couple of interregion messages out of OGS1, in preparation for the big shlep ahead. --- .../Communications/CommunicationsManager.cs | 10 ------ .../Communications/IInterRegionCommunications.cs | 36 ---------------------- 2 files changed, 46 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 936e583..e0e07b2 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -324,16 +324,6 @@ namespace OpenSim.Framework.Communications return m_messageService.GetFriendRegionInfos(uuids); } - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - return m_interRegion.InformFriendsInOtherRegion(agentId, destRegionHandle, friends, online); - } - - public bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) - { - return m_interRegion.TriggerTerminateFriend(regionHandle, agentID, exFriendID); - } - #endregion #region Packet Handlers diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 6b589b9..2d4eb53 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -48,41 +48,5 @@ namespace OpenSim.Framework.Communications bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); - /// - /// Try to inform friends in the given region about online status of agent. - /// - /// - /// The of the agent. - /// - /// - /// The regionHandle of the region. - /// - /// - /// A List of s of friends to inform in the given region. - /// - /// - /// Is the agent online or offline - /// - /// - /// A list of friends that couldn't be reached on this region. - /// - List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online); - - /// - /// Send TerminateFriend of exFriendID to agent agentID in region regionHandle. - /// - /// - /// The handle of the region agentID is in (hopefully). - /// - /// - /// The agent to send the packet to. - /// - /// - /// The ex-friends ID. - /// - /// - /// Whether the packet could be sent. False if the agent couldn't be found in the region. - /// - bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID); } } -- cgit v1.1 From 33330297d603a66cc157baa21c81328edc893e51 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 20 Feb 2009 03:39:50 +0000 Subject: THE BIG ANTI-REMOTING SCHLEP -- StartRemoting is no more. Sims in older versions will have a hard time communicating with sims on this release and later, especially if they haven't transitioned to RESTComms at all. There's still some cleanup to do on assorted data structures, but the main functional change here is that sims no longer listen on remoting ports. --- .../Communications/CommunicationsManager.cs | 6 --- .../Communications/IInterRegionCommunications.cs | 52 ---------------------- 2 files changed, 58 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IInterRegionCommunications.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e0e07b2..bb8e452 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -59,12 +59,6 @@ namespace OpenSim.Framework.Communications } protected IGridServices m_gridService; - public IInterRegionCommunications InterRegion - { - get { return m_interRegion; } - } - protected IInterRegionCommunications m_interRegion; - public UserProfileCacheService UserProfileCacheService { get { return m_userProfileCacheService; } diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs deleted file mode 100644 index 2d4eb53..0000000 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IInterRegionCommunications - { - string rdebugRegionName { get; set; } - - bool CheckRegion(string address, uint port); - bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod); - bool RegionUp(SerializableRegionInfo region, ulong regionhandle); - bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); - - bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying); - bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying); - - bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId); - bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID); - - bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); - - } -} -- cgit v1.1 From 2e095f5727b2bd22ccf06f940ec191bed4fc8820 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 20 Feb 2009 16:47:31 +0000 Subject: * Upped VersionInfo to 0.6.3 and in the process, changed assemblyinfo to 0.6.3.* to better track down dll ref and overwrite problems. --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 2df5fbc..e2f31c1 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -35,9 +35,9 @@ using System.Runtime.InteropServices; [assembly : AssemblyTitle("OpenGrid.Framework.Communications")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] -[assembly : AssemblyCompany("")] +[assembly : AssemblyCompany("http://opensimulator.org")] [assembly : AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // 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 : AssemblyVersion("0.6.3.*")] [assembly : AssemblyFileVersion("1.0.0.0")] -- cgit v1.1 From 7a649a758da3ec269c3b136eb36c1185bd2caf54 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 21 Feb 2009 03:32:25 +0000 Subject: Add copyright headers. Minor formatting cleanup. --- OpenSim/Framework/Communications/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index ae16715..454197a 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -135,7 +135,7 @@ namespace OpenSim.Framework.Communications } firstname = (string)requestData["first"]; - lastname = (string) requestData["last"]; + lastname = (string)requestData["last"]; m_log.InfoFormat( "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", -- cgit v1.1 From 8f55b9d735fbc975ce7a4b54e972c17ffbfb1f49 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 22 Feb 2009 20:52:55 +0000 Subject: Mantis#3218. Thank you kindly, TLaukkan (Tommil) for a patch that: * Added log4net dependency to physxplugin in prebuild.xml. * Added missing m_log fields to classes. * Replaced Console.WriteLine with appropriate m_log.Xxxx * Tested that nant test target runs succesfully. * Tested that local opensim sandbox starts up without errors. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0e1f948..2690e4e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -510,11 +510,11 @@ namespace OpenSim.Framework.Communications.Cache //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); source = 3; - //Console.WriteLine("asset request " + requestID); + //m_log.Debug("asset request " + requestID); } //check to see if asset is in local cache, if not we need to request it from asset server. - //Console.WriteLine("asset request " + requestID); + //m_log.Debug("asset request " + requestID); if (!m_memcache.Contains(requestID)) { //not found asset diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a4c847d..4ab304f 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -464,7 +464,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// public string RequestTexture(string request, string path, string param) { - System.Console.WriteLine("texture request " + request); + m_log.Debug("texture request " + request); // Needs implementing (added to remove compiler warning) return String.Empty; } @@ -670,7 +670,7 @@ namespace OpenSim.Framework.Communications.Capabilities } } - //System.Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); + //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; -- cgit v1.1 From 72be38f7ae94a954a451f37d44e2e1b1341ff4dd Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 25 Feb 2009 02:14:19 +0000 Subject: Distinguish 404 errors in RestClient.Request(). Mantis #3225. --- OpenSim/Framework/Communications/RestClient.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 69932fc..3035da5 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -293,8 +293,16 @@ namespace OpenSim.Framework.Communications } catch (WebException e) { - m_log.ErrorFormat("[ASSET] Error fetching asset from asset server"); - m_log.Debug(e.ToString()); + HttpWebResponse errorResponse = e.Response as HttpWebResponse; + if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) + { + m_log.Warn("[ASSET] Asset not found (404)"); + } + else + { + m_log.Error("[ASSET] Error fetching asset from asset server"); + m_log.Debug(e.ToString()); + } return null; } -- cgit v1.1 From 4db232763f578048c3339e6a60fe801cc3853b3d Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 25 Feb 2009 18:33:15 +0000 Subject: More refactoring of the Grid, User and Messaging servers. --- OpenSim/Framework/Communications/IUserService.cs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 206fb1e..0846024 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -114,17 +114,5 @@ namespace OpenSim.Framework.Communications /// /// The agent that we're retreiving the friends Data. List GetUserFriendList(UUID friendlistowner); - - /// - /// Get's the User Appearance - // AvatarAppearance GetUserAppearance(UUID user); - - // void UpdateUserAppearance(UUID user, AvatarAppearance appearance); - - // void AddAttachment(UUID user, UUID attach); - - // void RemoveAttachment(UUID user, UUID attach); - - // List GetAttachments(UUID user); } } -- cgit v1.1 From 57ab79e3312d9856a3534a1e2343b45c6cf74ac6 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 26 Feb 2009 21:29:16 +0000 Subject: * Update ScenePresenceTests to reflect current REST communication workflow. * Fixed an issue with AssetCache where it would break unit tests randomly. From: Arthur Rodrigo S Valadares --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 2690e4e..800c997 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -210,7 +210,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.Error("[ASSET CACHE]: " + e); + m_log.Error("[ASSET CACHE]: " + e.ToString()); } } } -- cgit v1.1 From 171015f65fc2226b92b0f881a49e0110445e5045 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 3 Mar 2009 15:41:21 +0000 Subject: Moved Linden protocol login handling to modules in OpenSim.Client.Linden. There are two region modules in there LLStandaloneLoginModule (for standalone mode) and LLProxyLoginModule (for grid mode which just handles incoming expect_user and logoff_user messages from the remote login server) Changed OpenSim.Framework.Communications.Tests.LoginServiceTests to use the LLStandaloneLoginService (from the LLStandaloneLoginModule) rather than LocalLoginService. Really these login tests should most likely be somewhere else as they are testing specific implementations of login services. Commented out the old LocalLoginService as its no longer used, but want to check there are no problems before it gets deleted. --- .../Communications/CommunicationsManager.cs | 3 +- .../Communications/Tests/LoginServiceTests.cs | 130 ++++++++++++++++++--- 2 files changed, 115 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bb8e452..3363c24 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework.Communications.Cache; @@ -111,6 +112,7 @@ namespace OpenSim.Framework.Communications } protected BaseHttpServer m_httpServer; + /// /// Constructor /// @@ -125,7 +127,6 @@ namespace OpenSim.Framework.Communications m_assetCache = assetCache; m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); m_httpServer = httpServer; - // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); } #region Inventory diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 57ed0f5..854d68d 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -27,6 +27,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Net; using System.Text.RegularExpressions; using NUnit.Framework; @@ -35,6 +36,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; +using OpenSim.Client.Linden; namespace OpenSim.Framework.Communications.Tests { @@ -60,16 +62,22 @@ namespace OpenSim.Framework.Communications.Tests CommunicationsManager commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); + + //commsManager.GridService.RegisterRegion( + // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + //commsManager.GridService.RegionLoginsEnabled = true; - commsManager.GridService.RegisterRegion( - new RegionInfo(42, 43, capsEndPoint, regionExternalName)); - commsManager.GridService.RegionLoginsEnabled = true; + //LoginService loginService + // = new LocalLoginService( + // (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, + // (LocalBackEndServices)commsManager.GridService, + // commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); - LoginService loginService - = new LocalLoginService( - (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, - (LocalBackEndServices)commsManager.GridService, - commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); + TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); + regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + + LoginService loginService = new LLStandaloneLoginService((UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, + commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), regionConnector); Hashtable loginParams = new Hashtable(); loginParams["first"] = firstName; @@ -108,21 +116,25 @@ namespace OpenSim.Framework.Communications.Tests CommunicationsManager commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); - commsManager.GridService.RegisterRegion( - new RegionInfo(42, 43, capsEndPoint, regionExternalName)); - commsManager.GridService.RegionLoginsEnabled = true; - LocalUserServices lus = (LocalUserServices)commsManager.UserService; lus.AddUser(firstName,lastName,"boingboing","abc@ftw.com",42,43); + //commsManager.GridService.RegisterRegion( + // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + //commsManager.GridService.RegionLoginsEnabled = true; - LoginService loginService - = new LocalLoginService( - (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, - (LocalBackEndServices)commsManager.GridService, - commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); + //LoginService loginService + // = new LocalLoginService( + // (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, + // (LocalBackEndServices)commsManager.GridService, + // commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); + TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); + regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + + LoginService loginService = new LLStandaloneLoginService((UserManagerBase) lus, "Hello folks", commsManager.InterServiceInventoryService, + commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), regionConnector); // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. @@ -277,5 +289,89 @@ namespace OpenSim.Framework.Communications.Tests responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); } + + public class TestLoginToRegionConnector : ILoginRegionsConnector + { + + private List m_regionsList = new List(); + + public void AddRegion(RegionInfo regionInfo) + { + lock (m_regionsList) + { + if (!m_regionsList.Contains(regionInfo)) + { + m_regionsList.Add(regionInfo); + } + } + } + + #region ILoginRegionsConnector Members + public bool RegionLoginsEnabled + { + get { return true; } + } + + public void LogOffUserFromGrid(ulong regionHandle, OpenMetaverse.UUID AvatarID, OpenMetaverse.UUID RegionSecret, string message) + { + } + + public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) + { + lock (m_regionsList) + { + foreach (RegionInfo regInfo in m_regionsList) + { + if (regInfo.RegionHandle == regionHandle) + return true; + } + } + return false; + } + + public RegionInfo RequestClosestRegion(string region) + { + lock (m_regionsList) + { + foreach (RegionInfo regInfo in m_regionsList) + { + if (regInfo.RegionName == region) + return regInfo; + } + } + + return null; + } + + public RegionInfo RequestNeighbourInfo(OpenMetaverse.UUID regionID) + { + lock (m_regionsList) + { + foreach (RegionInfo regInfo in m_regionsList) + { + if (regInfo.RegionID == regionID) + return regInfo; + } + } + + return null; + } + + public RegionInfo RequestNeighbourInfo(ulong regionHandle) + { + lock (m_regionsList) + { + foreach (RegionInfo regInfo in m_regionsList) + { + if (regInfo.RegionHandle == regionHandle) + return regInfo; + } + } + + return null; + } + + #endregion + } } } -- cgit v1.1 From 84d6b024756a051fae1a6a24a925fa29f44b5c4e Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 3 Mar 2009 16:36:21 +0000 Subject: Renamed ILoginRegionsConnector to ILoginServiceToRegionsConnector and moved it from OpenSim.Client.Linden to OpenSim.Framework. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 854d68d..c737817 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -290,7 +290,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(responseData["message"], Is.EqualTo("Hello folks")); } - public class TestLoginToRegionConnector : ILoginRegionsConnector + public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector { private List m_regionsList = new List(); -- cgit v1.1 From 08509d5cf281004dca6ec42cd1d76a7896b0e73a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 6 Mar 2009 19:25:33 +0000 Subject: * Protects RestClient from crashing with dictionary exception, which leads to the client thread crashing if uncaught. --- OpenSim/Framework/Communications/RestClient.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 3035da5..db5010b 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -165,7 +165,18 @@ namespace OpenSim.Framework.Communications /// Value of the parameter, e.g. 42 public void AddQueryParameter(string name, string value) { - _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + try + { + _parameterElements.Add(HttpUtility.UrlEncode(name), HttpUtility.UrlEncode(value)); + } + catch (ArgumentException) + { + m_log.Error("[REST]: Query parameter " + name + " is already added."); + } + catch (Exception e) + { + m_log.Error("[REST]: An exception was raised adding query parameter to dictionary. Exception: {0}",e); + } } /// @@ -174,7 +185,18 @@ namespace OpenSim.Framework.Communications /// Name of the parameter, e.g. min public void AddQueryParameter(string name) { - _parameterElements.Add(HttpUtility.UrlEncode(name), null); + try + { + _parameterElements.Add(HttpUtility.UrlEncode(name), null); + } + catch (ArgumentException) + { + m_log.Error("[REST]: Query parameter " + name + " is already added."); + } + catch (Exception e) + { + m_log.Error("[REST]: An exception was raised adding query parameter to dictionary. Exception: {0}",e); + } } /// -- cgit v1.1 From 6f4051c93251c4c8a1cff91b3b449f1f25c94382 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 8 Mar 2009 23:17:49 +0000 Subject: Making the web_login_key code work, even if the LL Viewer doesn't support it. Other clients can launch the LL Viewer with something like this, for example: Process.Start("C:\\Program Files\\SecondLife\\SecondLife.exe", "-loginuri " + loginuri + "?web_login_key=" + web_login_key + " -login " + firstName + " " + lastName + " -multiple"); This requires a prior step for actually getting the key, which can be done like this: http://localhost:9000/?method=login&firstname=barak&lastname=obama&password=123&show_login_form=FALSE --- OpenSim/Framework/Communications/LoginService.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 454197a..1c72b79 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -116,6 +116,8 @@ namespace OpenSim.Framework.Communications XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable) request.Params[0]; + SniffLoginKey((Uri)request.Params[2], requestData); + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); @@ -303,7 +305,7 @@ namespace OpenSim.Framework.Communications string passwd = (string) requestData["passwd"]; GoodLogin = AuthenticateUser(userProfile, passwd); } - else if (requestData.Contains("web_login_key")) + if (!GoodLogin && (requestData.Contains("web_login_key"))) { try { @@ -576,7 +578,7 @@ namespace OpenSim.Framework.Communications { UUID webloginkey = UUID.Random(); m_userManager.StoreWebLoginKey(user.ID, webloginkey); - statuscode = 301; + //statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + @@ -584,8 +586,9 @@ namespace OpenSim.Framework.Communications "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); //m_log.Info("[WEB]: R:" + redirectURL); returnactions["int_response_code"] = statuscode; - returnactions["str_redirect_location"] = redirectURL; - returnactions["str_response_string"] = "GoodLogin"; + //returnactions["str_redirect_location"] = redirectURL; + //returnactions["str_response_string"] = "GoodLogin"; + returnactions["str_response_string"] = webloginkey.ToString(); } else { @@ -854,5 +857,17 @@ namespace OpenSim.Framework.Communications RootFolderID = rootID; } } + + protected void SniffLoginKey(Uri uri, Hashtable requestData) + { + string uri_str = uri.ToString(); + string[] parts = uri_str.Split(new char[] { '=' }); + if (parts.Length > 1) + { + string web_login_key = parts[1]; + requestData.Add("web_login_key", web_login_key); + m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); + } + } } } -- cgit v1.1 From 66120f5a4015d2659732672481c7533586b09e9e Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 9 Mar 2009 07:29:53 +0000 Subject: Fix tests broken in r8732. Recent changes in the code handling login_to_simulator XMLRPC method calls caused two tests to fail because not enough parameters were being supplied with the method call. The parameters added in this patch work, but I'm not sure whether they are actually correct or even relevant. Diva, please look over this. --- .../Framework/Communications/Tests/LoginServiceTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index c737817..d8d08c9 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -86,6 +86,8 @@ namespace OpenSim.Framework.Communications.Tests ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -148,6 +150,8 @@ namespace OpenSim.Framework.Communications.Tests ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -197,6 +201,8 @@ namespace OpenSim.Framework.Communications.Tests sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -231,6 +237,8 @@ namespace OpenSim.Framework.Communications.Tests sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -246,6 +254,8 @@ namespace OpenSim.Framework.Communications.Tests sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -261,6 +271,8 @@ namespace OpenSim.Framework.Communications.Tests sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -276,6 +288,8 @@ namespace OpenSim.Framework.Communications.Tests sendParams = new ArrayList(); sendParams.Add(loginParams); + sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? request = new XmlRpcRequest("login_to_simulator", sendParams); -- cgit v1.1 From 5bee29e036d9212319b4b752cb3869fe12c80412 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 9 Mar 2009 08:07:12 +0000 Subject: Refactor login test class. There were multiple tests in one test method (T011_Auth_Login). This test has been refactored into multiple tests. Common setup code was placed into a SetUp method executed before each test. --- .../Communications/Tests/LoginServiceTests.cs | 241 +++++++++++---------- 1 file changed, 126 insertions(+), 115 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d8d08c9..daa2a89 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -47,46 +47,54 @@ namespace OpenSim.Framework.Communications.Tests [TestFixture] public class LoginServiceTests { - /// - /// Test the normal response to a login. Does not test authentication. - /// - [Test] - public void T010_NormalLoginResponse() + private string m_firstName = "Adam"; + private string m_lastName = "West"; + private string m_regionExternalName = "localhost"; + + private IPEndPoint m_capsEndPoint; + private CommunicationsManager m_commsManager; + private TestLoginToRegionConnector m_regionConnector; + private LocalUserServices m_localUserServices; + private LoginService m_loginService; + private UserProfileData m_userProfileData; + + [SetUp] + public void SetUpLoginEnviroment() { - //log4net.Config.XmlConfigurator.Configure(); + m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); + m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); + m_regionConnector = new TestLoginToRegionConnector(); - string firstName = "Timmy"; - string lastName = "Mallet"; - string regionExternalName = "localhost"; - IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); + m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); - CommunicationsManager commsManager - = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); - - //commsManager.GridService.RegisterRegion( - // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); - //commsManager.GridService.RegionLoginsEnabled = true; + m_localUserServices = (LocalUserServices) m_commsManager.UserService; + m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); - //LoginService loginService - // = new LocalLoginService( - // (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, - // (LocalBackEndServices)commsManager.GridService, - // commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); + m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_commsManager.InterServiceInventoryService, + m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector); - TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); - regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); + m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); + } - LoginService loginService = new LLStandaloneLoginService((UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, - commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), regionConnector); + /// + /// Test the normal response to a login. Does not test authentication. + /// + [Test] + public void TestUnauthenticatedLogin() + { + // We want to use our own LoginService for this test, one that + // doesn't require authentication. + LoginService loginService = new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", m_commsManager.InterServiceInventoryService, + m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); Hashtable loginParams = new Hashtable(); - loginParams["first"] = firstName; - loginParams["last"] = lastName; + loginParams["first"] = m_firstName; + loginParams["last"] = m_lastName; loginParams["passwd"] = "boingboing"; ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); @@ -94,78 +102,48 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); Hashtable responseData = (Hashtable)response.Value; - Assert.That(responseData["first_name"], Is.EqualTo(firstName)); - Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); + Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); Assert.That( responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); Regex capsSeedPattern = new Regex("^http://" - + regionExternalName + + m_regionExternalName + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); } [Test] - public void T011_Auth_Login() + public void TestAuthenticatedLoginSuccess() { - string firstName = "Adam"; - string lastName = "West"; - string regionExternalName = "localhost"; - IPEndPoint capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); - - CommunicationsManager commsManager - = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); - - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - - lus.AddUser(firstName,lastName,"boingboing","abc@ftw.com",42,43); - - //commsManager.GridService.RegisterRegion( - // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); - //commsManager.GridService.RegionLoginsEnabled = true; - - //LoginService loginService - // = new LocalLoginService( - // (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, - // (LocalBackEndServices)commsManager.GridService, - // commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); - - TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); - regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); - - LoginService loginService = new LLStandaloneLoginService((UserManagerBase) lus, "Hello folks", commsManager.InterServiceInventoryService, - commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), regionConnector); - // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. // 1) Test for positive authentication Hashtable loginParams = new Hashtable(); - loginParams["first"] = firstName; - loginParams["last"] = lastName; + loginParams["first"] = m_firstName; + loginParams["last"] = m_lastName; loginParams["passwd"] = "boingboing"; ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); Hashtable responseData = (Hashtable)response.Value; - UserProfileData uprof = lus.GetUserProfile(firstName,lastName); - - UserAgentData uagent = uprof.CurrentAgent; + UserAgentData uagent = m_userProfileData.CurrentAgent; Assert.That(uagent,Is.Not.Null); Assert.That(responseData["first_name"], Is.Not.Null); - Assert.That(responseData["first_name"], Is.EqualTo(firstName)); - Assert.That(responseData["last_name"], Is.EqualTo(lastName)); + Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); + Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); Assert.That(responseData["agent_id"], Is.EqualTo(uagent.ProfileID.ToString())); Assert.That(responseData["session_id"], Is.EqualTo(uagent.SessionID.ToString())); Assert.That(responseData["secure_session_id"], Is.EqualTo(uagent.SecureSessionID.ToString())); @@ -180,34 +158,38 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" - + regionExternalName + + m_regionExternalName + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); + } + [Test] + public void TestAuthenticatedLoginForBuddies() + { // 1.1) Test for budddies! - lus.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); - lus.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); + m_localUserServices.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); + m_localUserServices.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); - UserProfileData friend1 = lus.GetUserProfile("Friend","Number1"); - UserProfileData friend2 = lus.GetUserProfile("Friend","Number2"); - lus.AddNewUserFriend(friend1.ID,uprof.ID,1); - lus.AddNewUserFriend(friend1.ID,friend2.ID,2); + UserProfileData friend1 = m_localUserServices.GetUserProfile("Friend","Number1"); + UserProfileData friend2 = m_localUserServices.GetUserProfile("Friend","Number2"); + m_localUserServices.AddNewUserFriend(friend1.ID,m_userProfileData.ID,1); + m_localUserServices.AddNewUserFriend(friend1.ID,friend2.ID,2); - loginParams = new Hashtable(); + Hashtable loginParams = new Hashtable(); loginParams["first"] = "Friend"; loginParams["last"] = "Number1"; loginParams["passwd"] = "boingboing"; - sendParams = new ArrayList(); + ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - request = new XmlRpcRequest("login_to_simulator", sendParams); + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); - responseData = (Hashtable)response.Value; + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; ArrayList friendslist = (ArrayList) responseData["buddy-list"]; @@ -217,89 +199,118 @@ namespace OpenSim.Framework.Communications.Tests Hashtable buddy1 = (Hashtable) friendslist[0]; Hashtable buddy2 = (Hashtable) friendslist[1]; Assert.That(friendslist.Count, Is.EqualTo(2)); - Assert.That(uprof.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); + Assert.That(m_userProfileData.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); Assert.That(friend2.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); + } + + [Test] + public void TestAuthenticatedLoginBadUsername() + { // 2) Test for negative authentication // string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; - string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; - string error_already_logged = "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; //string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; // 2.1) Test for wrong user name - loginParams = new Hashtable(); - loginParams["first"] = lastName; - loginParams["last"] = firstName; + Hashtable loginParams = new Hashtable(); + loginParams["first"] = m_lastName; + loginParams["last"] = m_firstName; loginParams["passwd"] = "boingboing"; - sendParams = new ArrayList(); + ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - request = new XmlRpcRequest("login_to_simulator", sendParams); + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); - responseData = (Hashtable)response.Value; + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); + } + + [Test] + public void TestAuthenticatedLoginBadPassword() + { + string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; // 2.2) Test for wrong password - loginParams = new Hashtable(); + Hashtable loginParams = new Hashtable(); loginParams["first"] = "Friend"; loginParams["last"] = "Number2"; loginParams["passwd"] = "boing"; - sendParams = new ArrayList(); + ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - request = new XmlRpcRequest("login_to_simulator", sendParams); + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); - responseData = (Hashtable)response.Value; + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); + } + + [Test] + public void TestAuthenticatedLoginBadXml() + { + string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; // 2.3) Bad XML - loginParams = new Hashtable(); + Hashtable loginParams = new Hashtable(); loginParams["first"] = "Friend"; loginParams["banana"] = "Banana"; loginParams["passwd"] = "boingboing"; - - sendParams = new ArrayList(); + + ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - request = new XmlRpcRequest("login_to_simulator", sendParams); + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); - responseData = (Hashtable)response.Value; + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); - + + } + + [Test] + public void TestAuthenticatedLoginAlreadyLoggedIn() + { + string error_already_logged = "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner. " + + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; // 2.4) Already logged in and sucessfull post login - loginParams = new Hashtable(); + Hashtable loginParams = new Hashtable(); loginParams["first"] = "Adam"; loginParams["last"] = "West"; loginParams["passwd"] = "boingboing"; - sendParams = new ArrayList(); + ArrayList sendParams = new ArrayList(); sendParams.Add(loginParams); - sendParams.Add(capsEndPoint); // is this parameter correct? + sendParams.Add(m_capsEndPoint); // is this parameter correct? sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? + // First we log in. + XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + Assert.That(responseData["message"], Is.EqualTo("Hello folks")); + + // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); + response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); + // Finally the third time we should be able to get right back in. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = loginService.XmlRpcLoginMethod(request); + response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); } -- cgit v1.1 From a2ff2e9000db4cfc817f6bc1971674186f3af3b3 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 9 Mar 2009 15:20:36 +0000 Subject: * Added TXXX in front of unit tests to make sure they are running in the correct order. Although it might not make a difference here, this pattern should be followed to avoid further issues. From: Arthur Rodrigo S Valadares --- .../Framework/Communications/Tests/LoginServiceTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index daa2a89..ca25922 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Tests /// Test the normal response to a login. Does not test authentication. /// [Test] - public void TestUnauthenticatedLogin() + public void T010_TestUnauthenticatedLogin() { // We want to use our own LoginService for this test, one that // doesn't require authentication. @@ -116,7 +116,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginSuccess() + public void T011_TestAuthenticatedLoginSuccess() { // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. @@ -165,7 +165,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginForBuddies() + public void T012_TestAuthenticatedLoginForBuddies() { // 1.1) Test for budddies! m_localUserServices.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); @@ -204,7 +204,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginBadUsername() + public void T020_TestAuthenticatedLoginBadUsername() { // 2) Test for negative authentication @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginBadPassword() + public void T021_TestAuthenticatedLoginBadPassword() { string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; // 2.2) Test for wrong password @@ -254,7 +254,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginBadXml() + public void T022_TestAuthenticatedLoginBadXml() { string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; // 2.3) Bad XML @@ -277,7 +277,7 @@ namespace OpenSim.Framework.Communications.Tests } [Test] - public void TestAuthenticatedLoginAlreadyLoggedIn() + public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { string error_already_logged = "You appear to be already logged in. " + "If this is not the case please wait for your session to timeout. " + -- cgit v1.1 From 5a6bc26600c80d8e838bafdde4df970841c6c285 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 9 Mar 2009 17:55:08 +0000 Subject: * Address http://opensimulator.org/mantis/view.php?id=3207 * A saved archive now immediately expires the data in the asset cache that it used, rather than retaining all the assets (esp textures) in the cache. * This is an imperfect solution. Ideally we would only expire the assets newly requested for the archive (not existing ones). But doing that would require a lot more restructuring. * I don't believe there are any locking issues due to the locking performed by the underlying memory cache, but please report any issues. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 800c997..30f7ddf 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -46,8 +46,7 @@ namespace OpenSim.Framework.Communications.Cache /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and - /// AssetNotFound(), which means they do share the same asset and texture caches.I agr - + /// AssetNotFound(), which means they do share the same asset and texture caches. public class AssetCache : IAssetCache { @@ -401,9 +400,7 @@ namespace OpenSim.Framework.Communications.Cache m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); if (StatsManager.SimExtraStats != null) - { StatsManager.SimExtraStats.AddAsset(assetInf); - } if (RequestedAssets.ContainsKey(assetInf.FullID)) { -- cgit v1.1 From 1bf05a543c1328c31b7b107a3335f34e8d174ed8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 9 Mar 2009 18:35:26 +0000 Subject: * Move method documentation from AssetCache up to IAssetCache * No functional changes --- .../Framework/Communications/Cache/AssetCache.cs | 90 +++------------------- 1 file changed, 10 insertions(+), 80 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 30f7ddf..dfbdb09 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -37,8 +37,6 @@ using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications.Cache { - // public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); - /// /// Manages local cache of assets and their sending to viewers. /// @@ -49,7 +47,6 @@ namespace OpenSim.Framework.Communications.Cache /// AssetNotFound(), which means they do share the same asset and texture caches. public class AssetCache : IAssetCache { - #region IPlugin /// @@ -88,7 +85,6 @@ namespace OpenSim.Framework.Communications.Cache assetCacheThread.IsBackground = true; assetCacheThread.Start(); ThreadTracker.Add(assetCacheThread); - } public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer) @@ -113,44 +109,27 @@ namespace OpenSim.Framework.Communications.Cache private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// The cache of assets. This does not include textures. - /// - //private Dictionary Assets; - - /// - /// The cache of textures. - /// - //private Dictionary Textures; - - /// + /// /// Assets requests which are waiting for asset server data. This includes texture requests - /// + /// private Dictionary RequestedAssets; - /// + /// /// Asset requests with data which are ready to be sent back to requesters. This includes textures. - /// + /// private List AssetRequests; - /// + /// /// Until the asset request is fulfilled, each asset request is associated with a list of requesters - /// - private Dictionary RequestLists; - - /// - /// The 'server' from which assets can be requested and to which assets are persisted. - /// - private IAssetServer m_assetServer; + /// + private Dictionary RequestLists; public IAssetServer AssetServer { get { return m_assetServer; } } + private IAssetServer m_assetServer; - /// - /// Report statistical data. - /// public void ShowState() { m_log.InfoFormat("Memcache:{0} RequestLists:{1}", @@ -160,9 +139,6 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Count); } - /// - /// Clear the asset cache. - /// public void Clear() { m_log.Info("[ASSET CACHE]: Clearing Asset cache"); @@ -214,12 +190,6 @@ namespace OpenSim.Framework.Communications.Cache } } - /// - /// Only get an asset if we already have it in the cache. - /// - /// - /// - /// true if the asset was in the cache, false if it was not public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) { Object tmp; @@ -234,15 +204,6 @@ namespace OpenSim.Framework.Communications.Cache return false; } - /// - /// Asynchronously retrieve an asset. - /// - /// - /// - /// - /// A callback invoked when the asset has either been found or not found. - /// If the asset was found this is called with the asset UUID and the asset data - /// If the asset was not found this is still called with the asset UUID but with a null asset data reference public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture) { //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); @@ -288,19 +249,6 @@ namespace OpenSim.Framework.Communications.Cache } } - /// - /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to - /// load it into the cache. - /// - /// - /// XXX We'll keep polling the cache until we get the asset or we exceed - /// the allowed number of polls. This isn't a very good way of doing things since a single thread - /// is processing inbound packets, so if the asset server is slow, we could block this for up to - /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() - /// - /// - /// - /// null if the asset could not be retrieved public AssetBase GetAsset(UUID assetID, bool isTexture) { // I'm not going over 3 seconds since this will be blocking processing of all the other inbound @@ -334,10 +282,6 @@ namespace OpenSim.Framework.Communications.Cache return null; } - /// - /// Add an asset to both the persistent store and the cache. - /// - /// public void AddAsset(AssetBase asset) { if (!m_memcache.Contains(asset.FullID)) @@ -371,13 +315,6 @@ namespace OpenSim.Framework.Communications.Cache } } - /// - /// Allows you to clear a specific asset by uuid out - /// of the asset cache. This is needed because the osdynamic - /// texture code grows the asset cache without bounds. The - /// real solution here is a much better cache archicture, but - /// this is a stop gap measure until we have such a thing. - /// public void ExpireAsset(UUID uuid) { // uuid is unique, so no need to worry about it showing up @@ -393,7 +330,6 @@ namespace OpenSim.Framework.Communications.Cache // See IAssetReceiver public virtual void AssetReceived(AssetBase asset, bool IsTexture) { - AssetInfo assetInf = new AssetInfo(asset); if (!m_memcache.Contains(assetInf.FullID)) { @@ -488,11 +424,6 @@ namespace OpenSim.Framework.Communications.Cache return numPackets; } - /// - /// Handle an asset request from the client. The result will be sent back asynchronously. - /// - /// - /// public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) { UUID requestID = UUID.Zero; @@ -581,8 +512,8 @@ namespace OpenSim.Framework.Communications.Cache { req2 = new AssetRequestToClient(); } - // Trying to limit memory usage by only creating AssetRequestToClient if needed - //req2 = new AssetRequestToClient(); + + // Trying to limit memory usage by only creating AssetRequestToClient if needed req2.AssetInf = req.AssetInf; req2.AssetRequestSource = req.AssetRequestSource; req2.DataPointer = req.DataPointer; @@ -595,7 +526,6 @@ namespace OpenSim.Framework.Communications.Cache req2.RequestAssetID = req.RequestAssetID; req2.TransferRequestID = req.TransferRequestID; req.RequestUser.SendAsset(req2); - } //remove requests that have been completed -- cgit v1.1 From ae759f2d060bc53cc0b372d5584fcd4ffdd963b4 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 9 Mar 2009 19:40:32 +0000 Subject: * Add basic asset cache get test --- .../Communications/Cache/GridAssetClient.cs | 5 +- .../Communications/Cache/SQLAssetServer.cs | 7 +- .../Communications/Tests/Cache/AssetCacheTests.cs | 88 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 3b6dc52..7131cb5 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -36,7 +36,6 @@ namespace OpenSim.Framework.Communications.Cache { public class GridAssetClient : AssetServerBase { - #region IPlugin public override string Name @@ -51,7 +50,7 @@ namespace OpenSim.Framework.Communications.Cache public override void Initialise(ConfigSettings p_set, string p_url) { - m_log.Debug("[GRIDASSET] Plugin configured initialisation"); + m_log.Debug("[GRID ASSET CLIENT]: Plugin configured initialisation"); Initialise(p_url); } @@ -65,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache public GridAssetClient(string p_url) { - m_log.Debug("[GRIDASSET] Direct constructor"); + m_log.Debug("[GRID ASSET CLIENT]: Direct constructor"); Initialise(p_url); } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 5274288..41a9561 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -34,7 +34,6 @@ namespace OpenSim.Framework.Communications.Cache { public class SQLAssetServer : AssetServerBase { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #region IPlugin @@ -51,7 +50,7 @@ namespace OpenSim.Framework.Communications.Cache public override void Initialise(ConfigSettings p_set) { - m_log.Debug("[SQLASSET] Plugin configured initialisation"); + m_log.Debug("[SQLAssetServer]: Plugin configured initialisation"); Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource); } @@ -61,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache public SQLAssetServer(string pluginName, string connect) { - m_log.Debug("[SQLASSET] Direct constructor"); + m_log.Debug("[SQLAssetServer]: Direct constructor"); Initialise(pluginName, connect); } @@ -108,7 +107,7 @@ namespace OpenSim.Framework.Communications.Cache protected override AssetBase GetAsset(AssetRequest req) { - return m_assetProvider.FetchAsset(req.AssetID);; + return m_assetProvider.FetchAsset(req.AssetID); } public override void StoreAsset(AssetBase asset) diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs new file mode 100644 index 0000000..34193b5 --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Threading; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Framework.Communications.Tests +{ + /// + /// Asset cache tests + /// + [TestFixture] + public class AssetCacheTests + { + protected UUID m_assetIdReceived; + protected AssetBase m_assetReceived; + + [Test] + /// + /// Test the 'asynchronous' get asset mechanism (though this won't be done asynchronously within this test) + /// + public void TestGetAsset() + { + UUID assetId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + byte[] assetData = new byte[] { 3, 2, 1 }; + + AssetBase asset = new AssetBase(); + asset.FullID = assetId; + asset.Data = assetData; + + TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); + assetPlugin.CreateAsset(asset); + + IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin)); + + lock (this) + { + assetCache.GetAsset(assetId, AssetRequestCallback, false); + Monitor.Wait(this, 60000); + } + + Assert.That( + assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received"); + Assert.That( + assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received"); + } + + private void AssetRequestCallback(UUID assetId, AssetBase asset) + { + m_assetIdReceived = assetId; + m_assetReceived = asset; + + lock (this) + { + Monitor.PulseAll(this); + } + } + } +} -- cgit v1.1 From 051096e8ae6d6eb262f1e5398ab1521db05bae2e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 9 Mar 2009 19:58:39 +0000 Subject: * minor: remove some mono compiler warnings --- OpenSim/Framework/Communications/LoginService.cs | 10 +++++----- .../Framework/Communications/Tests/Cache/AssetCacheTests.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 1c72b79..e8e0559 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -579,11 +579,11 @@ namespace OpenSim.Framework.Communications UUID webloginkey = UUID.Random(); m_userManager.StoreWebLoginKey(user.ID, webloginkey); //statuscode = 301; - - string redirectURL = "about:blank?redirect-http-hack=" + - HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + - lastname + - "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + +// string redirectURL = "about:blank?redirect-http-hack=" + +// HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + +// lastname + +// "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); //m_log.Info("[WEB]: R:" + redirectURL); returnactions["int_response_code"] = statuscode; //returnactions["str_redirect_location"] = redirectURL; diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 34193b5..18ae9a7 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -43,11 +43,11 @@ namespace OpenSim.Framework.Communications.Tests { protected UUID m_assetIdReceived; protected AssetBase m_assetReceived; - - [Test] + /// /// Test the 'asynchronous' get asset mechanism (though this won't be done asynchronously within this test) /// + [Test] public void TestGetAsset() { UUID assetId = UUID.Parse("00000000-0000-0000-0000-000000000001"); -- cgit v1.1 From 1917238cd3f24f05343a8b7737b8208c6e587700 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 10 Mar 2009 11:47:34 +0000 Subject: * Re-aligned CustomiseResponse function for imminent up-pulling --- OpenSim/Framework/Communications/LoginService.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index e8e0559..36d7280 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -56,6 +56,9 @@ namespace OpenSim.Framework.Communications /// protected LibraryRootFolder m_libraryRootFolder; + protected uint m_defaultHomeX; + protected uint m_defaultHomeY; + /// /// Constructor /// -- cgit v1.1 From 0df0258087e18757a77514ac4cba8a50e01b27d5 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 10 Mar 2009 12:11:19 +0000 Subject: *** POTENTIAL BREAKAGE *** * Finally got to the point where I could pull up the CustomiseResponse function. Major de-duplication. * Introduced FromRegionInfo on RegionProfileData * This revision needs both grid and standalone testing galore. Work in progress! --- OpenSim/Framework/Communications/LoginService.cs | 150 +++++++++++++++++++++-- 1 file changed, 141 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 36d7280..1e7faa5 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -78,15 +78,6 @@ namespace OpenSim.Framework.Communications } /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// true on success, false if the region was not successfully told to expect a user connection - public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); - - /// /// If the user is already logged in, try to notify the region that the user they've got is dead. /// /// @@ -872,5 +863,146 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); } } + + /// + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. + /// + /// The existing response + /// The user profile + /// The requested start location + /// true on success, false if the region was not successfully told to expect a user connection + public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + { + // add active gestures to login-response + AddActiveGestures(response, theUser); + + // HomeLocation + RegionInfo homeInfo = null; + + // use the homeRegionID if it is stored already. If not, use the regionHandle as before + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } + else + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + + if (homeInfo != null) + { + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + (homeInfo.RegionLocX * Constants.RegionSize), + (homeInfo.RegionLocY * Constants.RegionSize), + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + } + else + { + m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); + // Emergency mode: Home-region isn't available, so we can't request the region info. + // Use the stored home regionHandle instead. + // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + regionX, regionY, + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + + m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", + theUser.FirstName, theUser.SurName, + regionX, regionY); + } + + // StartLocation + RegionInfo regionInfo = null; + if (startLocationRequest == "home") + { + regionInfo = homeInfo; + theUser.CurrentAgent.Position = theUser.HomeLocation; + response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + } + else if (startLocationRequest == "last") + { + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); + response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + } + else + { + Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); + Match uriMatch = reURI.Match(startLocationRequest); + if (uriMatch == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); + } + else + { + string region = uriMatch.Groups["region"].ToString(); + regionInfo = RequestClosestRegion(region); + if (regionInfo == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); + } + else + { + theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), + float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); + } + } + response.LookAt = "[r0,r1,r0]"; + // can be: last, home, safe, url + response.StartLocation = "url"; + } + + if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) + { + return true; + } + + // StartLocation not available, send him to a nearby region instead + // regionInfo = m_gridService.RequestClosestRegion(""); + //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + + // Send him to default region instead + ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | + ((ulong)m_defaultHomeY * Constants.RegionSize); + + if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + { + m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); + return false; + } + + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); + + // Customise the response + //response.Home = + // string.Format( + // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + // (SimInfo.regionLocX * Constants.RegionSize), + // (SimInfo.regionLocY*Constants.RegionSize), + // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + response.StartLocation = "safe"; + + return PrepareLoginToRegion(regionInfo, theUser, response); + } + + protected abstract RegionInfo RequestClosestRegion(string region); + protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); + protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); + protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser); + protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); } } -- cgit v1.1 From acad0328b2c50d22fe76ebb7c8de2c97c856b42f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 11 Mar 2009 18:02:22 +0000 Subject: * Make all coded defaults match settings in OpenSim.ini.example * In most cases, the setting in OpenSim.ini.example is taken as the canonical one since this is the file virtually everyone ends up using * OpenSim will start up with a blank OpenSim.ini, in which case sqlite is the default database (as before) --- OpenSim/Framework/Communications/GridInfoService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index 488ce8e..bb54c1b 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -102,9 +102,15 @@ namespace OpenSim.Framework.Communications else if (null != netCfg) { if (grid) - _info["login"] = netCfg.GetString("user_server_url"); - else - _info["login"] = String.Format("http://127.0.0.1:{0}/", netCfg.GetString("http_listener_port")); + _info["login"] + = netCfg.GetString( + "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + else + _info["login"] + = String.Format( + "http://127.0.0.1:{0}/", + netCfg.GetString("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort)); + IssueWarning(); } else -- cgit v1.1 From 2e6e0cee28a34579091437e37fbbbb75342258e3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 11 Mar 2009 18:21:47 +0000 Subject: * fix build break --- OpenSim/Framework/Communications/GridInfoService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs index bb54c1b..4ad447d 100644 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ b/OpenSim/Framework/Communications/GridInfoService.cs @@ -109,7 +109,8 @@ namespace OpenSim.Framework.Communications _info["login"] = String.Format( "http://127.0.0.1:{0}/", - netCfg.GetString("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort)); + netCfg.GetString( + "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); IssueWarning(); } -- cgit v1.1 From 2133d358317f28fe54020207ed8fa59562e1d6eb Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 11 Mar 2009 19:19:48 +0000 Subject: * Reverted r8750 to do another round of debugging on mantis #3287 --- OpenSim/Framework/Communications/LoginService.cs | 150 ++--------------------- 1 file changed, 9 insertions(+), 141 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 1e7faa5..36d7280 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -78,6 +78,15 @@ namespace OpenSim.Framework.Communications } /// + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. + /// + /// The existing response + /// The user profile + /// true on success, false if the region was not successfully told to expect a user connection + public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); + + /// /// If the user is already logged in, try to notify the region that the user they've got is dead. /// /// @@ -863,146 +872,5 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); } } - - /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// The requested start location - /// true on success, false if the region was not successfully told to expect a user connection - public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) - { - // add active gestures to login-response - AddActiveGestures(response, theUser); - - // HomeLocation - RegionInfo homeInfo = null; - - // use the homeRegionID if it is stored already. If not, use the regionHandle as before - UUID homeRegionId = theUser.HomeRegionID; - ulong homeRegionHandle = theUser.HomeRegion; - if (homeRegionId != UUID.Zero) - { - homeInfo = GetRegionInfo(homeRegionId); - } - else - { - homeInfo = GetRegionInfo(homeRegionHandle); - } - - if (homeInfo != null) - { - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - (homeInfo.RegionLocX * Constants.RegionSize), - (homeInfo.RegionLocY * Constants.RegionSize), - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - } - else - { - m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); - // Emergency mode: Home-region isn't available, so we can't request the region info. - // Use the stored home regionHandle instead. - // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = homeRegionHandle >> 32; - ulong regionY = homeRegionHandle & 0xffffffff; - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - regionX, regionY, - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - - m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", - theUser.FirstName, theUser.SurName, - regionX, regionY); - } - - // StartLocation - RegionInfo regionInfo = null; - if (startLocationRequest == "home") - { - regionInfo = homeInfo; - theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; - } - else if (startLocationRequest == "last") - { - UUID lastRegion = theUser.CurrentAgent.Region; - regionInfo = GetRegionInfo(lastRegion); - response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; - } - else - { - Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); - Match uriMatch = reURI.Match(startLocationRequest); - if (uriMatch == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); - } - else - { - string region = uriMatch.Groups["region"].ToString(); - regionInfo = RequestClosestRegion(region); - if (regionInfo == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); - } - else - { - theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), - float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); - } - } - response.LookAt = "[r0,r1,r0]"; - // can be: last, home, safe, url - response.StartLocation = "url"; - } - - if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) - { - return true; - } - - // StartLocation not available, send him to a nearby region instead - // regionInfo = m_gridService.RequestClosestRegion(""); - //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); - - // Send him to default region instead - ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | - ((ulong)m_defaultHomeY * Constants.RegionSize); - - if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) - { - m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); - return false; - } - - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - - // Customise the response - //response.Home = - // string.Format( - // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - // (SimInfo.regionLocX * Constants.RegionSize), - // (SimInfo.regionLocY*Constants.RegionSize), - // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - theUser.CurrentAgent.Position = new Vector3(128, 128, 0); - response.StartLocation = "safe"; - - return PrepareLoginToRegion(regionInfo, theUser, response); - } - - protected abstract RegionInfo RequestClosestRegion(string region); - protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); - protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser); - protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); } } -- cgit v1.1 From 33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 12 Mar 2009 10:50:59 +0000 Subject: * Another stab at refactoring up the CustomiseResponse function. Two fixes: * Sometimes, null is a valid return value to indicate 'none found'. doh. * Sometimes, the Grid server does not send simURI - this you need to reconstruct yourself. Euw. (I believe) this solves mantis issue #3287 --- OpenSim/Framework/Communications/LoginService.cs | 156 +++++++++++++++++++++-- 1 file changed, 147 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 36d7280..278ea43 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -78,15 +78,6 @@ namespace OpenSim.Framework.Communications } /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// true on success, false if the region was not successfully told to expect a user connection - public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); - - /// /// If the user is already logged in, try to notify the region that the user they've got is dead. /// /// @@ -872,5 +863,152 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); } } + + /// + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. + /// + /// The existing response + /// The user profile + /// The requested start location + /// true on success, false if the region was not successfully told to expect a user connection + public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + { + // add active gestures to login-response + AddActiveGestures(response, theUser); + + // HomeLocation + RegionInfo homeInfo = null; + + // use the homeRegionID if it is stored already. If not, use the regionHandle as before + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } + else + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + + if (homeInfo != null) + { + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + (homeInfo.RegionLocX * Constants.RegionSize), + (homeInfo.RegionLocY * Constants.RegionSize), + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + } + else + { + m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); + // Emergency mode: Home-region isn't available, so we can't request the region info. + // Use the stored home regionHandle instead. + // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + regionX, regionY, + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + + m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", + theUser.FirstName, theUser.SurName, + regionX, regionY); + } + + // StartLocation + RegionInfo regionInfo = null; + if (startLocationRequest == "home") + { + regionInfo = homeInfo; + theUser.CurrentAgent.Position = theUser.HomeLocation; + response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + } + else if (startLocationRequest == "last") + { + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); + response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + } + else + { + Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); + Match uriMatch = reURI.Match(startLocationRequest); + if (uriMatch == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); + } + else + { + string region = uriMatch.Groups["region"].ToString(); + regionInfo = RequestClosestRegion(region); + if (regionInfo == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); + } + else + { + theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), + float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); + } + } + response.LookAt = "[r0,r1,r0]"; + // can be: last, home, safe, url + response.StartLocation = "url"; + } + + if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) + { + return true; + } + + // StartLocation not available, send him to a nearby region instead + // regionInfo = m_gridService.RequestClosestRegion(""); + //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + + // Send him to default region instead + ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | + ((ulong)m_defaultHomeY * Constants.RegionSize); + + if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + { + m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); + return false; + } + + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); + + if( regionInfo == null ) + { + m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); + return false; + } + + // Customise the response + //response.Home = + // string.Format( + // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + // (SimInfo.regionLocX * Constants.RegionSize), + // (SimInfo.regionLocY*Constants.RegionSize), + // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + response.StartLocation = "safe"; + + return PrepareLoginToRegion(regionInfo, theUser, response); + } + + protected abstract RegionInfo RequestClosestRegion(string region); + protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); + protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); + protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser); + protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); } } -- cgit v1.1 From fb258c5ed98a1b7b1046e7387d8f130f7a4587d3 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 12 Mar 2009 15:28:30 +0000 Subject: Update svn properties, formatting cleanup. --- OpenSim/Framework/Communications/LoginService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 278ea43..92bf83f 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -318,7 +318,7 @@ namespace OpenSim.Framework.Communications return GoodLogin; } - protected virtual bool TryAuthenticateLLSDLogin( string firstname, string lastname, string passwd, out UserProfileData userProfile) + protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) { bool GoodLogin = false; userProfile = GetTheUser(firstname, lastname); @@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications } m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname+"' '"+lastname+"' / "+passwd); - if (!TryAuthenticateLLSDLogin( firstname, lastname, passwd, out userProfile)) + if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) { return logResponse.CreateLoginFailedResponseLLSD(); } @@ -985,7 +985,7 @@ namespace OpenSim.Framework.Communications m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); regionInfo = GetRegionInfo(defaultHandle); - if( regionInfo == null ) + if (regionInfo == null) { m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); return false; -- cgit v1.1 From 6573e2ee2f2a5df57e40a1fa83688477e9d15ff3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 13 Mar 2009 18:36:24 +0000 Subject: * Remove asset cache size and texture stat reports from ASSET STATS since these are now inaccurate * Correct count of assets in cache --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dfbdb09..7d06a1e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -312,18 +312,20 @@ namespace OpenSim.Framework.Communications.Cache { m_assetServer.StoreAsset(asset); } + + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.AddAsset(asset); } } public void ExpireAsset(UUID uuid) { - // uuid is unique, so no need to worry about it showing up - // in the 2 caches differently. Also, locks are probably - // needed in all of this, or move to synchronized non - // generic forms for Dictionaries. if (m_memcache.Contains(uuid)) { m_memcache.Remove(uuid); + + if (StatsManager.SimExtraStats != null) + StatsManager.SimExtraStats.RemoveAsset(uuid); } } -- cgit v1.1 From c04e7cdf2b8f95534dafe7faedb29e1ff1af36c8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 13 Mar 2009 20:46:53 +0000 Subject: * Support loading empty folders in an iar --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7bb2ab9..1d0c030 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -214,9 +214,7 @@ namespace OpenSim.Framework.Communications.Cache req.IsTexture = isTexture; m_assetRequests.Enqueue(req); - #if DEBUG - //m_log.InfoFormat("[ASSET SERVER]: Added {0} to request queue", assetID); - #endif + //m_log.DebugFormat("[ASSET SERVER]: Added {0} to request queue", assetID); } public virtual void UpdateAsset(AssetBase asset) -- cgit v1.1 From a7d610ffcca8d707c7f9e9fdd7ad1477981ec2a9 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 18 Mar 2009 16:37:26 +0000 Subject: Adds support for unlink-region command in hypergrid. --- OpenSim/Framework/Communications/IGridServices.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 69e8756..fa4d8d0 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -65,6 +65,9 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); RegionInfo RequestNeighbourInfo(UUID regionID); + RegionInfo RequestNeighbourInfo(string name); + RegionInfo RequestNeighbourInfo(string host, uint port); + RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); -- cgit v1.1 From bd2180d9af21dd54d4199a9381afa3e43e913823 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 19 Mar 2009 18:11:44 +0000 Subject: * refactor: Create IHttpServer interface instead of accessing BaseHttpServer via CommunicationsManager directly --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 17 +++++++++-------- .../Communications/Capabilities/CapsHandlers.cs | 5 +++-- .../Framework/Communications/CommunicationsManager.cs | 12 +++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 4ab304f..fde44be 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -33,6 +33,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.Interfaces; // using OpenSim.Region.Framework.Interfaces; @@ -95,7 +96,7 @@ namespace OpenSim.Framework.Communications.Capabilities // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. //private string eventQueue = "0100/"; - private BaseHttpServer m_httpListener; + private IHttpServer m_httpListener; private UUID m_agentID; private IAssetCache m_assetCache; private int m_eventQueueCount = 1; @@ -120,7 +121,7 @@ namespace OpenSim.Framework.Communications.Capabilities public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; public GetClientDelegate GetClient = null; - public Caps(IAssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, + public Caps(IAssetCache assetCache, IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, UUID agent, bool dumpAssetsToFile, string regionName) { m_assetCache = assetCache; @@ -808,7 +809,7 @@ namespace OpenSim.Framework.Communications.Capabilities private UUID newAssetID; private UUID inventoryItemID; private UUID parentFolder; - private BaseHttpServer httpListener; + private IHttpServer httpListener; private bool m_dumpAssetsToFile; private string m_assetName = String.Empty; private string m_assetDes = String.Empty; @@ -818,7 +819,7 @@ namespace OpenSim.Framework.Communications.Capabilities public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, - BaseHttpServer httpServer, bool dumpAssetsToFile) + IHttpServer httpServer, bool dumpAssetsToFile) { m_assetName = assetName; m_assetDes = description; @@ -907,10 +908,10 @@ namespace OpenSim.Framework.Communications.Capabilities private string uploaderPath = String.Empty; private UUID inventoryItemID; - private BaseHttpServer httpListener; + private IHttpServer httpListener; private bool m_dumpAssetToFile; - public ItemUpdater(UUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) + public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; @@ -991,11 +992,11 @@ namespace OpenSim.Framework.Communications.Capabilities private UUID inventoryItemID; private UUID primID; private bool isScriptRunning; - private BaseHttpServer httpListener; + private IHttpServer httpListener; private bool m_dumpAssetToFile; public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, - string path, BaseHttpServer httpServer, bool dumpAssetToFile) + string path, IHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index ed31c45..b47d014 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -28,6 +28,7 @@ using System.Collections; using System.Collections.Generic; using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.Interfaces; namespace OpenSim.Framework.Communications.Capabilities { @@ -39,7 +40,7 @@ namespace OpenSim.Framework.Communications.Capabilities public class CapsHandlers { private Dictionary m_capsHandlers = new Dictionary(); - private BaseHttpServer m_httpListener; + private IHttpServer m_httpListener; private string m_httpListenerHostName; private uint m_httpListenerPort; private bool m_useSSL = false; @@ -67,7 +68,7 @@ namespace OpenSim.Framework.Communications.Capabilities /// host name of the HTTP /// server /// HTTP port - public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) + public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) { m_httpListener = httpListener; m_httpListenerHostName = httpListenerHostname; diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 3363c24..b4078fd 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -29,7 +29,7 @@ using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.Interfaces; namespace OpenSim.Framework.Communications { @@ -106,12 +106,14 @@ namespace OpenSim.Framework.Communications } protected IUserAdminService m_userAdminService; - public BaseHttpServer HttpServer + /// + /// OpenSimulator's built in HTTP server + /// + public IHttpServer HttpServer { get { return m_httpServer; } } - protected BaseHttpServer m_httpServer; - + protected IHttpServer m_httpServer; /// /// Constructor @@ -120,7 +122,7 @@ namespace OpenSim.Framework.Communications /// /// /// - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, IAssetCache assetCache, + public CommunicationsManager(NetworkServersInfo serversInfo, IHttpServer httpServer, IAssetCache assetCache, bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; -- cgit v1.1 From 2a76b2a417a704f4893e66347090f9f752114c1b Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 19 Mar 2009 21:43:35 +0000 Subject: Moving GetInventoryItem up to InventoryServiceBase, since this seems like a pretty fundamental function. --- OpenSim/Framework/Communications/InventoryServiceBase.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index de76415..8068080 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -321,6 +321,16 @@ namespace OpenSim.Framework.Communications } } + public InventoryItemBase GetInventoryItem(UUID itemID) + { + foreach (IInventoryDataPlugin plugin in m_plugins) + { + return plugin.getInventoryItem(itemID); + } + + return null; + } + /// /// Used to create a new user inventory. /// -- cgit v1.1 From feaa64507183c6bedac790f5c3986cda191a5c3e Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 20 Mar 2009 06:49:12 +0000 Subject: * De-duplicated login service some more * Normalized m_inventoryService * Pulled AddActiveGestures up --- OpenSim/Framework/Communications/LoginService.cs | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 92bf83f..b84f5b6 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -60,6 +60,11 @@ namespace OpenSim.Framework.Communications protected uint m_defaultHomeY; /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_inventoryService; + + /// /// Constructor /// /// @@ -1008,7 +1013,33 @@ namespace OpenSim.Framework.Communications protected abstract RegionInfo RequestClosestRegion(string region); protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser); protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); + + /// + /// Add active gestures of the user to the login response. + /// + /// + /// A + /// + /// + /// A + /// + protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) + { + List gestures = m_inventoryService.GetActiveGestures(theUser.ID); + //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); + ArrayList list = new ArrayList(); + if (gestures != null) + { + foreach (InventoryItemBase gesture in gestures) + { + Hashtable item = new Hashtable(); + item["item_id"] = gesture.ID.ToString(); + item["asset_id"] = gesture.AssetID.ToString(); + list.Add(item); + } + } + response.ActiveGestures = list; + } } } -- cgit v1.1 From 613201e22045166d5a22f7bc1ef75ebe6639b1de Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 20 Mar 2009 17:25:12 +0000 Subject: * Normalized and pulled GetInventorySkeleton up. --- OpenSim/Framework/Communications/LoginService.cs | 110 ++++++++++++++++------- 1 file changed, 79 insertions(+), 31 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index b84f5b6..99b5df7 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -90,13 +90,6 @@ namespace OpenSim.Framework.Communications { } - /// - /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. - /// - /// - /// - /// This will be thrown if there is a problem with the inventory service - protected abstract InventoryData GetInventorySkeleton(UUID userID); /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message @@ -107,13 +100,13 @@ namespace OpenSim.Framework.Communications { // Temporary fix m_loginMutex.WaitOne(); - + try { //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. //CKF: m_log.Info("[LOGIN]: Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable) request.Params[0]; + Hashtable requestData = (Hashtable)request.Params[0]; SniffLoginKey((Uri)request.Params[2], requestData); @@ -301,14 +294,14 @@ namespace OpenSim.Framework.Communications { if (requestData.Contains("passwd")) { - string passwd = (string) requestData["passwd"]; + string passwd = (string)requestData["passwd"]; GoodLogin = AuthenticateUser(userProfile, passwd); } if (!GoodLogin && (requestData.Contains("web_login_key"))) { try { - UUID webloginkey = new UUID((string) requestData["web_login_key"]); + UUID webloginkey = new UUID((string)requestData["web_login_key"]); GoodLogin = AuthenticateUser(userProfile, webloginkey); } catch (Exception e) @@ -372,7 +365,7 @@ namespace OpenSim.Framework.Communications m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); startLocationRequest = map["start"].AsString(); } - m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname+"' '"+lastname+"' / "+passwd); + m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) { @@ -385,7 +378,7 @@ namespace OpenSim.Framework.Communications else return logResponse.CreateLoginFailedResponseLLSD(); - + if (userProfile.GodLevel < m_minLoginLevel) { return logResponse.CreateLoginBlockedResponseLLSD(); @@ -520,7 +513,7 @@ namespace OpenSim.Framework.Communications string firstname = String.Empty; string lastname = String.Empty; string location = String.Empty; - string region =String.Empty; + string region = String.Empty; string grid = String.Empty; string channel = String.Empty; string version = String.Empty; @@ -560,7 +553,7 @@ namespace OpenSim.Framework.Communications lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); if (keysvals.Contains("password")) - password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); + password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); // load our login form. string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); @@ -578,11 +571,11 @@ namespace OpenSim.Framework.Communications UUID webloginkey = UUID.Random(); m_userManager.StoreWebLoginKey(user.ID, webloginkey); //statuscode = 301; - -// string redirectURL = "about:blank?redirect-http-hack=" + -// HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + -// lastname + -// "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + + // string redirectURL = "about:blank?redirect-http-hack=" + + // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + // lastname + + // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); //m_log.Info("[WEB]: R:" + redirectURL); returnactions["int_response_code"] = statuscode; //returnactions["str_redirect_location"] = redirectURL; @@ -612,7 +605,7 @@ namespace OpenSim.Framework.Communications { // inject our values in the form at the markers - string loginform=String.Empty; + string loginform = String.Empty; string file = Path.Combine(Util.configDir(), "http_loginform.html"); if (!File.Exists(file)) { @@ -753,7 +746,7 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); // Match web login key unless it's the default weblogin key UUID.Zero - passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != UUID.Zero); + passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); return passwordSuccess; } @@ -801,7 +794,7 @@ namespace OpenSim.Framework.Communications LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); buddyitem.BuddyID = fl.Friend; buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; - buddyitem.BuddyRightsGiven = (int) fl.FriendPerms; + buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; buddylistreturn.AddNewBuddy(buddyitem); } return buddylistreturn; @@ -996,14 +989,6 @@ namespace OpenSim.Framework.Communications return false; } - // Customise the response - //response.Home = - // string.Format( - // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - // (SimInfo.regionLocX * Constants.RegionSize), - // (SimInfo.regionLocY*Constants.RegionSize), - // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); theUser.CurrentAgent.Position = new Vector3(128, 128, 0); response.StartLocation = "safe"; @@ -1041,5 +1026,68 @@ namespace OpenSim.Framework.Communications } response.ActiveGestures = list; } + + /// + /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. + /// + /// + /// + /// This will be thrown if there is a problem with the inventory service + protected InventoryData GetInventorySkeleton(UUID userID) + { + List folders = m_inventoryService.GetInventorySkeleton(userID); + + // If we have user auth but no inventory folders for some reason, create a new set of folders. + if (folders == null || folders.Count == 0) + { + m_log.InfoFormat( + "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); + + // Although the create user function creates a new agent inventory along with a new user profile, some + // tools are creating the user profile directly in the database without creating the inventory. At + // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already + // exist. + if (!m_inventoryService.CreateNewUserInventory(userID)) + { + throw new Exception( + String.Format( + "The inventory creation request for user {0} did not succeed." + + " Please contact your inventory service provider for more information.", + userID)); + } + + m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); + + folders = m_inventoryService.GetInventorySkeleton(userID); + + if (folders == null || folders.Count == 0) + { + throw new Exception( + String.Format( + "A root inventory folder for user {0} could not be retrieved from the inventory service", + userID)); + } + } + + UUID rootID = UUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.ParentID == UUID.Zero) + { + rootID = InvFolder.ID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.Name; + TempHash["parent_id"] = InvFolder.ParentID.ToString(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.Type; + TempHash["folder_id"] = InvFolder.ID.ToString(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, rootID); + } } } -- cgit v1.1 From 1121a214b9258487dae0d84dad1a0b495d2f80bd Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 21 Mar 2009 17:46:58 +0000 Subject: Add a QueryItem method to the inventory subsystem. Currently implemented for MySQL only, stubs for the others. This allows updating the cache with a single item from the database. --- .../Communications/Cache/CachedUserInfo.cs | 42 ++++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 8 +++++ .../Communications/InventoryServiceBase.cs | 14 ++++++++ 3 files changed, 64 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c5bbd6a..57c3ece 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void AddItemDelegate(InventoryItemBase itemInfo); internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); internal delegate void DeleteItemDelegate(UUID itemID); + internal delegate void QueryItemDelegate(UUID itemID); internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); @@ -767,6 +768,47 @@ namespace OpenSim.Framework.Communications.Cache return RootFolder.FindFolderForType(type); } + + // Load additional items that other regions have put into the database + // The item will be added tot he local cache. Returns true if the item + // was found and can be sent to the client + // + public bool QueryItem(UUID itemID) + { + if (m_hasReceivedInventory) + { + InventoryItemBase item = RootFolder.FindItem(itemID); + + if (item != null) + { + // Item is in local cache, just update client + // + return true; + } + + InventoryItemBase itemInfo = m_commsManager.InventoryService.QueryItem(item); + if (itemInfo != null) + { + InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); + ItemReceive(itemInfo, folder); + return true; + } + + return false; + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(QueryItemDelegate), this, "QueryItem"), + new object[] { itemID })); + + return true; + } + + return false; + } + } /// diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index aead3be..fc9d8af 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -105,6 +105,14 @@ namespace OpenSim.Framework.Communications bool DeleteItem(InventoryItemBase item); /// + /// Query the server for an item that may have been added by + /// another region + /// + /// + /// true if the item was found in local cache + InventoryItemBase QueryItem(InventoryItemBase item); + + /// /// Does the given user have an inventory structure? /// /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 8068080..cad7989 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -278,6 +278,20 @@ namespace OpenSim.Framework.Communications return true; } + public virtual InventoryItemBase QueryItem(InventoryItemBase item) + { + foreach (IInventoryDataPlugin plugin in m_plugins) + { + InventoryItemBase result = plugin.queryInventoryItem(item.ID); + if (result != null) + { + return result; + } + } + + return null; + } + /// /// Purge a folder of all items items and subfolders. /// -- cgit v1.1 From 09732b4d5dfdb3a9e326e99c2e86d7492bc06e55 Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 21 Mar 2009 20:16:35 +0000 Subject: Initial support for authentication/authorization keys in UserManagerBase, and use of it in HGStandaloneLoginService (producer of initial key for user, and of subsequent keys) and HGStandaloneInventoryService (consumer of a key). Keys are of the form http:/// and they are sent over http header "authorization". --- .../Framework/Communications/IAuthentication.cs | 13 ++++ .../Framework/Communications/UserManagerBase.cs | 83 +++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Framework/Communications/IAuthentication.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs new file mode 100644 index 0000000..5d6d5f2 --- /dev/null +++ b/OpenSim/Framework/Communications/IAuthentication.cs @@ -0,0 +1,13 @@ +using System; + +using OpenMetaverse; + + +namespace OpenSim.Framework.Communications +{ + public interface IAuthentication + { + string GetNewKey(string url, UUID userID, UUID authToken); + bool VerifyKey(UUID userID, string key); + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 62c3f89..c177d4f 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService + public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -750,5 +750,86 @@ namespace OpenSim.Framework.Communications } } } + + #region IAuthentication + + protected Dictionary> m_userKeys = new Dictionary>(); + + /// + /// This generates authorization keys in the form + /// http://userserver/uuid + /// after verifying that the caller is, indeed, authorized to request a key + /// + /// URL of the user server + /// The user ID requesting the new key + /// The original authorization token for that user, obtained during login + /// + public string GetNewKey(string url, UUID userID, UUID authToken) + { + UserProfileData profile = GetUserProfile(userID); + string newKey = string.Empty; + if (!url.EndsWith("/")) + url = url + "/"; + + if (profile != null) + { + // I'm overloading webloginkey for this, so that no changes are needed in the DB + // The uses of webloginkey are fairly mutually exclusive + if (profile.WebLoginKey.Equals(authToken)) + { + newKey = UUID.Random().ToString(); + List keys; + lock (m_userKeys) + { + if (m_userKeys.ContainsKey(userID)) + { + keys = m_userKeys[userID]; + } + else + { + keys = new List(); + m_userKeys.Add(userID, keys); + } + keys.Add(newKey); + } + m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID); + } + else + m_log.Info("[USERAUTH]: Unauthorized key generation request. Denying new key."); + } + else + m_log.Info("[USERAUTH]: User not found."); + + return url + newKey; + } + + /// + /// This verifies the uuid portion of the key given out by GenerateKey + /// + /// + /// + /// + public bool VerifyKey(UUID userID, string key) + { + lock (m_userKeys) + { + if (m_userKeys.ContainsKey(userID)) + { + List keys = m_userKeys[userID]; + if (keys.Contains(key)) + { + // Keys are one-time only, so remove it + keys.Remove(key); + return true; + } + return false; + } + else + return false; + } + } + + #endregion + } } -- cgit v1.1 From 9489ad57f98e13c61725fe157eacf2e56053abe6 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 22 Mar 2009 04:39:16 +0000 Subject: Moving the LoginAuth service up, so that it can be shared among standalones and the User Server. --- .../Framework/Communications/HGLoginAuthService.cs | 346 +++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 OpenSim/Framework/Communications/HGLoginAuthService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/HGLoginAuthService.cs b/OpenSim/Framework/Communications/HGLoginAuthService.cs new file mode 100644 index 0000000..d12b73b --- /dev/null +++ b/OpenSim/Framework/Communications/HGLoginAuthService.cs @@ -0,0 +1,346 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.Net; +using System.Reflection; +using System.Text.RegularExpressions; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; + +using OpenMetaverse; + +using log4net; +using Nini.Config; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Communications +{ + public class HGLoginAuthService : LoginService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected NetworkServersInfo m_serversInfo; + protected bool m_authUsers = false; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_interServiceInventoryService; + + /// + /// Used to make requests to the local regions. + /// + protected ILoginServiceToRegionsConnector m_regionsConnector; + + + public HGLoginAuthService( + UserManagerBase userManager, string welcomeMess, + IInterServiceInventoryServices interServiceInventoryService, + NetworkServersInfo serversInfo, + bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) + : base(userManager, libraryRootFolder, welcomeMess) + { + this.m_serversInfo = serversInfo; + m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; + m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; + m_authUsers = authenticate; + + m_interServiceInventoryService = interServiceInventoryService; + m_regionsConnector = regionsConnector; + m_inventoryService = interServiceInventoryService; + } + + public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); + XmlRpcResponse response = base.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + + responseData["grid_service"] = m_serversInfo.GridURL; + responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; + responseData["inventory_service"] = m_serversInfo.InventoryURL; + responseData["asset_service"] = m_serversInfo.AssetURL; + responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; + int x = (Int32)responseData["region_x"]; + int y = (Int32)responseData["region_y"]; + uint ux = (uint)(x / Constants.RegionSize); + uint uy = (uint)(y / Constants.RegionSize); + ulong regionHandle = Util.UIntsToLong(ux, uy); + responseData["region_handle"] = regionHandle.ToString(); + responseData["http_port"] = (UInt32)m_serversInfo.HttpListenerPort; + + // Let's remove the seed cap from the login + //responseData.Remove("seed_capability"); + + // Let's add the appearance + UUID userID = UUID.Zero; + UUID.TryParse((string)responseData["agent_id"], out userID); + AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); + if (appearance == null) + { + m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); + appearance = new AvatarAppearance(); + } + + responseData["appearance"] = appearance.ToHashTable(); + + // Let's also send the auth token + UUID token = UUID.Random(); + responseData["auth_token"] = token.ToString(); + UserProfileData userProfile = m_userManager.GetUserProfile(userID); + if (userProfile != null) + { + userProfile.WebLoginKey = token; + m_userManager.CommitAgent(ref userProfile); + } + + return response; + } + + public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) + { + + // Verify the key of who's calling + UUID userID = UUID.Zero; + UUID authKey = UUID.Zero; + UUID.TryParse((string)request.Params[0], out userID); + UUID.TryParse((string)request.Params[1], out authKey); + + m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); + string newKey = string.Empty; + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); + } + else + { + newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = (string) newKey; + return response; + } + + public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) + { + foreach (object o in request.Params) + { + if (o != null) + m_log.Debug(" >> Param " + o.ToString()); + else + m_log.Debug(" >> Null"); + } + + // Verify the key of who's calling + UUID userID = UUID.Zero; + string authKey = string.Empty; + UUID.TryParse((string)request.Params[0], out userID); + authKey = (string)request.Params[1]; + + m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); + bool success = false; + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); + } + else + { + success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = (string)success.ToString(); + return response; + } + + public override UserProfileData GetTheUser(string firstname, string lastname) + { + UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); + if (profile != null) + { + return profile; + } + + if (!m_authUsers) + { + //no current user account so make one + m_log.Info("[LOGIN]: No user account found so creating a new one."); + + m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); + + return m_userManager.GetUserProfile(firstname, lastname); + } + + return null; + } + + public override bool AuthenticateUser(UserProfileData profile, string password) + { + if (!m_authUsers) + { + //for now we will accept any password in sandbox mode + m_log.Info("[LOGIN]: Authorising user (no actual password check)"); + + return true; + } + else + { + m_log.Info( + "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); + + if (!password.StartsWith("$1$")) + password = "$1$" + Util.Md5Hash(password); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + + bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + return loginresult; + } + } + + protected override RegionInfo RequestClosestRegion(string region) + { + return m_regionsConnector.RequestClosestRegion(region); + } + + protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); + } + + protected override RegionInfo GetRegionInfo(UUID homeRegionId) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionId); + } + + + /// + /// Prepare a login to the given region. This involves both telling the region to expect a connection + /// and appropriately customising the response to the user. + /// + /// + /// + /// + /// true if the region was successfully contacted, false otherwise + protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) + { + IPEndPoint endPoint = regionInfo.ExternalEndPoint; + response.SimAddress = endPoint.Address.ToString(); + response.SimPort = (uint)endPoint.Port; + response.RegionX = regionInfo.RegionLocX; + response.RegionY = regionInfo.RegionLocY; + + string capsPath = CapsUtil.GetRandomCapsObjectPath(); + string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); + + // Don't use the following! It Fails for logging into any region not on the same port as the http server! + // Kept here so it doesn't happen again! + // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; + + string seedcap = "http://"; + + if (m_serversInfo.HttpUsesSSL) + { + seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + m_serversInfo.httpSSLPort + capsSeedPath; + } + else + { + seedcap = "http://" + regionInfo.ExternalHostName + ":" + m_serversInfo.HttpListenerPort + capsSeedPath; + } + + response.SeedCapability = seedcap; + + // Notify the target of an incoming user + m_log.InfoFormat( + "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", + regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); + + // Update agent with target sim + user.CurrentAgent.Region = regionInfo.RegionID; + user.CurrentAgent.Handle = regionInfo.RegionHandle; + + AgentCircuitData agent = new AgentCircuitData(); + agent.AgentID = user.ID; + agent.firstname = user.FirstName; + agent.lastname = user.SurName; + agent.SessionID = user.CurrentAgent.SessionID; + agent.SecureSessionID = user.CurrentAgent.SecureSessionID; + agent.circuitcode = Convert.ToUInt32(response.CircuitCode); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = user.CurrentAgent.Position; + agent.CapsPath = capsPath; + agent.Appearance = m_userManager.GetUserAppearance(user.ID); + if (agent.Appearance == null) + { + m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); + agent.Appearance = new AvatarAppearance(); + } + + if (m_regionsConnector.RegionLoginsEnabled) + { + // m_log.Info("[LLStandaloneLoginModule] Informing region about user"); + return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent); + } + + return false; + } + + public override void LogOffUser(UserProfileData theUser, string message) + { + RegionInfo SimInfo; + try + { + SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); + + if (SimInfo == null) + { + m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); + return; + } + } + catch (Exception) + { + m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); + return; + } + + m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); + } + } +} -- cgit v1.1 From 73a982babe7a976d024fea6a00a78321fefa8e5e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Mar 2009 15:19:43 +0000 Subject: Fox a null ref in the inventory give module --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 57c3ece..03569f6 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -786,6 +786,9 @@ namespace OpenSim.Framework.Communications.Cache return true; } + item = new InventoryItemBase(); + item.ID = itemID; + InventoryItemBase itemInfo = m_commsManager.InventoryService.QueryItem(item); if (itemInfo != null) { -- cgit v1.1 From e6bb86a22428c6ed9e3d97e5347835e5e5cff598 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Mar 2009 15:42:22 +0000 Subject: Add QueryItem method to secure inventory and HG inventory, change method sig to provide additional information the HG needs. --- .../Communications/Cache/CachedUserInfo.cs | 21 ++++++++++++++------- .../Communications/ISecureInventoryService.cs | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 03569f6..4ea1e22 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -773,23 +773,30 @@ namespace OpenSim.Framework.Communications.Cache // The item will be added tot he local cache. Returns true if the item // was found and can be sent to the client // - public bool QueryItem(UUID itemID) + public bool QueryItem(InventoryItemBase item) { if (m_hasReceivedInventory) { - InventoryItemBase item = RootFolder.FindItem(itemID); + InventoryItemBase invItem = RootFolder.FindItem(item.ID); - if (item != null) + if (invItem != null) { // Item is in local cache, just update client // return true; } - item = new InventoryItemBase(); - item.ID = itemID; + InventoryItemBase itemInfo = null; + + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.QueryItem(item, m_session_id); + } + else + { + m_commsManager.InventoryService.QueryItem(item); + } - InventoryItemBase itemInfo = m_commsManager.InventoryService.QueryItem(item); if (itemInfo != null) { InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); @@ -804,7 +811,7 @@ namespace OpenSim.Framework.Communications.Cache AddRequest( new InventoryRequest( Delegate.CreateDelegate(typeof(QueryItemDelegate), this, "QueryItem"), - new object[] { itemID })); + new object[] { item.ID })); return true; } diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index 6da13fe..d70dd0b 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -96,6 +96,8 @@ namespace OpenSim.Framework.Communications /// true if the item was successfully deleted bool DeleteItem(InventoryItemBase item, UUID session_id); + InventoryItemBase QueryItem(InventoryItemBase item, UUID session_id); + /// /// Does the given user have an inventory structure? /// -- cgit v1.1 From 48e87b644838ad0b59d6dfe7c3fddf4b96cf4971 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 22 Mar 2009 18:25:04 +0000 Subject: Make single item inventory gives work across regions --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 4ea1e22..e590b9d 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -790,11 +790,11 @@ namespace OpenSim.Framework.Communications.Cache if (m_commsManager.SecureInventoryService != null) { - m_commsManager.SecureInventoryService.QueryItem(item, m_session_id); + itemInfo = m_commsManager.SecureInventoryService.QueryItem(item, m_session_id); } else { - m_commsManager.InventoryService.QueryItem(item); + itemInfo = m_commsManager.InventoryService.QueryItem(item); } if (itemInfo != null) -- cgit v1.1 From 412112acbafa6e1f111b12007fd3a81728d0b2f5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 23 Mar 2009 00:11:34 +0000 Subject: Committing partial work on passing folders across instances. This may crash. --- .../Communications/Cache/CachedUserInfo.cs | 51 ++++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 8 ++++ .../Communications/ISecureInventoryService.cs | 2 + .../Communications/InventoryServiceBase.cs | 14 ++++++ 4 files changed, 75 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index e590b9d..8d36623 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -37,6 +37,7 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); internal delegate void DeleteItemDelegate(UUID itemID); internal delegate void QueryItemDelegate(UUID itemID); + internal delegate void QueryFolderDelegate(UUID folderID); internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); @@ -819,6 +820,56 @@ namespace OpenSim.Framework.Communications.Cache return false; } + public bool QueryFolder(InventoryFolderBase folder) + { + if (m_hasReceivedInventory) + { + InventoryFolderBase invFolder = RootFolder.FindFolder(folder.ID); + + if (invFolder != null) + { + // Folder is in local cache, just update client + // + return true; + } + + InventoryFolderBase folderInfo = null; + + if (m_commsManager.SecureInventoryService != null) + { + folderInfo = m_commsManager.SecureInventoryService.QueryFolder(folder, m_session_id); + } + else + { + folderInfo = m_commsManager.InventoryService.QueryFolder(folder); + } + + if (folderInfo != null) + { + InventoryFolderImpl createdFolder = RootFolder.CreateChildFolder(folderInfo.ID, folderInfo.Name, (ushort)folderInfo.Type); + + createdFolder.Version = folderInfo.Version; + createdFolder.Owner = folderInfo.Owner; + createdFolder.ParentID = folderInfo.ParentID; + + return true; + } + + return false; + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(QueryFolderDelegate), this, "QueryFolder"), + new object[] { folder.ID })); + + return true; + } + + return false; + } + } /// diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index fc9d8af..e37b188 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -113,6 +113,14 @@ namespace OpenSim.Framework.Communications InventoryItemBase QueryItem(InventoryItemBase item); /// + /// Query the server for a folder that may have been added by + /// another region + /// + /// + /// true if the folder was found in local cache + InventoryFolderBase QueryFolder(InventoryFolderBase folder); + + /// /// Does the given user have an inventory structure? /// /// diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index d70dd0b..a405ee5 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -98,6 +98,8 @@ namespace OpenSim.Framework.Communications InventoryItemBase QueryItem(InventoryItemBase item, UUID session_id); + InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id); + /// /// Does the given user have an inventory structure? /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index cad7989..ff66250 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -292,6 +292,20 @@ namespace OpenSim.Framework.Communications return null; } + public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) + { + foreach (IInventoryDataPlugin plugin in m_plugins) + { + InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); + if (result != null) + { + return result; + } + } + + return null; + } + /// /// Purge a folder of all items items and subfolders. /// -- cgit v1.1 From ec07baa8c007a0e60441d792521abfa45f92c229 Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 24 Mar 2009 02:28:17 +0000 Subject: Preparing the loginauth service for gridmode logins. --- OpenSim/Framework/Communications/HGLoginAuthService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/HGLoginAuthService.cs b/OpenSim/Framework/Communications/HGLoginAuthService.cs index d12b73b..21d34f8 100644 --- a/OpenSim/Framework/Communications/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/HGLoginAuthService.cs @@ -79,6 +79,11 @@ namespace OpenSim.Framework.Communications m_inventoryService = interServiceInventoryService; } + public void SetServersInfo(NetworkServersInfo sinfo) + { + m_serversInfo = sinfo; + } + public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); -- cgit v1.1 From b5f6aa6ff271ef3db95570f48bdf0e4a2b775e33 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 24 Mar 2009 08:21:50 +0000 Subject: From: Alan Webb Changes to AssetCache and DynamicTextureModule to eliminate opportunities for lost texture updates. --- .../Framework/Communications/Cache/AssetCache.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 7d06a1e..bd0b1b1 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications.Cache // If it's a direct request for a script, drop it // because it's a hacked client if (req.AssetRequestSource != 2 || assetInf.Type != 10) - AssetRequests.Add(req); + lock(AssetRequests) AssetRequests.Add(req); } } @@ -487,7 +487,7 @@ namespace OpenSim.Framework.Communications.Cache req.Params = transferRequest.TransferInfo.Params; req.AssetInf = new AssetInfo(asset); req.NumPackets = CalculateNumPackets(asset.Data); - AssetRequests.Add(req); + lock(AssetRequests) AssetRequests.Add(req); } /// @@ -506,16 +506,16 @@ namespace OpenSim.Framework.Communications.Cache int num = Math.Min(5, AssetRequests.Count); AssetRequest req; - AssetRequestToClient req2 = null; + AssetRequestToClient req2 = new AssetRequestToClient(); + for (int i = 0; i < num; i++) { - req = AssetRequests[i]; - if (req2 == null) + lock(AssetRequests) { - req2 = new AssetRequestToClient(); + req = AssetRequests[0]; + AssetRequests.RemoveAt(0); } - - // Trying to limit memory usage by only creating AssetRequestToClient if needed + req2.AssetInf = req.AssetInf; req2.AssetRequestSource = req.AssetRequestSource; req2.DataPointer = req.DataPointer; @@ -528,13 +528,9 @@ namespace OpenSim.Framework.Communications.Cache req2.RequestAssetID = req.RequestAssetID; req2.TransferRequestID = req.TransferRequestID; req.RequestUser.SendAsset(req2); - } - //remove requests that have been completed - for (int i = 0; i < num; i++) - { - AssetRequests.RemoveAt(0); } + } public class AssetRequest -- cgit v1.1 From c7d0e4ffc151818702375fdb786189fd1f8c7c94 Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 24 Mar 2009 18:56:32 +0000 Subject: Added the login region's http to the login response. --- .../Framework/Communications/HGLoginAuthService.cs | 42 ++++++---------------- OpenSim/Framework/Communications/LoginResponse.cs | 8 +++++ 2 files changed, 18 insertions(+), 32 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/HGLoginAuthService.cs b/OpenSim/Framework/Communications/HGLoginAuthService.cs index 21d34f8..49977b7 100644 --- a/OpenSim/Framework/Communications/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/HGLoginAuthService.cs @@ -70,8 +70,11 @@ namespace OpenSim.Framework.Communications : base(userManager, libraryRootFolder, welcomeMess) { this.m_serversInfo = serversInfo; - m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; - m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; + if (m_serversInfo != null) + { + m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; + m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; + } m_authUsers = authenticate; m_interServiceInventoryService = interServiceInventoryService; @@ -101,7 +104,6 @@ namespace OpenSim.Framework.Communications uint uy = (uint)(y / Constants.RegionSize); ulong regionHandle = Util.UIntsToLong(ux, uy); responseData["region_handle"] = regionHandle.ToString(); - responseData["http_port"] = (UInt32)m_serversInfo.HttpListenerPort; // Let's remove the seed cap from the login //responseData.Remove("seed_capability"); @@ -255,8 +257,7 @@ namespace OpenSim.Framework.Communications /// - /// Prepare a login to the given region. This involves both telling the region to expect a connection - /// and appropriately customising the response to the user. + /// Not really informing the region. Just filling out the response fields related to the region. /// /// /// @@ -269,6 +270,7 @@ namespace OpenSim.Framework.Communications response.SimPort = (uint)endPoint.Port; response.RegionX = regionInfo.RegionLocX; response.RegionY = regionInfo.RegionLocY; + response.SimHttpPort = regionInfo.HttpPort; string capsPath = CapsUtil.GetRandomCapsObjectPath(); string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); @@ -281,11 +283,11 @@ namespace OpenSim.Framework.Communications if (m_serversInfo.HttpUsesSSL) { - seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + m_serversInfo.httpSSLPort + capsSeedPath; + seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; } else { - seedcap = "http://" + regionInfo.ExternalHostName + ":" + m_serversInfo.HttpListenerPort + capsSeedPath; + seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; } response.SeedCapability = seedcap; @@ -299,31 +301,7 @@ namespace OpenSim.Framework.Communications user.CurrentAgent.Region = regionInfo.RegionID; user.CurrentAgent.Handle = regionInfo.RegionHandle; - AgentCircuitData agent = new AgentCircuitData(); - agent.AgentID = user.ID; - agent.firstname = user.FirstName; - agent.lastname = user.SurName; - agent.SessionID = user.CurrentAgent.SessionID; - agent.SecureSessionID = user.CurrentAgent.SecureSessionID; - agent.circuitcode = Convert.ToUInt32(response.CircuitCode); - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = user.CurrentAgent.Position; - agent.CapsPath = capsPath; - agent.Appearance = m_userManager.GetUserAppearance(user.ID); - if (agent.Appearance == null) - { - m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); - agent.Appearance = new AvatarAppearance(); - } - - if (m_regionsConnector.RegionLoginsEnabled) - { - // m_log.Info("[LLStandaloneLoginModule] Informing region about user"); - return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent); - } - - return false; + return true; } public override void LogOffUser(UserProfileData theUser, string message) diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index d1b9258..6986369 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -75,6 +75,7 @@ namespace OpenSim.Framework.Communications private string everLoggedIn; private string login; private uint simPort; + private uint simHttpPort; private string simAddress; private string agentAccess; private Int32 circuitCode; @@ -354,6 +355,7 @@ namespace OpenSim.Framework.Communications responseData["sim_port"] = (Int32) SimPort; responseData["sim_ip"] = SimAddress; + responseData["http_port"] = (Int32)SimHttpPort; responseData["agent_id"] = AgentID.ToString(); responseData["session_id"] = SessionID.ToString(); @@ -579,6 +581,12 @@ namespace OpenSim.Framework.Communications set { simPort = value; } } + public uint SimHttpPort + { + get { return simHttpPort; } + set { simHttpPort = value; } + } + public string SimAddress { get { return simAddress; } -- cgit v1.1 From 64341fc965cc92507498deb42516ab50eda619f2 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 24 Mar 2009 20:57:02 +0000 Subject: * minor: remove a couple more compiler warnings --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 8d36623..dbbcc49 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -816,8 +816,6 @@ namespace OpenSim.Framework.Communications.Cache return true; } - - return false; } public bool QueryFolder(InventoryFolderBase folder) @@ -866,8 +864,6 @@ namespace OpenSim.Framework.Communications.Cache return true; } - - return false; } } -- cgit v1.1 From 0bb3d2e6d75baa244da1906e0466448cf4acb3be Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 25 Mar 2009 07:36:56 +0000 Subject: cleanup --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index dbbcc49..32c235a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -865,7 +865,6 @@ namespace OpenSim.Framework.Communications.Cache return true; } } - } /// -- cgit v1.1 From 3ca1481c3da08f7da68ec9a1007587389e10d37f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 26 Mar 2009 06:56:10 +0000 Subject: * Minor fixes, inverted an if for readability and introduced a virtual pre-process step on the asset cache --- .../Framework/Communications/Cache/AssetCache.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index bd0b1b1..d79645e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -333,6 +333,9 @@ namespace OpenSim.Framework.Communications.Cache public virtual void AssetReceived(AssetBase asset, bool IsTexture) { AssetInfo assetInf = new AssetInfo(asset); + + ProcessRecievedAsset(IsTexture, assetInf); + if (!m_memcache.Contains(assetInf.FullID)) { m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); @@ -347,10 +350,19 @@ namespace OpenSim.Framework.Communications.Cache req.NumPackets = CalculateNumPackets(assetInf.Data); RequestedAssets.Remove(assetInf.FullID); - // If it's a direct request for a script, drop it - // because it's a hacked client - if (req.AssetRequestSource != 2 || assetInf.Type != 10) - lock(AssetRequests) AssetRequests.Add(req); + + if (req.AssetRequestSource == 2 && assetInf.Type == 10) + { + // If it's a direct request for a script, drop it + // because it's a hacked client + } + else + { + lock (AssetRequests) + { + AssetRequests.Add(req); + } + } } } @@ -377,6 +389,10 @@ namespace OpenSim.Framework.Communications.Cache } } + protected void ProcessRecievedAsset(bool IsTexture, AssetInfo assetInf) + { + } + // See IAssetReceiver public virtual void AssetNotFound(UUID assetID, bool IsTexture) { -- cgit v1.1 From 28d9a735214975aca52df0ddd2e2def96526c6b3 Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 26 Mar 2009 16:05:00 +0000 Subject: Small refactoring in Caps, no functional changes. --- .../Framework/Communications/Capabilities/Caps.cs | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index fde44be..8a4d145 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -153,6 +153,13 @@ namespace OpenSim.Framework.Communications.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; + RegisterRegionServiceHandlers(capsBase); + RegisterInventoryServiceHandlers(capsBase); + + } + + public void RegisterRegionServiceHandlers(string capsBase) + { try { // the root of all evil @@ -164,6 +171,22 @@ namespace OpenSim.Framework.Communications.Capabilities // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, // GetMapLayer); + m_capsHandlers["UpdateScriptTaskInventory"] = + new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); + m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; + + } + catch (Exception e) + { + m_log.Error("[CAPS]: " + e.ToString()); + } + } + + public void RegisterInventoryServiceHandlers(string capsBase) + { + try + { + // I don't think this one works... m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler("POST", capsBase + m_newInventory, @@ -171,10 +194,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateNotecardAgentInventory"] = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; - m_capsHandlers["UpdateScriptTaskInventory"] = - new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; - m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires @@ -186,8 +206,8 @@ namespace OpenSim.Framework.Communications.Capabilities // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid // we will be // able to get the data we need to implement the necessary part of the protocol to fix the issue above. -// m_capsHandlers["FetchInventoryDescendents"] = -// new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); + // m_capsHandlers["FetchInventoryDescendents"] = + // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); // m_capsHandlers["FetchInventoryDescendents"] = // new LLSDStreamhandler("POST", -- cgit v1.1 From a423b3060b0149d5e5725307bf5edb7be88b238d Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 26 Mar 2009 22:17:57 +0000 Subject: Notecard updates bypassing the regions. (HGStandalone only) --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 8a4d145..db58975 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -112,6 +112,10 @@ namespace OpenSim.Framework.Communications.Capabilities { get { return m_httpListener.SSLCommonName; } } + public CapsHandlers CapsHandlers + { + get { return m_capsHandlers; } + } // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls @@ -626,7 +630,9 @@ namespace OpenSim.Framework.Communications.Capabilities public string NoteCardAgentInventory(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName); + m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); + m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); + //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); -- cgit v1.1 From f2b8691c9c1fbc79663c8a451314d31cd410555b Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 26 Mar 2009 22:21:39 +0000 Subject: Forgot to comment an unnecessary log message on my last commit. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index db58975..94614a1 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -630,8 +630,8 @@ namespace OpenSim.Framework.Communications.Capabilities public string NoteCardAgentInventory(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); - m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); + //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); + //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); -- cgit v1.1 From 08732b65be3ce13e8dd965a4542991a766dbd920 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 29 Mar 2009 20:29:13 +0000 Subject: Moved some files around, so that it's easier to share code between standalone and the grid services. Should not affect any functionality. --- .../Framework/Communications/HGLoginAuthService.cs | 329 ----------- .../Communications/Services/HGInventoryService.cs | 636 +++++++++++++++++++++ .../Communications/Services/HGLoginAuthService.cs | 329 +++++++++++ 3 files changed, 965 insertions(+), 329 deletions(-) delete mode 100644 OpenSim/Framework/Communications/HGLoginAuthService.cs create mode 100644 OpenSim/Framework/Communications/Services/HGInventoryService.cs create mode 100644 OpenSim/Framework/Communications/Services/HGLoginAuthService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/HGLoginAuthService.cs b/OpenSim/Framework/Communications/HGLoginAuthService.cs deleted file mode 100644 index 49977b7..0000000 --- a/OpenSim/Framework/Communications/HGLoginAuthService.cs +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; - -using OpenMetaverse; - -using log4net; -using Nini.Config; -using Nwc.XmlRpc; - -namespace OpenSim.Framework.Communications -{ - public class HGLoginAuthService : LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected NetworkServersInfo m_serversInfo; - protected bool m_authUsers = false; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_interServiceInventoryService; - - /// - /// Used to make requests to the local regions. - /// - protected ILoginServiceToRegionsConnector m_regionsConnector; - - - public HGLoginAuthService( - UserManagerBase userManager, string welcomeMess, - IInterServiceInventoryServices interServiceInventoryService, - NetworkServersInfo serversInfo, - bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) - : base(userManager, libraryRootFolder, welcomeMess) - { - this.m_serversInfo = serversInfo; - if (m_serversInfo != null) - { - m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; - m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; - } - m_authUsers = authenticate; - - m_interServiceInventoryService = interServiceInventoryService; - m_regionsConnector = regionsConnector; - m_inventoryService = interServiceInventoryService; - } - - public void SetServersInfo(NetworkServersInfo sinfo) - { - m_serversInfo = sinfo; - } - - public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); - XmlRpcResponse response = base.XmlRpcLoginMethod(request); - Hashtable responseData = (Hashtable)response.Value; - - responseData["grid_service"] = m_serversInfo.GridURL; - responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; - responseData["inventory_service"] = m_serversInfo.InventoryURL; - responseData["asset_service"] = m_serversInfo.AssetURL; - responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; - int x = (Int32)responseData["region_x"]; - int y = (Int32)responseData["region_y"]; - uint ux = (uint)(x / Constants.RegionSize); - uint uy = (uint)(y / Constants.RegionSize); - ulong regionHandle = Util.UIntsToLong(ux, uy); - responseData["region_handle"] = regionHandle.ToString(); - - // Let's remove the seed cap from the login - //responseData.Remove("seed_capability"); - - // Let's add the appearance - UUID userID = UUID.Zero; - UUID.TryParse((string)responseData["agent_id"], out userID); - AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); - if (appearance == null) - { - m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); - appearance = new AvatarAppearance(); - } - - responseData["appearance"] = appearance.ToHashTable(); - - // Let's also send the auth token - UUID token = UUID.Random(); - responseData["auth_token"] = token.ToString(); - UserProfileData userProfile = m_userManager.GetUserProfile(userID); - if (userProfile != null) - { - userProfile.WebLoginKey = token; - m_userManager.CommitAgent(ref userProfile); - } - - return response; - } - - public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) - { - - // Verify the key of who's calling - UUID userID = UUID.Zero; - UUID authKey = UUID.Zero; - UUID.TryParse((string)request.Params[0], out userID); - UUID.TryParse((string)request.Params[1], out authKey); - - m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); - string newKey = string.Empty; - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); - } - else - { - newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = (string) newKey; - return response; - } - - public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) - { - foreach (object o in request.Params) - { - if (o != null) - m_log.Debug(" >> Param " + o.ToString()); - else - m_log.Debug(" >> Null"); - } - - // Verify the key of who's calling - UUID userID = UUID.Zero; - string authKey = string.Empty; - UUID.TryParse((string)request.Params[0], out userID); - authKey = (string)request.Params[1]; - - m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); - bool success = false; - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); - } - else - { - success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = (string)success.ToString(); - return response; - } - - public override UserProfileData GetTheUser(string firstname, string lastname) - { - UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); - if (profile != null) - { - return profile; - } - - if (!m_authUsers) - { - //no current user account so make one - m_log.Info("[LOGIN]: No user account found so creating a new one."); - - m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); - - return m_userManager.GetUserProfile(firstname, lastname); - } - - return null; - } - - public override bool AuthenticateUser(UserProfileData profile, string password) - { - if (!m_authUsers) - { - //for now we will accept any password in sandbox mode - m_log.Info("[LOGIN]: Authorising user (no actual password check)"); - - return true; - } - else - { - m_log.Info( - "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); - - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - - bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); - return loginresult; - } - } - - protected override RegionInfo RequestClosestRegion(string region) - { - return m_regionsConnector.RequestClosestRegion(region); - } - - protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); - } - - protected override RegionInfo GetRegionInfo(UUID homeRegionId) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionId); - } - - - /// - /// Not really informing the region. Just filling out the response fields related to the region. - /// - /// - /// - /// - /// true if the region was successfully contacted, false otherwise - protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) - { - IPEndPoint endPoint = regionInfo.ExternalEndPoint; - response.SimAddress = endPoint.Address.ToString(); - response.SimPort = (uint)endPoint.Port; - response.RegionX = regionInfo.RegionLocX; - response.RegionY = regionInfo.RegionLocY; - response.SimHttpPort = regionInfo.HttpPort; - - string capsPath = CapsUtil.GetRandomCapsObjectPath(); - string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); - - // Don't use the following! It Fails for logging into any region not on the same port as the http server! - // Kept here so it doesn't happen again! - // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; - - string seedcap = "http://"; - - if (m_serversInfo.HttpUsesSSL) - { - seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; - } - else - { - seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; - } - - response.SeedCapability = seedcap; - - // Notify the target of an incoming user - m_log.InfoFormat( - "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", - regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); - - // Update agent with target sim - user.CurrentAgent.Region = regionInfo.RegionID; - user.CurrentAgent.Handle = regionInfo.RegionHandle; - - return true; - } - - public override void LogOffUser(UserProfileData theUser, string message) - { - RegionInfo SimInfo; - try - { - SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); - - if (SimInfo == null) - { - m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); - return; - } - } - catch (Exception) - { - m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); - return; - } - - m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); - } - } -} diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs new file mode 100644 index 0000000..f0b2259 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -0,0 +1,636 @@ +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * 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 Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +//using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; +using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.Interfaces; + +using OpenMetaverse.StructuredData; + +namespace OpenSim.Framework.Communications.Services +{ + public class HGInventoryService + { + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private InventoryServiceBase m_inventoryService; + private UserManagerBase m_userService; + IAssetDataPlugin m_assetProvider; + IHttpServer httpServer; + private string m_thisInventoryUrl = "http://localhost:9000"; + private string m_thisHostname = "127.0.0.1"; + private uint m_thisPort = 9000; + + + public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string url) + { + m_inventoryService = invService; + m_userService = userService; + m_thisInventoryUrl = url; + if (!m_thisInventoryUrl.EndsWith("/")) + m_thisInventoryUrl += "/"; + + Uri uri = new Uri(m_thisInventoryUrl); + if (uri != null) + { + m_thisHostname = uri.Host; + m_thisPort = (uint)uri.Port; + } + + m_assetProvider = assetService; + httpServer = httpserver; + + AddHttpHandlers(); + } + + public virtual void AddHttpHandlers() + { + httpServer.AddHTTPHandler("/InvCap/", CapHandler); + } + + public bool CheckAuthSession(string session_id, string avatar_id) + { + return true; + } + + + // In truth, this is not called from the outside, for standalones. I'm just making it + // a handler already so that this can be reused for the InventoryServer. + public string CreateCapUrl(Guid _userid) + { + UUID userID = new UUID(_userid); + UUID random = UUID.Random(); + string url = m_thisInventoryUrl + random.ToString() + "/"; + m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); + return url; + } + + /// + /// Return a user's entire inventory + /// + /// + /// The user's inventory. If an inventory cannot be found then an empty collection is returned. + public InventoryCollection GetUserInventory(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List allFolders = m_inventoryService.GetInventorySkeleton(userID); + + if (null == allFolders) + { + m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); + + return invCollection; + } + + List allItems = new List(); + + foreach (InventoryFolderBase folder in allFolders) + { + List items = m_inventoryService.RequestFolderItems(folder.ID); + + if (items != null) + { + allItems.InsertRange(0, items); + } + } + + invCollection.UserID = userID; + invCollection.Folders = allFolders; + invCollection.Items = allItems; + + // foreach (InventoryFolderBase folder in invCollection.Folders) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); + // } + // + // foreach (InventoryItemBase item in invCollection.Items) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); + // } + + m_log.InfoFormat( + "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", + invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); + + return invCollection; + } + + public InventoryCollection FetchDescendants(InventoryFolderBase fb) + { + m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List items = m_inventoryService.RequestFolderItems(fb.ID); + List folders = m_inventoryService.RequestSubFolders(fb.ID); + + invCollection.UserID = fb.Owner; + invCollection.Folders = folders; + invCollection.Items = items; + + m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); + + return invCollection; + } + + public bool RemoveFolder(InventoryFolderBase folder) + { + m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); + return false; + } + + public InventoryItemBase GetInventoryItem(InventoryItemBase item) + { + m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); + + item = m_inventoryService.GetInventoryItem(item.ID); + if (item == null) + m_log.Debug("[HGStandaloneInvService]: null item"); + return item; + } + + public InventoryItemBase AddItem(InventoryItemBase item) + { + m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); + if (m_inventoryService.AddItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase UpdateItem(InventoryItemBase item) + { + m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); + InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); + item.CurrentPermissions = it.CurrentPermissions; + item.AssetID = it.AssetID; + if (m_inventoryService.UpdateItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase MoveItem(InventoryItemBase newitem) + { + m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); + InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); + if (Item != null) + { + if (newitem.Name != String.Empty) + { + Item.Name = newitem.Name; + } + Item.Folder = newitem.Folder; + m_inventoryService.UpdateItem(Item); + return Item; + } + else + { + m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); + newitem.ID = UUID.Zero; + return newitem; + } + + } + + public InventoryItemBase DeleteItem(InventoryItemBase item) + { + item = m_inventoryService.GetInventoryItem(item.ID); + if (m_inventoryService.DeleteItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase CopyItem(InventoryItemBase olditem) + { + m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); + InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id + // BIG HACK here + UUID newID = olditem.AssetID; + if (Item != null) + { + if (olditem.Name != String.Empty) + { + Item.Name = olditem.Name; + } + Item.ID = newID; + Item.Folder = olditem.Folder; + Item.Owner = olditem.Owner; + // There should be some tests here about the owner, etc but I'm going to ignore that + // because I'm not sure it makes any sense + // Also I should probably close the asset... + m_inventoryService.AddItem(Item); + return Item; + } + else + { + m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); + olditem.ID = UUID.Zero; + return olditem; + } + + } + + /// + /// Guid to UUID wrapper for same name IInventoryServices method + /// + /// + /// + public List GetInventorySkeleton(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); + } + + public List GetActiveGestures(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); + + return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); + } + + public AssetBase GetAsset(InventoryItemBase item) + { + m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); + AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data + InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); + if (item2 == null) + { + m_log.Debug("[HGStandaloneInvService]: null item"); + return asset; + } + if (item2.Owner != item.Owner) + { + m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); + return asset; + } + + // All good, get the asset + AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); + m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null)? "NULL" : "Not Null")); + if (theasset != null) + { + asset = theasset; + //m_log.Debug(" >> Sending assetID " + item.AssetID); + } + return asset; + } + + public bool PostAsset(AssetBase asset) + { + m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); + m_assetProvider.CreateAsset(asset); + + return true; + } + + /// + /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) + /// + public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) + { + m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); + InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); + + if (item != null) + { + // We're still not dealing with permissions + //if ((InventoryType)item.InvType == InventoryType.Notecard) + //{ + // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) + // { + // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); + // return UUID.Zero; + // } + + // //remoteClient.SendAgentAlertMessage("Notecard saved", false); + //} + //else if ((InventoryType)item.InvType == InventoryType.LSL) + //{ + // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) + // { + // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); + // return UUID.Zero; + // } + + // //remoteClient.SendAgentAlertMessage("Script saved", false); + //} + + AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); + PostAsset(asset); + + item.AssetID = asset.FullID; + item.Owner = userID; + m_inventoryService.UpdateItem(item); + + return (asset.FullID); + } + return UUID.Zero; + } + + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) + { + AssetBase asset = new AssetBase(); + asset.Name = name; + asset.Description = description; + asset.Type = assetType; + asset.FullID = UUID.Random(); + asset.Data = (data == null) ? new byte[1] : data; + + return asset; + } + + #region Caps + + Dictionary invCaps = new Dictionary(); + + public Hashtable CapHandler(Hashtable request) + { + m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); + + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); + + // these are requests if the type + // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ + + Hashtable responsedata = new Hashtable(); + responsedata["content_type"] = "text/plain"; + + UUID userID; + string authToken = string.Empty; + string authority = string.Empty; + if (!GetParams(request, out userID, out authority, out authToken)) + { + m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); + responsedata["int_response_code"] = 404; + responsedata["str_response_string"] = "Not found"; + + return responsedata; + } + + // Next, let's parse the verb + string method = (string)request["http-method"]; + if (method.Equals("GET")) + { + DoInvCapPost(request, responsedata, userID, authToken); + return responsedata; + } + //else if (method.Equals("DELETE")) + //{ + // DoAgentDelete(request, responsedata, agentID, action, regionHandle); + + // return responsedata; + //} + else + { + m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); + responsedata["int_response_code"] = 405; + responsedata["str_response_string"] = "Method not allowed"; + + return responsedata; + } + + } + + public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authToken) + { + + // This is the meaning of POST agent + + // Check Auth Token + if (!(m_userService is IAuthentication)) + { + m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); + responsedata["int_response_code"] = 501; + responsedata["str_response_string"] = "Not implemented"; + return; + } + + bool success = ((IAuthentication)m_userService).VerifyKey(userID, authToken); + + if (success) + { + + m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); + + // Then establish secret service handlers + + Hashtable usercaps = RegisterCaps(userID, authToken); + + responsedata["int_response_code"] = 200; + //responsedata["str_response_string"] = "OK"; + responsedata["str_response_string"] = SerializeHashtable(usercaps); + } + else + { + m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); + responsedata["int_response_code"] = 403; + responsedata["str_response_string"] = "Forbidden"; + } + } + + + /// + /// Extract the params from a request. + /// + public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) + { + uuid = UUID.Zero; + authority = string.Empty; + authKey = string.Empty; + + string uri = (string)request["uri"]; + uri = uri.Trim(new char[] { '/' }); + string[] parts = uri.Split('/'); + if (parts.Length <= 1) + { + return false; + } + else + { + if (!UUID.TryParse(parts[1], out uuid)) + return false; + + if (parts.Length >= 3) + { + authKey = parts[2]; + return true; + } + } + + Uri authUri; + Hashtable headers = (Hashtable)request["headers"]; + + // Authorization keys look like this: + // http://orgrid.org:8002/ + if (headers.ContainsKey("authorization")) + { + if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) + { + authority = authUri.Authority; + authKey = authUri.PathAndQuery.Trim('/'); + m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); + return true; + } + else + m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); + } + else + m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); + + return false; + } + + string SerializeHashtable(Hashtable hash) + { + string result = string.Empty; + foreach (object key in hash.Keys) + { + result += key.ToString() + "," + hash[key].ToString() + ";"; + } + return result; + } + + Hashtable RegisterCaps(UUID userID, string authToken) + { + lock (invCaps) + { + if (invCaps.ContainsKey(userID)) + { + // Remove the old ones + DeregisterCaps(httpServer, invCaps[userID]); + invCaps.Remove(userID); + } + } + + Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); + caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); + caps.ItemUpdatedCall = UpdateInventoryItemAsset; + Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); + + lock (invCaps) + invCaps.Add(userID, capsHandlers); + + return capsHandlers; + } + + string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) + { + string capUrl = "/" + authToken + "/" + capType + "/"; + + m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); + caps.Add(capType, capUrl); + return capUrl; + } + + void DeregisterCaps(IHttpServer httpServer, Hashtable caps) + { + foreach (string capUrl in caps.Values) + { + m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); + httpServer.RemoveStreamHandler("POST", capUrl); + } + } + + #endregion Caps + } +} diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs new file mode 100644 index 0000000..37c8846 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -0,0 +1,329 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.Net; +using System.Reflection; +using System.Text.RegularExpressions; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; + +using OpenMetaverse; + +using log4net; +using Nini.Config; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Communications.Services +{ + public class HGLoginAuthService : LoginService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected NetworkServersInfo m_serversInfo; + protected bool m_authUsers = false; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_interServiceInventoryService; + + /// + /// Used to make requests to the local regions. + /// + protected ILoginServiceToRegionsConnector m_regionsConnector; + + + public HGLoginAuthService( + UserManagerBase userManager, string welcomeMess, + IInterServiceInventoryServices interServiceInventoryService, + NetworkServersInfo serversInfo, + bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) + : base(userManager, libraryRootFolder, welcomeMess) + { + this.m_serversInfo = serversInfo; + if (m_serversInfo != null) + { + m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; + m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; + } + m_authUsers = authenticate; + + m_interServiceInventoryService = interServiceInventoryService; + m_regionsConnector = regionsConnector; + m_inventoryService = interServiceInventoryService; + } + + public void SetServersInfo(NetworkServersInfo sinfo) + { + m_serversInfo = sinfo; + } + + public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); + XmlRpcResponse response = base.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + + responseData["grid_service"] = m_serversInfo.GridURL; + responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; + responseData["inventory_service"] = m_serversInfo.InventoryURL; + responseData["asset_service"] = m_serversInfo.AssetURL; + responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; + int x = (Int32)responseData["region_x"]; + int y = (Int32)responseData["region_y"]; + uint ux = (uint)(x / Constants.RegionSize); + uint uy = (uint)(y / Constants.RegionSize); + ulong regionHandle = Util.UIntsToLong(ux, uy); + responseData["region_handle"] = regionHandle.ToString(); + + // Let's remove the seed cap from the login + //responseData.Remove("seed_capability"); + + // Let's add the appearance + UUID userID = UUID.Zero; + UUID.TryParse((string)responseData["agent_id"], out userID); + AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); + if (appearance == null) + { + m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); + appearance = new AvatarAppearance(); + } + + responseData["appearance"] = appearance.ToHashTable(); + + // Let's also send the auth token + UUID token = UUID.Random(); + responseData["auth_token"] = token.ToString(); + UserProfileData userProfile = m_userManager.GetUserProfile(userID); + if (userProfile != null) + { + userProfile.WebLoginKey = token; + m_userManager.CommitAgent(ref userProfile); + } + + return response; + } + + public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) + { + + // Verify the key of who's calling + UUID userID = UUID.Zero; + UUID authKey = UUID.Zero; + UUID.TryParse((string)request.Params[0], out userID); + UUID.TryParse((string)request.Params[1], out authKey); + + m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); + string newKey = string.Empty; + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); + } + else + { + newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = (string) newKey; + return response; + } + + public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) + { + foreach (object o in request.Params) + { + if (o != null) + m_log.Debug(" >> Param " + o.ToString()); + else + m_log.Debug(" >> Null"); + } + + // Verify the key of who's calling + UUID userID = UUID.Zero; + string authKey = string.Empty; + UUID.TryParse((string)request.Params[0], out userID); + authKey = (string)request.Params[1]; + + m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); + bool success = false; + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); + } + else + { + success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = (string)success.ToString(); + return response; + } + + public override UserProfileData GetTheUser(string firstname, string lastname) + { + UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); + if (profile != null) + { + return profile; + } + + if (!m_authUsers) + { + //no current user account so make one + m_log.Info("[LOGIN]: No user account found so creating a new one."); + + m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); + + return m_userManager.GetUserProfile(firstname, lastname); + } + + return null; + } + + public override bool AuthenticateUser(UserProfileData profile, string password) + { + if (!m_authUsers) + { + //for now we will accept any password in sandbox mode + m_log.Info("[LOGIN]: Authorising user (no actual password check)"); + + return true; + } + else + { + m_log.Info( + "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); + + if (!password.StartsWith("$1$")) + password = "$1$" + Util.Md5Hash(password); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + + bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + return loginresult; + } + } + + protected override RegionInfo RequestClosestRegion(string region) + { + return m_regionsConnector.RequestClosestRegion(region); + } + + protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); + } + + protected override RegionInfo GetRegionInfo(UUID homeRegionId) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionId); + } + + + /// + /// Not really informing the region. Just filling out the response fields related to the region. + /// + /// + /// + /// + /// true if the region was successfully contacted, false otherwise + protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) + { + IPEndPoint endPoint = regionInfo.ExternalEndPoint; + response.SimAddress = endPoint.Address.ToString(); + response.SimPort = (uint)endPoint.Port; + response.RegionX = regionInfo.RegionLocX; + response.RegionY = regionInfo.RegionLocY; + response.SimHttpPort = regionInfo.HttpPort; + + string capsPath = CapsUtil.GetRandomCapsObjectPath(); + string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); + + // Don't use the following! It Fails for logging into any region not on the same port as the http server! + // Kept here so it doesn't happen again! + // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; + + string seedcap = "http://"; + + if (m_serversInfo.HttpUsesSSL) + { + seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; + } + else + { + seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; + } + + response.SeedCapability = seedcap; + + // Notify the target of an incoming user + m_log.InfoFormat( + "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", + regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); + + // Update agent with target sim + user.CurrentAgent.Region = regionInfo.RegionID; + user.CurrentAgent.Handle = regionInfo.RegionHandle; + + return true; + } + + public override void LogOffUser(UserProfileData theUser, string message) + { + RegionInfo SimInfo; + try + { + SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); + + if (SimInfo == null) + { + m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); + return; + } + } + catch (Exception) + { + m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); + return; + } + + m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); + } + } +} -- cgit v1.1 From f7eac63e01d957bd9c115ac0f55d1dd6109f6aea Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 29 Mar 2009 22:04:45 +0000 Subject: Another bit of refactoring to try to make sense of OpenSim.Framework.Communications. Everything that looks like a service, with service handlers, moved to .Services -- i.e. LoginService and Response, and GridInfoService. The rest of the changes were to adapt to the new locations of those files. --- .../Framework/Communications/GridInfoService.cs | 172 --- OpenSim/Framework/Communications/LoginResponse.cs | 812 --------------- OpenSim/Framework/Communications/LoginService.cs | 1093 -------------------- .../Communications/Services/GridInfoService.cs | 172 +++ .../Communications/Services/HGInventoryService.cs | 33 +- .../Communications/Services/LoginResponse.cs | 812 +++++++++++++++ .../Communications/Services/LoginService.cs | 1093 ++++++++++++++++++++ .../Communications/Tests/LoginServiceTests.cs | 1 + 8 files changed, 2105 insertions(+), 2083 deletions(-) delete mode 100644 OpenSim/Framework/Communications/GridInfoService.cs delete mode 100644 OpenSim/Framework/Communications/LoginResponse.cs delete mode 100644 OpenSim/Framework/Communications/LoginService.cs create mode 100644 OpenSim/Framework/Communications/Services/GridInfoService.cs create mode 100644 OpenSim/Framework/Communications/Services/LoginResponse.cs create mode 100644 OpenSim/Framework/Communications/Services/LoginService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GridInfoService.cs b/OpenSim/Framework/Communications/GridInfoService.cs deleted file mode 100644 index 4ad447d..0000000 --- a/OpenSim/Framework/Communications/GridInfoService.cs +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.IO; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers; - -namespace OpenSim.Framework.Communications -{ - public class GridInfoService - { - private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable _info = new Hashtable(); - - /// - /// Instantiate a GridInfoService object. - /// - /// path to config path containing - /// grid information - /// - /// GridInfoService uses the [GridInfo] section of the - /// standard OpenSim.ini file --- which is not optimal, but - /// anything else requires a general redesign of the config - /// system. - /// - public GridInfoService(IConfigSource configSource) - { - loadGridInfo(configSource); - } - - /// - /// Default constructor, uses OpenSim.ini. - /// - public GridInfoService() - { - try - { - IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); - loadGridInfo(configSource); - } - catch (FileNotFoundException) - { - _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); - } - } - - private void loadGridInfo(IConfigSource configSource) - { - _info["platform"] = "OpenSim"; - try - { - IConfig startupCfg = configSource.Configs["Startup"]; - IConfig gridCfg = configSource.Configs["GridInfo"]; - IConfig netCfg = configSource.Configs["Network"]; - - bool grid = startupCfg.GetBoolean("gridmode", false); - - if (grid) - _info["mode"] = "grid"; - else - _info["mode"] = "standalone"; - - - if (null != gridCfg) - { - foreach (string k in gridCfg.GetKeys()) - { - _info[k] = gridCfg.GetString(k); - } - } - else if (null != netCfg) - { - if (grid) - _info["login"] - = netCfg.GetString( - "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); - else - _info["login"] - = String.Format( - "http://127.0.0.1:{0}/", - netCfg.GetString( - "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); - - IssueWarning(); - } - else - { - _info["login"] = "http://127.0.0.1:9000/"; - IssueWarning(); - } - } - catch (Exception) - { - _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); - } - _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); - - } - - private void IssueWarning() - { - _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); - _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); - foreach (string k in _info.Keys) - { - _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); - } - } - - public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - - _log.Info("[GridInfo]: Request for grid info"); - - foreach (string k in _info.Keys) - { - responseData[k] = _info[k]; - } - response.Value = responseData; - - return response; - } - - public string RestGetGridInfoMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - StringBuilder sb = new StringBuilder(); - - sb.Append("\n"); - foreach (string k in _info.Keys) - { - sb.AppendFormat("<{0}>{1}\n", k, _info[k]); - } - sb.Append("\n"); - - return sb.ToString(); - } - } -} diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs deleted file mode 100644 index 6986369..0000000 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ /dev/null @@ -1,812 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -namespace OpenSim.Framework.Communications -{ - /// - /// A temp class to handle login response. - /// Should make use of UserProfileManager where possible. - /// - public class LoginResponse - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable loginFlagsHash; - private Hashtable globalTexturesHash; - private Hashtable loginError; - private Hashtable uiConfigHash; - - private ArrayList loginFlags; - private ArrayList globalTextures; - private ArrayList eventCategories; - private ArrayList uiConfig; - private ArrayList classifiedCategories; - private ArrayList inventoryRoot; - private ArrayList initialOutfit; - private ArrayList agentInventory; - private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibRoot; - private ArrayList inventoryLibrary; - private ArrayList activeGestures; - - private UserInfo userProfile; - - private UUID agentID; - private UUID sessionID; - private UUID secureSessionID; - - // Login Flags - private string dst; - private string stipendSinceLogin; - private string gendered; - private string everLoggedIn; - private string login; - private uint simPort; - private uint simHttpPort; - private string simAddress; - private string agentAccess; - private Int32 circuitCode; - private uint regionX; - private uint regionY; - - // Login - private string firstname; - private string lastname; - - // Global Textures - private string sunTexture; - private string cloudTexture; - private string moonTexture; - - // Error Flags - private string errorReason; - private string errorMessage; - - // Response - private XmlRpcResponse xmlRpcResponse; - // private XmlRpcResponse defaultXmlRpcResponse; - - private string welcomeMessage; - private string startLocation; - private string allowFirstLife; - private string home; - private string seedCapability; - private string lookAt; - - private BuddyList m_buddyList = null; - - public LoginResponse() - { - loginFlags = new ArrayList(); - globalTextures = new ArrayList(); - eventCategories = new ArrayList(); - uiConfig = new ArrayList(); - classifiedCategories = new ArrayList(); - - loginError = new Hashtable(); - uiConfigHash = new Hashtable(); - - // defaultXmlRpcResponse = new XmlRpcResponse(); - userProfile = new UserInfo(); - inventoryRoot = new ArrayList(); - initialOutfit = new ArrayList(); - agentInventory = new ArrayList(); - inventoryLibrary = new ArrayList(); - inventoryLibraryOwner = new ArrayList(); - activeGestures = new ArrayList(); - - xmlRpcResponse = new XmlRpcResponse(); - // defaultXmlRpcResponse = new XmlRpcResponse(); - - SetDefaultValues(); - } - - private void SetDefaultValues() - { - DST = "N"; - StipendSinceLogin = "N"; - Gendered = "Y"; - EverLoggedIn = "Y"; - login = "false"; - firstname = "Test"; - lastname = "User"; - agentAccess = "M"; - startLocation = "last"; - allowFirstLife = "Y"; - - SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; - MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; - - ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; - ErrorReason = "key"; - welcomeMessage = "Welcome to OpenSim!"; - seedCapability = String.Empty; - home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + - userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + - userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + - userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; - lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; - RegionX = (uint) 255232; - RegionY = (uint) 254976; - - // Classifieds; - AddClassifiedCategory((Int32) 1, "Shopping"); - AddClassifiedCategory((Int32) 2, "Land Rental"); - AddClassifiedCategory((Int32) 3, "Property Rental"); - AddClassifiedCategory((Int32) 4, "Special Attraction"); - AddClassifiedCategory((Int32) 5, "New Products"); - AddClassifiedCategory((Int32) 6, "Employment"); - AddClassifiedCategory((Int32) 7, "Wanted"); - AddClassifiedCategory((Int32) 8, "Service"); - AddClassifiedCategory((Int32) 9, "Personal"); - - SessionID = UUID.Random(); - SecureSessionID = UUID.Random(); - AgentID = UUID.Random(); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - initialOutfit.Add(InitialOutfitHash); - } - - #region Login Failure Methods - - public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) - { - // Overwrite any default values; - xmlRpcResponse = new XmlRpcResponse(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - loginError["reason"] = ErrorReason; - loginError["message"] = ErrorMessage; - loginError["login"] = login; - xmlRpcResponse.Value = loginError; - return (xmlRpcResponse); - } - - public OSD GenerateFailureResponseLLSD(string reason, string message, string login) - { - OSDMap map = new OSDMap(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - map["reason"] = OSD.FromString(ErrorReason); - map["message"] = OSD.FromString(ErrorMessage); - map["login"] = OSD.FromString(login); - - return map; - } - - public XmlRpcResponse CreateFailedResponse() - { - return (CreateLoginFailedResponse()); - } - - public OSD CreateFailedResponseLLSD() - { - return CreateLoginFailedResponseLLSD(); - } - - public XmlRpcResponse CreateLoginFailedResponse() - { - return - (GenerateFailureResponse("key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false")); - } - - public OSD CreateLoginFailedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false"); - } - - /// - /// Response to indicate that login failed because the agent's inventory was not available. - /// - /// - public XmlRpcResponse CreateLoginInventoryFailedResponse() - { - return GenerateFailureResponse( - "key", - "The avatar inventory service is not responding. Please notify your login region operator.", - "false"); - } - - public XmlRpcResponse CreateAlreadyLoggedInResponse() - { - return - (GenerateFailureResponse("presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", - "false")); - } - - public OSD CreateAlreadyLoggedInResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner", - "false"); - } - - public XmlRpcResponse CreateLoginBlockedResponse() - { - return - (GenerateFailureResponse("presence", - "Logins are currently restricted. Please try again later", - "false")); - } - - public OSD CreateLoginBlockedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "Logins are currently restricted. Please try again later", - "false"); - } - - public XmlRpcResponse CreateDeadRegionResponse() - { - return - (GenerateFailureResponse("key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false")); - } - - public OSD CreateDeadRegionResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false"); - } - - public XmlRpcResponse CreateGridErrorResponse() - { - return - (GenerateFailureResponse("key", - "Error connecting to grid. Could not percieve credentials from login XML.", - "false")); - } - - public OSD CreateGridErrorResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Error connecting to grid. Could not percieve credentials from login XML.", - "false"); - } - - #endregion - - public virtual XmlRpcResponse ToXmlRpcResponse() - { - try - { - Hashtable responseData = new Hashtable(); - - loginFlagsHash = new Hashtable(); - loginFlagsHash["daylight_savings"] = DST; - loginFlagsHash["stipend_since_login"] = StipendSinceLogin; - loginFlagsHash["gendered"] = Gendered; - loginFlagsHash["ever_logged_in"] = EverLoggedIn; - loginFlags.Add(loginFlagsHash); - - responseData["first_name"] = Firstname; - responseData["last_name"] = Lastname; - responseData["agent_access"] = agentAccess; - - globalTexturesHash = new Hashtable(); - globalTexturesHash["sun_texture_id"] = SunTexture; - globalTexturesHash["cloud_texture_id"] = CloudTexture; - globalTexturesHash["moon_texture_id"] = MoonTexture; - globalTextures.Add(globalTexturesHash); - // this.eventCategories.Add(this.eventCategoriesHash); - - AddToUIConfig("allow_first_life", allowFirstLife); - uiConfig.Add(uiConfigHash); - - responseData["sim_port"] = (Int32) SimPort; - responseData["sim_ip"] = SimAddress; - responseData["http_port"] = (Int32)SimHttpPort; - - responseData["agent_id"] = AgentID.ToString(); - responseData["session_id"] = SessionID.ToString(); - responseData["secure_session_id"] = SecureSessionID.ToString(); - responseData["circuit_code"] = CircuitCode; - responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = loginFlags; - responseData["global-textures"] = globalTextures; - responseData["seed_capability"] = seedCapability; - - responseData["event_categories"] = eventCategories; - responseData["event_notifications"] = new ArrayList(); // todo - responseData["classified_categories"] = classifiedCategories; - responseData["ui-config"] = uiConfig; - - responseData["inventory-skeleton"] = agentInventory; - responseData["inventory-skel-lib"] = inventoryLibrary; - responseData["inventory-root"] = inventoryRoot; - responseData["inventory-lib-root"] = inventoryLibRoot; - responseData["gestures"] = activeGestures; - responseData["inventory-lib-owner"] = inventoryLibraryOwner; - responseData["initial-outfit"] = initialOutfit; - responseData["start_location"] = startLocation; - responseData["seed_capability"] = seedCapability; - responseData["home"] = home; - responseData["look_at"] = lookAt; - responseData["message"] = welcomeMessage; - responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); - responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); - - //responseData["inventory-lib-root"] = new ArrayList(); // todo - - if (m_buddyList != null) - { - responseData["buddy-list"] = m_buddyList.ToArray(); - } - - responseData["login"] = "true"; - xmlRpcResponse.Value = responseData; - - return (xmlRpcResponse); - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); - - return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); - } - } - - public OSD ToLLSDResponse() - { - try - { - OSDMap map = new OSDMap(); - - map["first_name"] = OSD.FromString(Firstname); - map["last_name"] = OSD.FromString(Lastname); - map["agent_access"] = OSD.FromString(agentAccess); - - map["sim_port"] = OSD.FromInteger(SimPort); - map["sim_ip"] = OSD.FromString(SimAddress); - - map["agent_id"] = OSD.FromUUID(AgentID); - map["session_id"] = OSD.FromUUID(SessionID); - map["secure_session_id"] = OSD.FromUUID(SecureSessionID); - map["circuit_code"] = OSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); - - #region Login Flags - - OSDMap loginFlagsLLSD = new OSDMap(); - loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); - map["login-flags"] = WrapOSDMap(loginFlagsLLSD); - - #endregion Login Flags - - #region Global Textures - - OSDMap globalTexturesLLSD = new OSDMap(); - globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); - - map["global-textures"] = WrapOSDMap(globalTexturesLLSD); - - #endregion Global Textures - - map["seed_capability"] = OSD.FromString(seedCapability); - - map["event_categories"] = ArrayListToOSDArray(eventCategories); - //map["event_notifications"] = new OSDArray(); // todo - map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); - - #region UI Config - - OSDMap uiConfigLLSD = new OSDMap(); - uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); - map["ui-config"] = WrapOSDMap(uiConfigLLSD); - - #endregion UI Config - - #region Inventory - - map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); - - map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); - - #endregion Inventory - - map["gestures"] = ArrayListToOSDArray(activeGestures); - - map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); - map["start_location"] = OSD.FromString(startLocation); - - map["seed_capability"] = OSD.FromString(seedCapability); - map["home"] = OSD.FromString(home); - map["look_at"] = OSD.FromString(lookAt); - map["message"] = OSD.FromString(welcomeMessage); - map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); - - if (m_buddyList != null) - { - map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); - } - - map["login"] = OSD.FromString("true"); - - return map; - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); - - return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); - } - } - - public OSDArray ArrayListToOSDArray(ArrayList arrlst) - { - OSDArray llsdBack = new OSDArray(); - foreach (Hashtable ht in arrlst) - { - OSDMap mp = new OSDMap(); - foreach (DictionaryEntry deHt in ht) - { - mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); - } - llsdBack.Add(mp); - } - return llsdBack; - } - - private static OSDArray WrapOSDMap(OSDMap wrapMe) - { - OSDArray array = new OSDArray(); - array.Add(wrapMe); - return array; - } - - public void SetEventCategories(string category, string value) - { - // this.eventCategoriesHash[category] = value; - //TODO - } - - public void AddToUIConfig(string itemName, string item) - { - uiConfigHash[itemName] = item; - } - - public void AddClassifiedCategory(Int32 ID, string categoryName) - { - Hashtable hash = new Hashtable(); - hash["category_name"] = categoryName; - hash["category_id"] = ID; - classifiedCategories.Add(hash); - // this.classifiedCategoriesHash.Clear(); - } - - #region Properties - - public string Login - { - get { return login; } - set { login = value; } - } - - public string DST - { - get { return dst; } - set { dst = value; } - } - - public string StipendSinceLogin - { - get { return stipendSinceLogin; } - set { stipendSinceLogin = value; } - } - - public string Gendered - { - get { return gendered; } - set { gendered = value; } - } - - public string EverLoggedIn - { - get { return everLoggedIn; } - set { everLoggedIn = value; } - } - - public uint SimPort - { - get { return simPort; } - set { simPort = value; } - } - - public uint SimHttpPort - { - get { return simHttpPort; } - set { simHttpPort = value; } - } - - public string SimAddress - { - get { return simAddress; } - set { simAddress = value; } - } - - public UUID AgentID - { - get { return agentID; } - set { agentID = value; } - } - - public UUID SessionID - { - get { return sessionID; } - set { sessionID = value; } - } - - public UUID SecureSessionID - { - get { return secureSessionID; } - set { secureSessionID = value; } - } - - public Int32 CircuitCode - { - get { return circuitCode; } - set { circuitCode = value; } - } - - public uint RegionX - { - get { return regionX; } - set { regionX = value; } - } - - public uint RegionY - { - get { return regionY; } - set { regionY = value; } - } - - public string SunTexture - { - get { return sunTexture; } - set { sunTexture = value; } - } - - public string CloudTexture - { - get { return cloudTexture; } - set { cloudTexture = value; } - } - - public string MoonTexture - { - get { return moonTexture; } - set { moonTexture = value; } - } - - public string Firstname - { - get { return firstname; } - set { firstname = value; } - } - - public string Lastname - { - get { return lastname; } - set { lastname = value; } - } - - public string AgentAccess - { - get { return agentAccess; } - set { agentAccess = value; } - } - - public string StartLocation - { - get { return startLocation; } - set { startLocation = value; } - } - - public string LookAt - { - get { return lookAt; } - set { lookAt = value; } - } - - public string SeedCapability - { - get { return seedCapability; } - set { seedCapability = value; } - } - - public string ErrorReason - { - get { return errorReason; } - set { errorReason = value; } - } - - public string ErrorMessage - { - get { return errorMessage; } - set { errorMessage = value; } - } - - public ArrayList InventoryRoot - { - get { return inventoryRoot; } - set { inventoryRoot = value; } - } - - public ArrayList InventorySkeleton - { - get { return agentInventory; } - set { agentInventory = value; } - } - - public ArrayList InventoryLibrary - { - get { return inventoryLibrary; } - set { inventoryLibrary = value; } - } - - public ArrayList InventoryLibraryOwner - { - get { return inventoryLibraryOwner; } - set { inventoryLibraryOwner = value; } - } - - public ArrayList InventoryLibRoot - { - get { return inventoryLibRoot; } - set { inventoryLibRoot = value; } - } - - public ArrayList ActiveGestures - { - get { return activeGestures; } - set { activeGestures = value; } - } - - public string Home - { - get { return home; } - set { home = value; } - } - - public string Message - { - get { return welcomeMessage; } - set { welcomeMessage = value; } - } - - public BuddyList BuddList - { - get { return m_buddyList; } - set { m_buddyList = value; } - } - - #endregion - - public class UserInfo - { - public string firstname; - public string lastname; - public ulong homeregionhandle; - public Vector3 homepos; - public Vector3 homelookat; - } - - public class BuddyList - { - public List Buddies = new List(); - - public void AddNewBuddy(BuddyInfo buddy) - { - if (!Buddies.Contains(buddy)) - { - Buddies.Add(buddy); - } - } - - public ArrayList ToArray() - { - ArrayList buddyArray = new ArrayList(); - foreach (BuddyInfo buddy in Buddies) - { - buddyArray.Add(buddy.ToHashTable()); - } - return buddyArray; - } - - public class BuddyInfo - { - public int BuddyRightsHave = 1; - public int BuddyRightsGiven = 1; - public UUID BuddyID; - - public BuddyInfo(string buddyID) - { - BuddyID = new UUID(buddyID); - } - - public BuddyInfo(UUID buddyID) - { - BuddyID = buddyID; - } - - public Hashtable ToHashTable() - { - Hashtable hTable = new Hashtable(); - hTable["buddy_rights_has"] = BuddyRightsHave; - hTable["buddy_rights_given"] = BuddyRightsGiven; - hTable["buddy_id"] = BuddyID.ToString(); - return hTable; - } - } - } - } -} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs deleted file mode 100644 index 99b5df7..0000000 --- a/OpenSim/Framework/Communications/LoginService.cs +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using System.Web; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Statistics; - -namespace OpenSim.Framework.Communications -{ - public abstract class LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected int m_minLoginLevel = 0; - protected UserManagerBase m_userManager = null; - protected Mutex m_loginMutex = new Mutex(false); - - /// - /// Used during login to send the skeleton of the OpenSim Library to the client. - /// - protected LibraryRootFolder m_libraryRootFolder; - - protected uint m_defaultHomeX; - protected uint m_defaultHomeY; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_inventoryService; - - /// - /// Constructor - /// - /// - /// - /// - public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, - string welcomeMess) - { - m_userManager = userManager; - m_libraryRootFolder = libraryRootFolder; - - if (welcomeMess != String.Empty) - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// If the user is already logged in, try to notify the region that the user they've got is dead. - /// - /// - public virtual void LogOffUser(UserProfileData theUser, string message) - { - } - - - /// - /// Called when we receive the client's initial XMLRPC login_to_simulator request message - /// - /// The XMLRPC request - /// The response to send - public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. - //CKF: m_log.Info("[LOGIN]: Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - SniffLoginKey((Uri)request.Params[2], requestData); - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && - (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - - string startLocationRequest = "last"; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - string firstname; - string lastname; - - if (GoodXML) - { - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - } - - firstname = (string)requestData["first"]; - lastname = (string)requestData["last"]; - - m_log.InfoFormat( - "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", - firstname, lastname); - - string clientVersion = "Unknown"; - - if (requestData.Contains("version")) - { - clientVersion = (string)requestData["version"]; - } - - m_log.DebugFormat( - "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - - if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) - { - return logResponse.CreateLoginFailedResponse(); - } - } - else - { - m_log.Info( - "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); - - return logResponse.CreateGridErrorResponse(); - } - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponse(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - //TODO: The following statements can cause trouble: - // If agentOnline could not turn from true back to false normally - // because of some problem, for instance, the crashment of server or client, - // the user cannot log in any longer. - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - - // try to tell the region that their user is dead. - LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); - - // Reject the login - - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", - firstname, lastname); - - return logResponse.CreateAlreadyLoggedInResponse(); - } - - // Otherwise... - // Create a new agent session - - m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - try - { - UUID agentID = userProfile.ID; - InventoryData inventData; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", - agentID, e); - - return logResponse.CreateLoginInventoryFailedResponse(); - } - - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) - { - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); - - return logResponse.ToXmlRpcResponse(); - } - else - { - m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); - return logResponse.CreateDeadRegionResponse(); - } - } - catch (Exception e) - { - m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); - m_log.Error(e.StackTrace); - } - } - - m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); - return response; - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) - { - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodLogin = false; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); - } - else - { - if (requestData.Contains("passwd")) - { - string passwd = (string)requestData["passwd"]; - GoodLogin = AuthenticateUser(userProfile, passwd); - } - if (!GoodLogin && (requestData.Contains("web_login_key"))) - { - try - { - UUID webloginkey = new UUID((string)requestData["web_login_key"]); - GoodLogin = AuthenticateUser(userProfile, webloginkey); - } - catch (Exception e) - { - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", - requestData["web_login_key"], firstname, lastname, e); - } - } - } - - return GoodLogin; - } - - protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) - { - bool GoodLogin = false; - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); - - return false; - } - - GoodLogin = AuthenticateUser(userProfile, passwd); - return GoodLogin; - } - - /// - /// Called when we receive the client's initial LLSD login_to_simulator request message - /// - /// The LLSD request - /// The response to send - public OSD LLSDLoginMethod(OSD request) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - // bool GoodLogin = false; - - string startLocationRequest = "last"; - - UserProfileData userProfile = null; - LoginResponse logResponse = new LoginResponse(); - - if (request.Type == OSDType.Map) - { - OSDMap map = (OSDMap)request; - - if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) - { - string firstname = map["first"].AsString(); - string lastname = map["last"].AsString(); - string passwd = map["passwd"].AsString(); - - if (map.ContainsKey("start")) - { - m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); - startLocationRequest = map["start"].AsString(); - } - m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); - - if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) - { - return logResponse.CreateLoginFailedResponseLLSD(); - } - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponseLLSD(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - // try to tell the region that their user is dead. - LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); - - // Reject the login - - m_log.InfoFormat( - "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", - userProfile.FirstName, userProfile.SurName); - - userProfile.CurrentAgent = null; - return logResponse.CreateAlreadyLoggedInResponseLLSD(); - } - - // Otherwise... - // Create a new agent session - - m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - try - { - UUID agentID = userProfile.ID; - - //InventoryData inventData = GetInventorySkeleton(agentID); - InventoryData inventData = null; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", - agentID, e.GetType(), e.Message); - - return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); - } - - - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; - - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - try - { - CustomiseResponse(logResponse, userProfile, startLocationRequest); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateDeadRegionResponseLLSD(); - } - - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", - userProfile.FirstName, userProfile.SurName); - - return logResponse.ToLLSDResponse(); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateFailedResponseLLSD(); - } - } - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - public Hashtable ProcessHTMLLogin(Hashtable keysvals) - { - // Matches all unspecified characters - // Currently specified,; lowercase letters, upper case letters, numbers, underline - // period, space, parens, and dash. - - Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); - - Hashtable returnactions = new Hashtable(); - int statuscode = 200; - - string firstname = String.Empty; - string lastname = String.Empty; - string location = String.Empty; - string region = String.Empty; - string grid = String.Empty; - string channel = String.Empty; - string version = String.Empty; - string lang = String.Empty; - string password = String.Empty; - string errormessages = String.Empty; - - // the client requires the HTML form field be named 'username' - // however, the data it sends when it loads the first time is 'firstname' - // another one of those little nuances. - - if (keysvals.Contains("firstname")) - firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); - - if (keysvals.Contains("username")) - firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); - - if (keysvals.Contains("lastname")) - lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); - - if (keysvals.Contains("location")) - location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); - - if (keysvals.Contains("region")) - region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); - - if (keysvals.Contains("grid")) - grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); - - if (keysvals.Contains("channel")) - channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); - - if (keysvals.Contains("version")) - version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); - - if (keysvals.Contains("lang")) - lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); - - if (keysvals.Contains("password")) - password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); - - // load our login form. - string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - - if (keysvals.ContainsKey("show_login_form")) - { - UserProfileData user = GetTheUser(firstname, lastname); - bool goodweblogin = false; - - if (user != null) - goodweblogin = AuthenticateUser(user, password); - - if (goodweblogin) - { - UUID webloginkey = UUID.Random(); - m_userManager.StoreWebLoginKey(user.ID, webloginkey); - //statuscode = 301; - - // string redirectURL = "about:blank?redirect-http-hack=" + - // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + - // lastname + - // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); - //m_log.Info("[WEB]: R:" + redirectURL); - returnactions["int_response_code"] = statuscode; - //returnactions["str_redirect_location"] = redirectURL; - //returnactions["str_response_string"] = "GoodLogin"; - returnactions["str_response_string"] = webloginkey.ToString(); - } - else - { - errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; - - loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - } - else - { - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - return returnactions; - } - - public string GetLoginForm(string firstname, string lastname, string location, string region, - string grid, string channel, string version, string lang, - string password, string errormessages) - { - // inject our values in the form at the markers - - string loginform = String.Empty; - string file = Path.Combine(Util.configDir(), "http_loginform.html"); - if (!File.Exists(file)) - { - loginform = GetDefaultLoginForm(); - } - else - { - StreamReader sr = File.OpenText(file); - loginform = sr.ReadToEnd(); - sr.Close(); - } - - loginform = loginform.Replace("[$firstname]", firstname); - loginform = loginform.Replace("[$lastname]", lastname); - loginform = loginform.Replace("[$location]", location); - loginform = loginform.Replace("[$region]", region); - loginform = loginform.Replace("[$grid]", grid); - loginform = loginform.Replace("[$channel]", channel); - loginform = loginform.Replace("[$version]", version); - loginform = loginform.Replace("[$lang]", lang); - loginform = loginform.Replace("[$password]", password); - loginform = loginform.Replace("[$errors]", errormessages); - - return loginform; - } - - public string GetDefaultLoginForm() - { - string responseString = - ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "OpenSim Login"; - responseString += "
"; - responseString += "
"; - - responseString += "
"; - - responseString += "
[$errors]
"; - responseString += "
"; - responseString += "First Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Last Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Password:"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += "
Connecting...
"; - - responseString += "
"; - - responseString += "
[$channel] | [$version]=[$lang]
"; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - - return responseString; - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - return m_userManager.CommitAgent(ref profile); - } - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - bool passwordSuccess = false; - //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Web Login method seems to also occasionally send the hashed password itself - - // we do this to get our hash in a form that the server password code can consume - // when the web-login-form submits the password in the clear (supposed to be over SSL!) - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - // Testing... - //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); - //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - - passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); - - return passwordSuccess; - } - - public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) - { - bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Match web login key unless it's the default weblogin key UUID.Zero - passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); - - return passwordSuccess; - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - m_userManager.CreateAgent(profile, request); - } - - public void CreateAgent(UserProfileData profile, OSD request) - { - m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) - { - LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); - foreach (FriendListItem fl in LFL) - { - LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); - buddyitem.BuddyID = fl.Friend; - buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; - buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; - buddylistreturn.AddNewBuddy(buddyitem); - } - return buddylistreturn; - } - - /// - /// Converts the inventory library skeleton into the form required by the rpc request. - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - Dictionary rootFolders - = m_libraryRootFolder.RequestSelfAndDescendentFolders(); - ArrayList folderHashes = new ArrayList(); - - foreach (InventoryFolderBase folder in rootFolders.Values) - { - Hashtable TempHash = new Hashtable(); - TempHash["name"] = folder.Name; - TempHash["parent_id"] = folder.ParentID.ToString(); - TempHash["version"] = (Int32)folder.Version; - TempHash["type_default"] = (Int32)folder.Type; - TempHash["folder_id"] = folder.ID.ToString(); - folderHashes.Add(TempHash); - } - - return folderHashes; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public UUID RootFolderID = UUID.Zero; - - public InventoryData(ArrayList invList, UUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - - protected void SniffLoginKey(Uri uri, Hashtable requestData) - { - string uri_str = uri.ToString(); - string[] parts = uri_str.Split(new char[] { '=' }); - if (parts.Length > 1) - { - string web_login_key = parts[1]; - requestData.Add("web_login_key", web_login_key); - m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); - } - } - - /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// The requested start location - /// true on success, false if the region was not successfully told to expect a user connection - public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) - { - // add active gestures to login-response - AddActiveGestures(response, theUser); - - // HomeLocation - RegionInfo homeInfo = null; - - // use the homeRegionID if it is stored already. If not, use the regionHandle as before - UUID homeRegionId = theUser.HomeRegionID; - ulong homeRegionHandle = theUser.HomeRegion; - if (homeRegionId != UUID.Zero) - { - homeInfo = GetRegionInfo(homeRegionId); - } - else - { - homeInfo = GetRegionInfo(homeRegionHandle); - } - - if (homeInfo != null) - { - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - (homeInfo.RegionLocX * Constants.RegionSize), - (homeInfo.RegionLocY * Constants.RegionSize), - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - } - else - { - m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); - // Emergency mode: Home-region isn't available, so we can't request the region info. - // Use the stored home regionHandle instead. - // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = homeRegionHandle >> 32; - ulong regionY = homeRegionHandle & 0xffffffff; - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - regionX, regionY, - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - - m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", - theUser.FirstName, theUser.SurName, - regionX, regionY); - } - - // StartLocation - RegionInfo regionInfo = null; - if (startLocationRequest == "home") - { - regionInfo = homeInfo; - theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; - } - else if (startLocationRequest == "last") - { - UUID lastRegion = theUser.CurrentAgent.Region; - regionInfo = GetRegionInfo(lastRegion); - response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; - } - else - { - Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); - Match uriMatch = reURI.Match(startLocationRequest); - if (uriMatch == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); - } - else - { - string region = uriMatch.Groups["region"].ToString(); - regionInfo = RequestClosestRegion(region); - if (regionInfo == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); - } - else - { - theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), - float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); - } - } - response.LookAt = "[r0,r1,r0]"; - // can be: last, home, safe, url - response.StartLocation = "url"; - } - - if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) - { - return true; - } - - // StartLocation not available, send him to a nearby region instead - // regionInfo = m_gridService.RequestClosestRegion(""); - //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); - - // Send him to default region instead - ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | - ((ulong)m_defaultHomeY * Constants.RegionSize); - - if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) - { - m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); - return false; - } - - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - - if (regionInfo == null) - { - m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); - return false; - } - - theUser.CurrentAgent.Position = new Vector3(128, 128, 0); - response.StartLocation = "safe"; - - return PrepareLoginToRegion(regionInfo, theUser, response); - } - - protected abstract RegionInfo RequestClosestRegion(string region); - protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); - protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); - - /// - /// Add active gestures of the user to the login response. - /// - /// - /// A - /// - /// - /// A - /// - protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) - { - List gestures = m_inventoryService.GetActiveGestures(theUser.ID); - //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); - ArrayList list = new ArrayList(); - if (gestures != null) - { - foreach (InventoryItemBase gesture in gestures) - { - Hashtable item = new Hashtable(); - item["item_id"] = gesture.ID.ToString(); - item["asset_id"] = gesture.AssetID.ToString(); - list.Add(item); - } - } - response.ActiveGestures = list; - } - - /// - /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. - /// - /// - /// - /// This will be thrown if there is a problem with the inventory service - protected InventoryData GetInventorySkeleton(UUID userID) - { - List folders = m_inventoryService.GetInventorySkeleton(userID); - - // If we have user auth but no inventory folders for some reason, create a new set of folders. - if (folders == null || folders.Count == 0) - { - m_log.InfoFormat( - "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); - - // Although the create user function creates a new agent inventory along with a new user profile, some - // tools are creating the user profile directly in the database without creating the inventory. At - // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already - // exist. - if (!m_inventoryService.CreateNewUserInventory(userID)) - { - throw new Exception( - String.Format( - "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", - userID)); - } - - m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); - - folders = m_inventoryService.GetInventorySkeleton(userID); - - if (folders == null || folders.Count == 0) - { - throw new Exception( - String.Format( - "A root inventory folder for user {0} could not be retrieved from the inventory service", - userID)); - } - } - - UUID rootID = UUID.Zero; - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolderBase InvFolder in folders) - { - if (InvFolder.ParentID == UUID.Zero) - { - rootID = InvFolder.ID; - } - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.Name; - TempHash["parent_id"] = InvFolder.ParentID.ToString(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.Type; - TempHash["folder_id"] = InvFolder.ID.ToString(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, rootID); - } - } -} diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs new file mode 100644 index 0000000..96fe0d8 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -0,0 +1,172 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.Communications.Services +{ + public class GridInfoService + { + private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable _info = new Hashtable(); + + /// + /// Instantiate a GridInfoService object. + /// + /// path to config path containing + /// grid information + /// + /// GridInfoService uses the [GridInfo] section of the + /// standard OpenSim.ini file --- which is not optimal, but + /// anything else requires a general redesign of the config + /// system. + /// + public GridInfoService(IConfigSource configSource) + { + loadGridInfo(configSource); + } + + /// + /// Default constructor, uses OpenSim.ini. + /// + public GridInfoService() + { + try + { + IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); + loadGridInfo(configSource); + } + catch (FileNotFoundException) + { + _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); + } + } + + private void loadGridInfo(IConfigSource configSource) + { + _info["platform"] = "OpenSim"; + try + { + IConfig startupCfg = configSource.Configs["Startup"]; + IConfig gridCfg = configSource.Configs["GridInfo"]; + IConfig netCfg = configSource.Configs["Network"]; + + bool grid = startupCfg.GetBoolean("gridmode", false); + + if (grid) + _info["mode"] = "grid"; + else + _info["mode"] = "standalone"; + + + if (null != gridCfg) + { + foreach (string k in gridCfg.GetKeys()) + { + _info[k] = gridCfg.GetString(k); + } + } + else if (null != netCfg) + { + if (grid) + _info["login"] + = netCfg.GetString( + "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + else + _info["login"] + = String.Format( + "http://127.0.0.1:{0}/", + netCfg.GetString( + "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); + + IssueWarning(); + } + else + { + _info["login"] = "http://127.0.0.1:9000/"; + IssueWarning(); + } + } + catch (Exception) + { + _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); + } + _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); + + } + + private void IssueWarning() + { + _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); + _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); + foreach (string k in _info.Keys) + { + _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); + } + } + + public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + _log.Info("[GridInfo]: Request for grid info"); + + foreach (string k in _info.Keys) + { + responseData[k] = _info[k]; + } + response.Value = responseData; + + return response; + } + + public string RestGetGridInfoMethod(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StringBuilder sb = new StringBuilder(); + + sb.Append("\n"); + foreach (string k in _info.Keys) + { + sb.AppendFormat("<{0}>{1}\n", k, _info[k]); + } + sb.Append("\n"); + + return sb.ToString(); + } + } +} diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index f0b2259..33d7722 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -52,19 +52,41 @@ namespace OpenSim.Framework.Communications.Services = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private InventoryServiceBase m_inventoryService; - private UserManagerBase m_userService; - IAssetDataPlugin m_assetProvider; IHttpServer httpServer; private string m_thisInventoryUrl = "http://localhost:9000"; private string m_thisHostname = "127.0.0.1"; private uint m_thisPort = 9000; + // These two used for local access, standalone mode + private UserManagerBase m_userService = null; + IAssetDataPlugin m_assetProvider = null; - public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string url) + // These two used for remote access + string m_UserServerURL = string.Empty; + string m_AssetServerURL = string.Empty; + + // Constructor for grid inventory server + public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) + { + m_UserServerURL = userServiceURL; + m_AssetServerURL = assetServiceURL; + + Init(invService, thisurl, httpserver); + } + + // Constructor for standalone mode + public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) { - m_inventoryService = invService; m_userService = userService; - m_thisInventoryUrl = url; + m_assetProvider = assetService; + + Init(invService, thisurl, httpserver); + } + + private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) + { + m_inventoryService = invService; + m_thisInventoryUrl = thisurl; if (!m_thisInventoryUrl.EndsWith("/")) m_thisInventoryUrl += "/"; @@ -75,7 +97,6 @@ namespace OpenSim.Framework.Communications.Services m_thisPort = (uint)uri.Port; } - m_assetProvider = assetService; httpServer = httpserver; AddHttpHandlers(); diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs new file mode 100644 index 0000000..82515e0 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -0,0 +1,812 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +namespace OpenSim.Framework.Communications.Services +{ + /// + /// A temp class to handle login response. + /// Should make use of UserProfileManager where possible. + /// + public class LoginResponse + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable loginFlagsHash; + private Hashtable globalTexturesHash; + private Hashtable loginError; + private Hashtable uiConfigHash; + + private ArrayList loginFlags; + private ArrayList globalTextures; + private ArrayList eventCategories; + private ArrayList uiConfig; + private ArrayList classifiedCategories; + private ArrayList inventoryRoot; + private ArrayList initialOutfit; + private ArrayList agentInventory; + private ArrayList inventoryLibraryOwner; + private ArrayList inventoryLibRoot; + private ArrayList inventoryLibrary; + private ArrayList activeGestures; + + private UserInfo userProfile; + + private UUID agentID; + private UUID sessionID; + private UUID secureSessionID; + + // Login Flags + private string dst; + private string stipendSinceLogin; + private string gendered; + private string everLoggedIn; + private string login; + private uint simPort; + private uint simHttpPort; + private string simAddress; + private string agentAccess; + private Int32 circuitCode; + private uint regionX; + private uint regionY; + + // Login + private string firstname; + private string lastname; + + // Global Textures + private string sunTexture; + private string cloudTexture; + private string moonTexture; + + // Error Flags + private string errorReason; + private string errorMessage; + + // Response + private XmlRpcResponse xmlRpcResponse; + // private XmlRpcResponse defaultXmlRpcResponse; + + private string welcomeMessage; + private string startLocation; + private string allowFirstLife; + private string home; + private string seedCapability; + private string lookAt; + + private BuddyList m_buddyList = null; + + public LoginResponse() + { + loginFlags = new ArrayList(); + globalTextures = new ArrayList(); + eventCategories = new ArrayList(); + uiConfig = new ArrayList(); + classifiedCategories = new ArrayList(); + + loginError = new Hashtable(); + uiConfigHash = new Hashtable(); + + // defaultXmlRpcResponse = new XmlRpcResponse(); + userProfile = new UserInfo(); + inventoryRoot = new ArrayList(); + initialOutfit = new ArrayList(); + agentInventory = new ArrayList(); + inventoryLibrary = new ArrayList(); + inventoryLibraryOwner = new ArrayList(); + activeGestures = new ArrayList(); + + xmlRpcResponse = new XmlRpcResponse(); + // defaultXmlRpcResponse = new XmlRpcResponse(); + + SetDefaultValues(); + } + + private void SetDefaultValues() + { + DST = "N"; + StipendSinceLogin = "N"; + Gendered = "Y"; + EverLoggedIn = "Y"; + login = "false"; + firstname = "Test"; + lastname = "User"; + agentAccess = "M"; + startLocation = "last"; + allowFirstLife = "Y"; + + SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; + MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; + + ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + ErrorReason = "key"; + welcomeMessage = "Welcome to OpenSim!"; + seedCapability = String.Empty; + home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + + userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + + userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + + userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; + lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + RegionX = (uint) 255232; + RegionY = (uint) 254976; + + // Classifieds; + AddClassifiedCategory((Int32) 1, "Shopping"); + AddClassifiedCategory((Int32) 2, "Land Rental"); + AddClassifiedCategory((Int32) 3, "Property Rental"); + AddClassifiedCategory((Int32) 4, "Special Attraction"); + AddClassifiedCategory((Int32) 5, "New Products"); + AddClassifiedCategory((Int32) 6, "Employment"); + AddClassifiedCategory((Int32) 7, "Wanted"); + AddClassifiedCategory((Int32) 8, "Service"); + AddClassifiedCategory((Int32) 9, "Personal"); + + SessionID = UUID.Random(); + SecureSessionID = UUID.Random(); + AgentID = UUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + initialOutfit.Add(InitialOutfitHash); + } + + #region Login Failure Methods + + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) + { + // Overwrite any default values; + xmlRpcResponse = new XmlRpcResponse(); + + // Ensure Login Failed message/reason; + ErrorMessage = message; + ErrorReason = reason; + + loginError["reason"] = ErrorReason; + loginError["message"] = ErrorMessage; + loginError["login"] = login; + xmlRpcResponse.Value = loginError; + return (xmlRpcResponse); + } + + public OSD GenerateFailureResponseLLSD(string reason, string message, string login) + { + OSDMap map = new OSDMap(); + + // Ensure Login Failed message/reason; + ErrorMessage = message; + ErrorReason = reason; + + map["reason"] = OSD.FromString(ErrorReason); + map["message"] = OSD.FromString(ErrorMessage); + map["login"] = OSD.FromString(login); + + return map; + } + + public XmlRpcResponse CreateFailedResponse() + { + return (CreateLoginFailedResponse()); + } + + public OSD CreateFailedResponseLLSD() + { + return CreateLoginFailedResponseLLSD(); + } + + public XmlRpcResponse CreateLoginFailedResponse() + { + return + (GenerateFailureResponse("key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false")); + } + + public OSD CreateLoginFailedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false"); + } + + /// + /// Response to indicate that login failed because the agent's inventory was not available. + /// + /// + public XmlRpcResponse CreateLoginInventoryFailedResponse() + { + return GenerateFailureResponse( + "key", + "The avatar inventory service is not responding. Please notify your login region operator.", + "false"); + } + + public XmlRpcResponse CreateAlreadyLoggedInResponse() + { + return + (GenerateFailureResponse("presence", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner. " + + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", + "false")); + } + + public OSD CreateAlreadyLoggedInResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner", + "false"); + } + + public XmlRpcResponse CreateLoginBlockedResponse() + { + return + (GenerateFailureResponse("presence", + "Logins are currently restricted. Please try again later", + "false")); + } + + public OSD CreateLoginBlockedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "Logins are currently restricted. Please try again later", + "false"); + } + + public XmlRpcResponse CreateDeadRegionResponse() + { + return + (GenerateFailureResponse("key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false")); + } + + public OSD CreateDeadRegionResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false"); + } + + public XmlRpcResponse CreateGridErrorResponse() + { + return + (GenerateFailureResponse("key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false")); + } + + public OSD CreateGridErrorResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false"); + } + + #endregion + + public virtual XmlRpcResponse ToXmlRpcResponse() + { + try + { + Hashtable responseData = new Hashtable(); + + loginFlagsHash = new Hashtable(); + loginFlagsHash["daylight_savings"] = DST; + loginFlagsHash["stipend_since_login"] = StipendSinceLogin; + loginFlagsHash["gendered"] = Gendered; + loginFlagsHash["ever_logged_in"] = EverLoggedIn; + loginFlags.Add(loginFlagsHash); + + responseData["first_name"] = Firstname; + responseData["last_name"] = Lastname; + responseData["agent_access"] = agentAccess; + + globalTexturesHash = new Hashtable(); + globalTexturesHash["sun_texture_id"] = SunTexture; + globalTexturesHash["cloud_texture_id"] = CloudTexture; + globalTexturesHash["moon_texture_id"] = MoonTexture; + globalTextures.Add(globalTexturesHash); + // this.eventCategories.Add(this.eventCategoriesHash); + + AddToUIConfig("allow_first_life", allowFirstLife); + uiConfig.Add(uiConfigHash); + + responseData["sim_port"] = (Int32) SimPort; + responseData["sim_ip"] = SimAddress; + responseData["http_port"] = (Int32)SimHttpPort; + + responseData["agent_id"] = AgentID.ToString(); + responseData["session_id"] = SessionID.ToString(); + responseData["secure_session_id"] = SecureSessionID.ToString(); + responseData["circuit_code"] = CircuitCode; + responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = loginFlags; + responseData["global-textures"] = globalTextures; + responseData["seed_capability"] = seedCapability; + + responseData["event_categories"] = eventCategories; + responseData["event_notifications"] = new ArrayList(); // todo + responseData["classified_categories"] = classifiedCategories; + responseData["ui-config"] = uiConfig; + + responseData["inventory-skeleton"] = agentInventory; + responseData["inventory-skel-lib"] = inventoryLibrary; + responseData["inventory-root"] = inventoryRoot; + responseData["inventory-lib-root"] = inventoryLibRoot; + responseData["gestures"] = activeGestures; + responseData["inventory-lib-owner"] = inventoryLibraryOwner; + responseData["initial-outfit"] = initialOutfit; + responseData["start_location"] = startLocation; + responseData["seed_capability"] = seedCapability; + responseData["home"] = home; + responseData["look_at"] = lookAt; + responseData["message"] = welcomeMessage; + responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); + responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); + + //responseData["inventory-lib-root"] = new ArrayList(); // todo + + if (m_buddyList != null) + { + responseData["buddy-list"] = m_buddyList.ToArray(); + } + + responseData["login"] = "true"; + xmlRpcResponse.Value = responseData; + + return (xmlRpcResponse); + } + catch (Exception e) + { + m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); + + return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); + } + } + + public OSD ToLLSDResponse() + { + try + { + OSDMap map = new OSDMap(); + + map["first_name"] = OSD.FromString(Firstname); + map["last_name"] = OSD.FromString(Lastname); + map["agent_access"] = OSD.FromString(agentAccess); + + map["sim_port"] = OSD.FromInteger(SimPort); + map["sim_ip"] = OSD.FromString(SimAddress); + + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["secure_session_id"] = OSD.FromUUID(SecureSessionID); + map["circuit_code"] = OSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + + #region Login Flags + + OSDMap loginFlagsLLSD = new OSDMap(); + loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); + map["login-flags"] = WrapOSDMap(loginFlagsLLSD); + + #endregion Login Flags + + #region Global Textures + + OSDMap globalTexturesLLSD = new OSDMap(); + globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); + + map["global-textures"] = WrapOSDMap(globalTexturesLLSD); + + #endregion Global Textures + + map["seed_capability"] = OSD.FromString(seedCapability); + + map["event_categories"] = ArrayListToOSDArray(eventCategories); + //map["event_notifications"] = new OSDArray(); // todo + map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); + + #region UI Config + + OSDMap uiConfigLLSD = new OSDMap(); + uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); + map["ui-config"] = WrapOSDMap(uiConfigLLSD); + + #endregion UI Config + + #region Inventory + + map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); + + map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); + + #endregion Inventory + + map["gestures"] = ArrayListToOSDArray(activeGestures); + + map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); + map["start_location"] = OSD.FromString(startLocation); + + map["seed_capability"] = OSD.FromString(seedCapability); + map["home"] = OSD.FromString(home); + map["look_at"] = OSD.FromString(lookAt); + map["message"] = OSD.FromString(welcomeMessage); + map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); + + if (m_buddyList != null) + { + map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); + } + + map["login"] = OSD.FromString("true"); + + return map; + } + catch (Exception e) + { + m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); + + return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); + } + } + + public OSDArray ArrayListToOSDArray(ArrayList arrlst) + { + OSDArray llsdBack = new OSDArray(); + foreach (Hashtable ht in arrlst) + { + OSDMap mp = new OSDMap(); + foreach (DictionaryEntry deHt in ht) + { + mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); + } + llsdBack.Add(mp); + } + return llsdBack; + } + + private static OSDArray WrapOSDMap(OSDMap wrapMe) + { + OSDArray array = new OSDArray(); + array.Add(wrapMe); + return array; + } + + public void SetEventCategories(string category, string value) + { + // this.eventCategoriesHash[category] = value; + //TODO + } + + public void AddToUIConfig(string itemName, string item) + { + uiConfigHash[itemName] = item; + } + + public void AddClassifiedCategory(Int32 ID, string categoryName) + { + Hashtable hash = new Hashtable(); + hash["category_name"] = categoryName; + hash["category_id"] = ID; + classifiedCategories.Add(hash); + // this.classifiedCategoriesHash.Clear(); + } + + #region Properties + + public string Login + { + get { return login; } + set { login = value; } + } + + public string DST + { + get { return dst; } + set { dst = value; } + } + + public string StipendSinceLogin + { + get { return stipendSinceLogin; } + set { stipendSinceLogin = value; } + } + + public string Gendered + { + get { return gendered; } + set { gendered = value; } + } + + public string EverLoggedIn + { + get { return everLoggedIn; } + set { everLoggedIn = value; } + } + + public uint SimPort + { + get { return simPort; } + set { simPort = value; } + } + + public uint SimHttpPort + { + get { return simHttpPort; } + set { simHttpPort = value; } + } + + public string SimAddress + { + get { return simAddress; } + set { simAddress = value; } + } + + public UUID AgentID + { + get { return agentID; } + set { agentID = value; } + } + + public UUID SessionID + { + get { return sessionID; } + set { sessionID = value; } + } + + public UUID SecureSessionID + { + get { return secureSessionID; } + set { secureSessionID = value; } + } + + public Int32 CircuitCode + { + get { return circuitCode; } + set { circuitCode = value; } + } + + public uint RegionX + { + get { return regionX; } + set { regionX = value; } + } + + public uint RegionY + { + get { return regionY; } + set { regionY = value; } + } + + public string SunTexture + { + get { return sunTexture; } + set { sunTexture = value; } + } + + public string CloudTexture + { + get { return cloudTexture; } + set { cloudTexture = value; } + } + + public string MoonTexture + { + get { return moonTexture; } + set { moonTexture = value; } + } + + public string Firstname + { + get { return firstname; } + set { firstname = value; } + } + + public string Lastname + { + get { return lastname; } + set { lastname = value; } + } + + public string AgentAccess + { + get { return agentAccess; } + set { agentAccess = value; } + } + + public string StartLocation + { + get { return startLocation; } + set { startLocation = value; } + } + + public string LookAt + { + get { return lookAt; } + set { lookAt = value; } + } + + public string SeedCapability + { + get { return seedCapability; } + set { seedCapability = value; } + } + + public string ErrorReason + { + get { return errorReason; } + set { errorReason = value; } + } + + public string ErrorMessage + { + get { return errorMessage; } + set { errorMessage = value; } + } + + public ArrayList InventoryRoot + { + get { return inventoryRoot; } + set { inventoryRoot = value; } + } + + public ArrayList InventorySkeleton + { + get { return agentInventory; } + set { agentInventory = value; } + } + + public ArrayList InventoryLibrary + { + get { return inventoryLibrary; } + set { inventoryLibrary = value; } + } + + public ArrayList InventoryLibraryOwner + { + get { return inventoryLibraryOwner; } + set { inventoryLibraryOwner = value; } + } + + public ArrayList InventoryLibRoot + { + get { return inventoryLibRoot; } + set { inventoryLibRoot = value; } + } + + public ArrayList ActiveGestures + { + get { return activeGestures; } + set { activeGestures = value; } + } + + public string Home + { + get { return home; } + set { home = value; } + } + + public string Message + { + get { return welcomeMessage; } + set { welcomeMessage = value; } + } + + public BuddyList BuddList + { + get { return m_buddyList; } + set { m_buddyList = value; } + } + + #endregion + + public class UserInfo + { + public string firstname; + public string lastname; + public ulong homeregionhandle; + public Vector3 homepos; + public Vector3 homelookat; + } + + public class BuddyList + { + public List Buddies = new List(); + + public void AddNewBuddy(BuddyInfo buddy) + { + if (!Buddies.Contains(buddy)) + { + Buddies.Add(buddy); + } + } + + public ArrayList ToArray() + { + ArrayList buddyArray = new ArrayList(); + foreach (BuddyInfo buddy in Buddies) + { + buddyArray.Add(buddy.ToHashTable()); + } + return buddyArray; + } + + public class BuddyInfo + { + public int BuddyRightsHave = 1; + public int BuddyRightsGiven = 1; + public UUID BuddyID; + + public BuddyInfo(string buddyID) + { + BuddyID = new UUID(buddyID); + } + + public BuddyInfo(UUID buddyID) + { + BuddyID = buddyID; + } + + public Hashtable ToHashTable() + { + Hashtable hTable = new Hashtable(); + hTable["buddy_rights_has"] = BuddyRightsHave; + hTable["buddy_rights_given"] = BuddyRightsGiven; + hTable["buddy_id"] = BuddyID.ToString(); + return hTable; + } + } + } + } +} diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs new file mode 100644 index 0000000..51158c9 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -0,0 +1,1093 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading; +using System.Web; +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Statistics; + +namespace OpenSim.Framework.Communications.Services +{ + public abstract class LoginService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected int m_minLoginLevel = 0; + protected UserManagerBase m_userManager = null; + protected Mutex m_loginMutex = new Mutex(false); + + /// + /// Used during login to send the skeleton of the OpenSim Library to the client. + /// + protected LibraryRootFolder m_libraryRootFolder; + + protected uint m_defaultHomeX; + protected uint m_defaultHomeY; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_inventoryService; + + /// + /// Constructor + /// + /// + /// + /// + public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, + string welcomeMess) + { + m_userManager = userManager; + m_libraryRootFolder = libraryRootFolder; + + if (welcomeMess != String.Empty) + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// If the user is already logged in, try to notify the region that the user they've got is dead. + /// + /// + public virtual void LogOffUser(UserProfileData theUser, string message) + { + } + + + /// + /// Called when we receive the client's initial XMLRPC login_to_simulator request message + /// + /// The XMLRPC request + /// The response to send + public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + // Temporary fix + m_loginMutex.WaitOne(); + + try + { + //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. + //CKF: m_log.Info("[LOGIN]: Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + SniffLoginKey((Uri)request.Params[2], requestData); + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && + (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); + + string startLocationRequest = "last"; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + string firstname; + string lastname; + + if (GoodXML) + { + if (requestData.Contains("start")) + { + startLocationRequest = (string)requestData["start"]; + } + + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + + m_log.InfoFormat( + "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", + firstname, lastname); + + string clientVersion = "Unknown"; + + if (requestData.Contains("version")) + { + clientVersion = (string)requestData["version"]; + } + + m_log.DebugFormat( + "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); + + if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) + { + return logResponse.CreateLoginFailedResponse(); + } + } + else + { + m_log.Info( + "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); + + return logResponse.CreateGridErrorResponse(); + } + + if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponse(); + } + else + { + // If we already have a session... + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) + { + //TODO: The following statements can cause trouble: + // If agentOnline could not turn from true back to false normally + // because of some problem, for instance, the crashment of server or client, + // the user cannot log in any longer. + userProfile.CurrentAgent.AgentOnline = false; + + m_userManager.CommitAgent(ref userProfile); + + // try to tell the region that their user is dead. + LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); + + // Reject the login + + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", + firstname, lastname); + + return logResponse.CreateAlreadyLoggedInResponse(); + } + + // Otherwise... + // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + + CreateAgent(userProfile, request); + + try + { + UUID agentID = userProfile.ID; + InventoryData inventData; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", + agentID, e); + + return logResponse.CreateLoginInventoryFailedResponse(); + } + + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderID = inventData.RootFolderID; + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + + logResponse.CircuitCode = Util.RandomClass.Next(); + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; + logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; + + if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) + { + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + + return logResponse.ToXmlRpcResponse(); + } + else + { + m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); + return logResponse.CreateDeadRegionResponse(); + } + } + catch (Exception e) + { + m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); + m_log.Error(e.StackTrace); + } + } + + m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); + return response; + } + finally + { + m_loginMutex.ReleaseMutex(); + } + } + + protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodLogin = false; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); + } + else + { + if (requestData.Contains("passwd")) + { + string passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(userProfile, passwd); + } + if (!GoodLogin && (requestData.Contains("web_login_key"))) + { + try + { + UUID webloginkey = new UUID((string)requestData["web_login_key"]); + GoodLogin = AuthenticateUser(userProfile, webloginkey); + } + catch (Exception e) + { + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); + } + } + } + + return GoodLogin; + } + + protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) + { + bool GoodLogin = false; + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); + + return false; + } + + GoodLogin = AuthenticateUser(userProfile, passwd); + return GoodLogin; + } + + /// + /// Called when we receive the client's initial LLSD login_to_simulator request message + /// + /// The LLSD request + /// The response to send + public OSD LLSDLoginMethod(OSD request) + { + // Temporary fix + m_loginMutex.WaitOne(); + + try + { + // bool GoodLogin = false; + + string startLocationRequest = "last"; + + UserProfileData userProfile = null; + LoginResponse logResponse = new LoginResponse(); + + if (request.Type == OSDType.Map) + { + OSDMap map = (OSDMap)request; + + if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) + { + string firstname = map["first"].AsString(); + string lastname = map["last"].AsString(); + string passwd = map["passwd"].AsString(); + + if (map.ContainsKey("start")) + { + m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); + startLocationRequest = map["start"].AsString(); + } + m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); + + if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) + { + return logResponse.CreateLoginFailedResponseLLSD(); + } + } + else + return logResponse.CreateLoginFailedResponseLLSD(); + } + else + return logResponse.CreateLoginFailedResponseLLSD(); + + + if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponseLLSD(); + } + else + { + // If we already have a session... + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) + { + userProfile.CurrentAgent.AgentOnline = false; + + m_userManager.CommitAgent(ref userProfile); + // try to tell the region that their user is dead. + LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); + + // Reject the login + + m_log.InfoFormat( + "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", + userProfile.FirstName, userProfile.SurName); + + userProfile.CurrentAgent = null; + return logResponse.CreateAlreadyLoggedInResponseLLSD(); + } + + // Otherwise... + // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + + CreateAgent(userProfile, request); + + try + { + UUID agentID = userProfile.ID; + + //InventoryData inventData = GetInventorySkeleton(agentID); + InventoryData inventData = null; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", + agentID, e.GetType(), e.Message); + + return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); + } + + + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderID = inventData.RootFolderID; + + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + + logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; + logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; + + try + { + CustomiseResponse(logResponse, userProfile, startLocationRequest); + } + catch (Exception ex) + { + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); + return logResponse.CreateDeadRegionResponseLLSD(); + } + + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", + userProfile.FirstName, userProfile.SurName); + + return logResponse.ToLLSDResponse(); + } + catch (Exception ex) + { + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); + return logResponse.CreateFailedResponseLLSD(); + } + } + } + finally + { + m_loginMutex.ReleaseMutex(); + } + } + + public Hashtable ProcessHTMLLogin(Hashtable keysvals) + { + // Matches all unspecified characters + // Currently specified,; lowercase letters, upper case letters, numbers, underline + // period, space, parens, and dash. + + Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); + + Hashtable returnactions = new Hashtable(); + int statuscode = 200; + + string firstname = String.Empty; + string lastname = String.Empty; + string location = String.Empty; + string region = String.Empty; + string grid = String.Empty; + string channel = String.Empty; + string version = String.Empty; + string lang = String.Empty; + string password = String.Empty; + string errormessages = String.Empty; + + // the client requires the HTML form field be named 'username' + // however, the data it sends when it loads the first time is 'firstname' + // another one of those little nuances. + + if (keysvals.Contains("firstname")) + firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); + + if (keysvals.Contains("username")) + firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); + + if (keysvals.Contains("lastname")) + lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); + + if (keysvals.Contains("location")) + location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); + + if (keysvals.Contains("region")) + region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); + + if (keysvals.Contains("grid")) + grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); + + if (keysvals.Contains("channel")) + channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); + + if (keysvals.Contains("version")) + version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); + + if (keysvals.Contains("lang")) + lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); + + if (keysvals.Contains("password")) + password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); + + // load our login form. + string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + + if (keysvals.ContainsKey("show_login_form")) + { + UserProfileData user = GetTheUser(firstname, lastname); + bool goodweblogin = false; + + if (user != null) + goodweblogin = AuthenticateUser(user, password); + + if (goodweblogin) + { + UUID webloginkey = UUID.Random(); + m_userManager.StoreWebLoginKey(user.ID, webloginkey); + //statuscode = 301; + + // string redirectURL = "about:blank?redirect-http-hack=" + + // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + // lastname + + // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + //m_log.Info("[WEB]: R:" + redirectURL); + returnactions["int_response_code"] = statuscode; + //returnactions["str_redirect_location"] = redirectURL; + //returnactions["str_response_string"] = "GoodLogin"; + returnactions["str_response_string"] = webloginkey.ToString(); + } + else + { + errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; + + loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; + } + } + else + { + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; + } + return returnactions; + } + + public string GetLoginForm(string firstname, string lastname, string location, string region, + string grid, string channel, string version, string lang, + string password, string errormessages) + { + // inject our values in the form at the markers + + string loginform = String.Empty; + string file = Path.Combine(Util.configDir(), "http_loginform.html"); + if (!File.Exists(file)) + { + loginform = GetDefaultLoginForm(); + } + else + { + StreamReader sr = File.OpenText(file); + loginform = sr.ReadToEnd(); + sr.Close(); + } + + loginform = loginform.Replace("[$firstname]", firstname); + loginform = loginform.Replace("[$lastname]", lastname); + loginform = loginform.Replace("[$location]", location); + loginform = loginform.Replace("[$region]", region); + loginform = loginform.Replace("[$grid]", grid); + loginform = loginform.Replace("[$channel]", channel); + loginform = loginform.Replace("[$version]", version); + loginform = loginform.Replace("[$lang]", lang); + loginform = loginform.Replace("[$password]", password); + loginform = loginform.Replace("[$errors]", errormessages); + + return loginform; + } + + public string GetDefaultLoginForm() + { + string responseString = + ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "OpenSim Login"; + responseString += "
"; + responseString += "
"; + + responseString += "
"; + + responseString += "
[$errors]
"; + responseString += "
"; + responseString += "First Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Last Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Password:"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += ""; + responseString += "
"; + responseString += "
Connecting...
"; + + responseString += "
"; + + responseString += "
[$channel] | [$version]=[$lang]
"; + responseString += "
"; + responseString += ""; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + + return responseString; + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + return m_userManager.CommitAgent(ref profile); + } + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + bool passwordSuccess = false; + //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); + + // Web Login method seems to also occasionally send the hashed password itself + + // we do this to get our hash in a form that the server password code can consume + // when the web-login-form submits the password in the clear (supposed to be over SSL!) + if (!password.StartsWith("$1$")) + password = "$1$" + Util.Md5Hash(password); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + // Testing... + //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); + //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); + + passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + + return passwordSuccess; + } + + public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) + { + bool passwordSuccess = false; + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); + + // Match web login key unless it's the default weblogin key UUID.Zero + passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); + + return passwordSuccess; + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + m_userManager.CreateAgent(profile, request); + } + + public void CreateAgent(UserProfileData profile, OSD request) + { + m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) + { + LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); + foreach (FriendListItem fl in LFL) + { + LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); + buddyitem.BuddyID = fl.Friend; + buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; + buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; + buddylistreturn.AddNewBuddy(buddyitem); + } + return buddylistreturn; + } + + /// + /// Converts the inventory library skeleton into the form required by the rpc request. + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + Dictionary rootFolders + = m_libraryRootFolder.RequestSelfAndDescendentFolders(); + ArrayList folderHashes = new ArrayList(); + + foreach (InventoryFolderBase folder in rootFolders.Values) + { + Hashtable TempHash = new Hashtable(); + TempHash["name"] = folder.Name; + TempHash["parent_id"] = folder.ParentID.ToString(); + TempHash["version"] = (Int32)folder.Version; + TempHash["type_default"] = (Int32)folder.Type; + TempHash["folder_id"] = folder.ID.ToString(); + folderHashes.Add(TempHash); + } + + return folderHashes; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public UUID RootFolderID = UUID.Zero; + + public InventoryData(ArrayList invList, UUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + + protected void SniffLoginKey(Uri uri, Hashtable requestData) + { + string uri_str = uri.ToString(); + string[] parts = uri_str.Split(new char[] { '=' }); + if (parts.Length > 1) + { + string web_login_key = parts[1]; + requestData.Add("web_login_key", web_login_key); + m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); + } + } + + /// + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. + /// + /// The existing response + /// The user profile + /// The requested start location + /// true on success, false if the region was not successfully told to expect a user connection + public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + { + // add active gestures to login-response + AddActiveGestures(response, theUser); + + // HomeLocation + RegionInfo homeInfo = null; + + // use the homeRegionID if it is stored already. If not, use the regionHandle as before + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } + else + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + + if (homeInfo != null) + { + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + (homeInfo.RegionLocX * Constants.RegionSize), + (homeInfo.RegionLocY * Constants.RegionSize), + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + } + else + { + m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); + // Emergency mode: Home-region isn't available, so we can't request the region info. + // Use the stored home regionHandle instead. + // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + regionX, regionY, + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + + m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", + theUser.FirstName, theUser.SurName, + regionX, regionY); + } + + // StartLocation + RegionInfo regionInfo = null; + if (startLocationRequest == "home") + { + regionInfo = homeInfo; + theUser.CurrentAgent.Position = theUser.HomeLocation; + response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + } + else if (startLocationRequest == "last") + { + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); + response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + } + else + { + Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); + Match uriMatch = reURI.Match(startLocationRequest); + if (uriMatch == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); + } + else + { + string region = uriMatch.Groups["region"].ToString(); + regionInfo = RequestClosestRegion(region); + if (regionInfo == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); + } + else + { + theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), + float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); + } + } + response.LookAt = "[r0,r1,r0]"; + // can be: last, home, safe, url + response.StartLocation = "url"; + } + + if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) + { + return true; + } + + // StartLocation not available, send him to a nearby region instead + // regionInfo = m_gridService.RequestClosestRegion(""); + //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + + // Send him to default region instead + ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | + ((ulong)m_defaultHomeY * Constants.RegionSize); + + if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + { + m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); + return false; + } + + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); + + if (regionInfo == null) + { + m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); + return false; + } + + theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + response.StartLocation = "safe"; + + return PrepareLoginToRegion(regionInfo, theUser, response); + } + + protected abstract RegionInfo RequestClosestRegion(string region); + protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); + protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); + protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); + + /// + /// Add active gestures of the user to the login response. + /// + /// + /// A + /// + /// + /// A + /// + protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) + { + List gestures = m_inventoryService.GetActiveGestures(theUser.ID); + //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); + ArrayList list = new ArrayList(); + if (gestures != null) + { + foreach (InventoryItemBase gesture in gestures) + { + Hashtable item = new Hashtable(); + item["item_id"] = gesture.ID.ToString(); + item["asset_id"] = gesture.AssetID.ToString(); + list.Add(item); + } + } + response.ActiveGestures = list; + } + + /// + /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. + /// + /// + /// + /// This will be thrown if there is a problem with the inventory service + protected InventoryData GetInventorySkeleton(UUID userID) + { + List folders = m_inventoryService.GetInventorySkeleton(userID); + + // If we have user auth but no inventory folders for some reason, create a new set of folders. + if (folders == null || folders.Count == 0) + { + m_log.InfoFormat( + "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); + + // Although the create user function creates a new agent inventory along with a new user profile, some + // tools are creating the user profile directly in the database without creating the inventory. At + // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already + // exist. + if (!m_inventoryService.CreateNewUserInventory(userID)) + { + throw new Exception( + String.Format( + "The inventory creation request for user {0} did not succeed." + + " Please contact your inventory service provider for more information.", + userID)); + } + + m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); + + folders = m_inventoryService.GetInventorySkeleton(userID); + + if (folders == null || folders.Count == 0) + { + throw new Exception( + String.Format( + "A root inventory folder for user {0} could not be retrieved from the inventory service", + userID)); + } + } + + UUID rootID = UUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.ParentID == UUID.Zero) + { + rootID = InvFolder.ID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.Name; + TempHash["parent_id"] = InvFolder.ParentID.ToString(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.Type; + TempHash["folder_id"] = InvFolder.ID.ToString(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, rootID); + } + } +} diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index ca25922..303efe1 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -34,6 +34,7 @@ using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Services; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; using OpenSim.Client.Linden; -- cgit v1.1 From c3e604c46c04673a9493251ef63daf9437e37a10 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 29 Mar 2009 23:39:00 +0000 Subject: Added Authorization client code that interfaces with HGLoginAuthService. Improved error handling in HGLoginAuthService. Instrumented HGInventoryService so that it can interface both with local and remote user and asset services. --- .../Framework/Communications/Clients/AuthClient.cs | 108 +++++++++++++++++++++ .../Communications/Services/HGInventoryService.cs | 73 ++++++++++++-- .../Communications/Services/HGLoginAuthService.cs | 32 +++--- 3 files changed, 192 insertions(+), 21 deletions(-) create mode 100644 OpenSim/Framework/Communications/Clients/AuthClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs new file mode 100644 index 0000000..95af7e1 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -0,0 +1,108 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using Nwc.XmlRpc; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Clients +{ + public class AuthClient + { + public static string GetNewKey(string authurl, UUID userID, UUID authToken) + { + //Hashtable keyParams = new Hashtable(); + //keyParams["user_id"] = userID; + //keyParams["auth_token"] = authKey; + + List SendParams = new List(); + SendParams.Add(userID.ToString()); + SendParams.Add(authToken.ToString()); + + XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(authurl, 6000); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); + return string.Empty; + } + + if (!reply.IsFault) + { + string newKey = string.Empty; + if (reply.Value != null) + newKey = (string)reply.Value; + + return newKey; + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + return string.Empty; + } + + } + + public static bool VerifyKey(string authurl, UUID userID, string authKey) + { + List SendParams = new List(); + SendParams.Add(userID.ToString()); + SendParams.Add(authKey); + + XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(authurl, 6000); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); + return false; + } + + if (!reply.IsFault) + { + bool success = false; + if (reply.Value != null) + success = (bool)reply.Value; + + return success; + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + return false; + } + } + } +} diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index 33d7722..eef9e80 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -35,7 +35,7 @@ using Nini.Config; using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework; -//using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Clients; using OpenSim.Framework.Communications.Cache; using Caps = OpenSim.Framework.Communications.Capabilities.Caps; using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; @@ -64,6 +64,7 @@ namespace OpenSim.Framework.Communications.Services // These two used for remote access string m_UserServerURL = string.Empty; string m_AssetServerURL = string.Empty; + SynchronousGridAssetClient m_AssetClient = null; // Constructor for grid inventory server public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) @@ -71,6 +72,8 @@ namespace OpenSim.Framework.Communications.Services m_UserServerURL = userServiceURL; m_AssetServerURL = assetServiceURL; + m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); + Init(invService, thisurl, httpserver); } @@ -298,7 +301,7 @@ namespace OpenSim.Framework.Communications.Services Item.Owner = olditem.Owner; // There should be some tests here about the owner, etc but I'm going to ignore that // because I'm not sure it makes any sense - // Also I should probably close the asset... + // Also I should probably clone the asset... m_inventoryService.AddItem(Item); return Item; } @@ -319,7 +322,7 @@ namespace OpenSim.Framework.Communications.Services public List GetInventorySkeleton(Guid rawUserID) { UUID userID = new UUID(rawUserID); - return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); + return m_inventoryService.GetInventorySkeleton(userID); } public List GetActiveGestures(Guid rawUserID) @@ -328,7 +331,7 @@ namespace OpenSim.Framework.Communications.Services m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); - return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); + return m_inventoryService.GetActiveGestures(userID); } public AssetBase GetAsset(InventoryItemBase item) @@ -348,8 +351,10 @@ namespace OpenSim.Framework.Communications.Services } // All good, get the asset - AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); - m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null)? "NULL" : "Not Null")); + //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); + AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); + + m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); if (theasset != null) { asset = theasset; @@ -361,7 +366,8 @@ namespace OpenSim.Framework.Communications.Services public bool PostAsset(AssetBase asset) { m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); - m_assetProvider.CreateAsset(asset); + //m_assetProvider.CreateAsset(asset); + StoreAsset(asset); return true; } @@ -492,7 +498,7 @@ namespace OpenSim.Framework.Communications.Services return; } - bool success = ((IAuthentication)m_userService).VerifyKey(userID, authToken); + bool success = VerifyKey(userID, authToken); if (success) { @@ -653,5 +659,56 @@ namespace OpenSim.Framework.Communications.Services } #endregion Caps + + #region Local vs Remote + + bool VerifyKey(UUID userID, string key) + { + // Remote call to the Authorization server + if (m_userService == null) + return AuthClient.VerifyKey(m_UserServerURL, userID, key); + // local call + else + return ((IAuthentication)m_userService).VerifyKey(userID, key); + } + + AssetBase FetchAsset(UUID assetID, bool isTexture) + { + // Remote call to the Asset server + if (m_assetProvider == null) + return m_AssetClient.SyncGetAsset(assetID, isTexture); + // local call + else + return m_assetProvider.FetchAsset(assetID); + } + + void StoreAsset(AssetBase asset) + { + // Remote call to the Asset server + if (m_assetProvider == null) + m_AssetClient.StoreAsset(asset); + // local call + else + m_assetProvider.CreateAsset(asset); + } + + #endregion Local vs Remote + } + + class SynchronousGridAssetClient : GridAssetClient + { + public SynchronousGridAssetClient(string url) + : base(url) + { + } + + public AssetBase SyncGetAsset(UUID assetID, bool isTexture) + { + AssetRequest assReq = new AssetRequest(); + assReq.AssetID = assetID; + assReq.IsTexture = isTexture; + return base.GetAsset(assReq); + } + } } diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 37c8846..cd4ca5c 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -169,22 +169,28 @@ namespace OpenSim.Framework.Communications.Services m_log.Debug(" >> Null"); } - // Verify the key of who's calling - UUID userID = UUID.Zero; - string authKey = string.Empty; - UUID.TryParse((string)request.Params[0], out userID); - authKey = (string)request.Params[1]; - - m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); bool success = false; - if (!(m_userManager is IAuthentication)) + if (request.Params.Count >= 2) { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); - } - else - { - success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); + // Verify the key of who's calling + UUID userID = UUID.Zero; + string authKey = string.Empty; + if (UUID.TryParse((string)request.Params[0], out userID)) + { + authKey = (string)request.Params[1]; + + m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); + } + else + { + success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); + } + } } XmlRpcResponse response = new XmlRpcResponse(); -- cgit v1.1 From 695780375924693105aa9b5a06bfe81a28393373 Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 30 Mar 2009 17:34:36 +0000 Subject: Sigh. Manual data typing grief. --- .../Framework/Communications/Clients/AuthClient.cs | 22 +++++++++++++++------- .../Communications/Services/HGInventoryService.cs | 3 ++- .../Communications/Services/HGLoginAuthService.cs | 13 +++---------- 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 95af7e1..ba5cf66 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -82,7 +82,7 @@ namespace OpenSim.Framework.Communications.Clients XmlRpcResponse reply; try { - reply = request.Send(authurl, 6000); + reply = request.Send(authurl, 10000); } catch (Exception e) { @@ -90,17 +90,25 @@ namespace OpenSim.Framework.Communications.Clients return false; } - if (!reply.IsFault) + if (reply != null) { - bool success = false; - if (reply.Value != null) - success = (bool)reply.Value; + if (!reply.IsFault) + { + bool success = false; + if (reply.Value != null) + success = (bool)reply.Value; - return success; + return success; + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + return false; + } } else { - System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); return false; } } diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index eef9e80..b01c30e 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -490,7 +490,7 @@ namespace OpenSim.Framework.Communications.Services // This is the meaning of POST agent // Check Auth Token - if (!(m_userService is IAuthentication)) + if ((m_userService != null) && !(m_userService is IAuthentication)) { m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); responsedata["int_response_code"] = 501; @@ -499,6 +499,7 @@ namespace OpenSim.Framework.Communications.Services } bool success = VerifyKey(userID, authToken); + m_log.Debug("[HGStandaloneInvService]: Key verification returned " + success); if (success) { diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index cd4ca5c..72e2dfb 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -161,14 +161,6 @@ namespace OpenSim.Framework.Communications.Services public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) { - foreach (object o in request.Params) - { - if (o != null) - m_log.Debug(" >> Param " + o.ToString()); - else - m_log.Debug(" >> Null"); - } - bool success = false; if (request.Params.Count >= 2) @@ -180,7 +172,7 @@ namespace OpenSim.Framework.Communications.Services { authKey = (string)request.Params[1]; - m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key ", authKey); + m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); if (!(m_userManager is IAuthentication)) { @@ -193,8 +185,9 @@ namespace OpenSim.Framework.Communications.Services } } + m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); XmlRpcResponse response = new XmlRpcResponse(); - response.Value = (string)success.ToString(); + response.Value = success; return response; } -- cgit v1.1 From 4cbf963354128f6d30e28ea68fe06a85ba5790c5 Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 30 Mar 2009 19:26:25 +0000 Subject: HGInventoryService now uses the actual authority portion of the user's key to verify the key. --- .../Framework/Communications/Clients/AuthClient.cs | 234 ++-- .../Communications/Services/HGInventoryService.cs | 1429 ++++++++++---------- .../Communications/Services/HGLoginAuthService.cs | 656 ++++----- 3 files changed, 1160 insertions(+), 1159 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index ba5cf66..39a886c 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -1,116 +1,118 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using Nwc.XmlRpc; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Clients -{ - public class AuthClient - { - public static string GetNewKey(string authurl, UUID userID, UUID authToken) - { - //Hashtable keyParams = new Hashtable(); - //keyParams["user_id"] = userID; - //keyParams["auth_token"] = authKey; - - List SendParams = new List(); - SendParams.Add(userID.ToString()); - SendParams.Add(authToken.ToString()); - - XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); - XmlRpcResponse reply; - try - { - reply = request.Send(authurl, 6000); - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); - return string.Empty; - } - - if (!reply.IsFault) - { - string newKey = string.Empty; - if (reply.Value != null) - newKey = (string)reply.Value; - - return newKey; - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); - return string.Empty; - } - - } - - public static bool VerifyKey(string authurl, UUID userID, string authKey) - { - List SendParams = new List(); - SendParams.Add(userID.ToString()); - SendParams.Add(authKey); - - XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); - XmlRpcResponse reply; - try - { - reply = request.Send(authurl, 10000); - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); - return false; - } - - if (reply != null) - { - if (!reply.IsFault) - { - bool success = false; - if (reply.Value != null) - success = (bool)reply.Value; - - return success; - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); - return false; - } - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); - return false; - } - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using Nwc.XmlRpc; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Clients +{ + public class AuthClient + { + public static string GetNewKey(string authurl, UUID userID, UUID authToken) + { + //Hashtable keyParams = new Hashtable(); + //keyParams["user_id"] = userID; + //keyParams["auth_token"] = authKey; + + List SendParams = new List(); + SendParams.Add(userID.ToString()); + SendParams.Add(authToken.ToString()); + + XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(authurl, 6000); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); + return string.Empty; + } + + if (!reply.IsFault) + { + string newKey = string.Empty; + if (reply.Value != null) + newKey = (string)reply.Value; + + return newKey; + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + return string.Empty; + } + + } + + public static bool VerifyKey(string authurl, UUID userID, string authKey) + { + List SendParams = new List(); + SendParams.Add(userID.ToString()); + SendParams.Add(authKey); + + System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl); + + XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); + XmlRpcResponse reply; + try + { + reply = request.Send(authurl, 10000); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); + return false; + } + + if (reply != null) + { + if (!reply.IsFault) + { + bool success = false; + if (reply.Value != null) + success = (bool)reply.Value; + + return success; + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); + return false; + } + } + else + { + System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); + return false; + } + } + } +} diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index b01c30e..7eaed89 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -1,715 +1,714 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * 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 Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Clients; -using OpenSim.Framework.Communications.Cache; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; -using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.Interfaces; - -using OpenMetaverse.StructuredData; - -namespace OpenSim.Framework.Communications.Services -{ - public class HGInventoryService - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private InventoryServiceBase m_inventoryService; - IHttpServer httpServer; - private string m_thisInventoryUrl = "http://localhost:9000"; - private string m_thisHostname = "127.0.0.1"; - private uint m_thisPort = 9000; - - // These two used for local access, standalone mode - private UserManagerBase m_userService = null; - IAssetDataPlugin m_assetProvider = null; - - // These two used for remote access - string m_UserServerURL = string.Empty; - string m_AssetServerURL = string.Empty; - SynchronousGridAssetClient m_AssetClient = null; - - // Constructor for grid inventory server - public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) - { - m_UserServerURL = userServiceURL; - m_AssetServerURL = assetServiceURL; - - m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); - - Init(invService, thisurl, httpserver); - } - - // Constructor for standalone mode - public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) - { - m_userService = userService; - m_assetProvider = assetService; - - Init(invService, thisurl, httpserver); - } - - private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) - { - m_inventoryService = invService; - m_thisInventoryUrl = thisurl; - if (!m_thisInventoryUrl.EndsWith("/")) - m_thisInventoryUrl += "/"; - - Uri uri = new Uri(m_thisInventoryUrl); - if (uri != null) - { - m_thisHostname = uri.Host; - m_thisPort = (uint)uri.Port; - } - - httpServer = httpserver; - - AddHttpHandlers(); - } - - public virtual void AddHttpHandlers() - { - httpServer.AddHTTPHandler("/InvCap/", CapHandler); - } - - public bool CheckAuthSession(string session_id, string avatar_id) - { - return true; - } - - - // In truth, this is not called from the outside, for standalones. I'm just making it - // a handler already so that this can be reused for the InventoryServer. - public string CreateCapUrl(Guid _userid) - { - UUID userID = new UUID(_userid); - UUID random = UUID.Random(); - string url = m_thisInventoryUrl + random.ToString() + "/"; - m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); - return url; - } - - /// - /// Return a user's entire inventory - /// - /// - /// The user's inventory. If an inventory cannot be found then an empty collection is returned. - public InventoryCollection GetUserInventory(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List allFolders = m_inventoryService.GetInventorySkeleton(userID); - - if (null == allFolders) - { - m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); - - return invCollection; - } - - List allItems = new List(); - - foreach (InventoryFolderBase folder in allFolders) - { - List items = m_inventoryService.RequestFolderItems(folder.ID); - - if (items != null) - { - allItems.InsertRange(0, items); - } - } - - invCollection.UserID = userID; - invCollection.Folders = allFolders; - invCollection.Items = allItems; - - // foreach (InventoryFolderBase folder in invCollection.Folders) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); - // } - // - // foreach (InventoryItemBase item in invCollection.Items) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); - // } - - m_log.InfoFormat( - "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", - invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); - - return invCollection; - } - - public InventoryCollection FetchDescendants(InventoryFolderBase fb) - { - m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List items = m_inventoryService.RequestFolderItems(fb.ID); - List folders = m_inventoryService.RequestSubFolders(fb.ID); - - invCollection.UserID = fb.Owner; - invCollection.Folders = folders; - invCollection.Items = items; - - m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); - - return invCollection; - } - - public bool RemoveFolder(InventoryFolderBase folder) - { - m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); - return false; - } - - public InventoryItemBase GetInventoryItem(InventoryItemBase item) - { - m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); - - item = m_inventoryService.GetInventoryItem(item.ID); - if (item == null) - m_log.Debug("[HGStandaloneInvService]: null item"); - return item; - } - - public InventoryItemBase AddItem(InventoryItemBase item) - { - m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); - if (m_inventoryService.AddItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public InventoryItemBase UpdateItem(InventoryItemBase item) - { - m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); - InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); - item.CurrentPermissions = it.CurrentPermissions; - item.AssetID = it.AssetID; - if (m_inventoryService.UpdateItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public InventoryItemBase MoveItem(InventoryItemBase newitem) - { - m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); - InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); - if (Item != null) - { - if (newitem.Name != String.Empty) - { - Item.Name = newitem.Name; - } - Item.Folder = newitem.Folder; - m_inventoryService.UpdateItem(Item); - return Item; - } - else - { - m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); - newitem.ID = UUID.Zero; - return newitem; - } - - } - - public InventoryItemBase DeleteItem(InventoryItemBase item) - { - item = m_inventoryService.GetInventoryItem(item.ID); - if (m_inventoryService.DeleteItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public InventoryItemBase CopyItem(InventoryItemBase olditem) - { - m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); - InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id - // BIG HACK here - UUID newID = olditem.AssetID; - if (Item != null) - { - if (olditem.Name != String.Empty) - { - Item.Name = olditem.Name; - } - Item.ID = newID; - Item.Folder = olditem.Folder; - Item.Owner = olditem.Owner; - // There should be some tests here about the owner, etc but I'm going to ignore that - // because I'm not sure it makes any sense - // Also I should probably clone the asset... - m_inventoryService.AddItem(Item); - return Item; - } - else - { - m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); - olditem.ID = UUID.Zero; - return olditem; - } - - } - - /// - /// Guid to UUID wrapper for same name IInventoryServices method - /// - /// - /// - public List GetInventorySkeleton(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - return m_inventoryService.GetInventorySkeleton(userID); - } - - public List GetActiveGestures(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); - - return m_inventoryService.GetActiveGestures(userID); - } - - public AssetBase GetAsset(InventoryItemBase item) - { - m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); - AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data - InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); - if (item2 == null) - { - m_log.Debug("[HGStandaloneInvService]: null item"); - return asset; - } - if (item2.Owner != item.Owner) - { - m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); - return asset; - } - - // All good, get the asset - //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); - AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); - - m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); - if (theasset != null) - { - asset = theasset; - //m_log.Debug(" >> Sending assetID " + item.AssetID); - } - return asset; - } - - public bool PostAsset(AssetBase asset) - { - m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); - //m_assetProvider.CreateAsset(asset); - StoreAsset(asset); - - return true; - } - - /// - /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) - /// - public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) - { - m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); - InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); - - if (item != null) - { - // We're still not dealing with permissions - //if ((InventoryType)item.InvType == InventoryType.Notecard) - //{ - // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) - // { - // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); - // return UUID.Zero; - // } - - // //remoteClient.SendAgentAlertMessage("Notecard saved", false); - //} - //else if ((InventoryType)item.InvType == InventoryType.LSL) - //{ - // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) - // { - // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); - // return UUID.Zero; - // } - - // //remoteClient.SendAgentAlertMessage("Script saved", false); - //} - - AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); - PostAsset(asset); - - item.AssetID = asset.FullID; - item.Owner = userID; - m_inventoryService.UpdateItem(item); - - return (asset.FullID); - } - return UUID.Zero; - } - - private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) - { - AssetBase asset = new AssetBase(); - asset.Name = name; - asset.Description = description; - asset.Type = assetType; - asset.FullID = UUID.Random(); - asset.Data = (data == null) ? new byte[1] : data; - - return asset; - } - - #region Caps - - Dictionary invCaps = new Dictionary(); - - public Hashtable CapHandler(Hashtable request) - { - m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); - - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); - - // these are requests if the type - // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ - - Hashtable responsedata = new Hashtable(); - responsedata["content_type"] = "text/plain"; - - UUID userID; - string authToken = string.Empty; - string authority = string.Empty; - if (!GetParams(request, out userID, out authority, out authToken)) - { - m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "Not found"; - - return responsedata; - } - - // Next, let's parse the verb - string method = (string)request["http-method"]; - if (method.Equals("GET")) - { - DoInvCapPost(request, responsedata, userID, authToken); - return responsedata; - } - //else if (method.Equals("DELETE")) - //{ - // DoAgentDelete(request, responsedata, agentID, action, regionHandle); - - // return responsedata; - //} - else - { - m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); - responsedata["int_response_code"] = 405; - responsedata["str_response_string"] = "Method not allowed"; - - return responsedata; - } - - } - - public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authToken) - { - - // This is the meaning of POST agent - - // Check Auth Token - if ((m_userService != null) && !(m_userService is IAuthentication)) - { - m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); - responsedata["int_response_code"] = 501; - responsedata["str_response_string"] = "Not implemented"; - return; - } - - bool success = VerifyKey(userID, authToken); - m_log.Debug("[HGStandaloneInvService]: Key verification returned " + success); - - if (success) - { - - m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); - - // Then establish secret service handlers - - Hashtable usercaps = RegisterCaps(userID, authToken); - - responsedata["int_response_code"] = 200; - //responsedata["str_response_string"] = "OK"; - responsedata["str_response_string"] = SerializeHashtable(usercaps); - } - else - { - m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); - responsedata["int_response_code"] = 403; - responsedata["str_response_string"] = "Forbidden"; - } - } - - - /// - /// Extract the params from a request. - /// - public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) - { - uuid = UUID.Zero; - authority = string.Empty; - authKey = string.Empty; - - string uri = (string)request["uri"]; - uri = uri.Trim(new char[] { '/' }); - string[] parts = uri.Split('/'); - if (parts.Length <= 1) - { - return false; - } - else - { - if (!UUID.TryParse(parts[1], out uuid)) - return false; - - if (parts.Length >= 3) - { - authKey = parts[2]; - return true; - } - } - - Uri authUri; - Hashtable headers = (Hashtable)request["headers"]; - - // Authorization keys look like this: - // http://orgrid.org:8002/ - if (headers.ContainsKey("authorization")) - { - if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) - { - authority = authUri.Authority; - authKey = authUri.PathAndQuery.Trim('/'); - m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); - return true; - } - else - m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); - } - else - m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); - - return false; - } - - string SerializeHashtable(Hashtable hash) - { - string result = string.Empty; - foreach (object key in hash.Keys) - { - result += key.ToString() + "," + hash[key].ToString() + ";"; - } - return result; - } - - Hashtable RegisterCaps(UUID userID, string authToken) - { - lock (invCaps) - { - if (invCaps.ContainsKey(userID)) - { - // Remove the old ones - DeregisterCaps(httpServer, invCaps[userID]); - invCaps.Remove(userID); - } - } - - Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); - caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); - caps.ItemUpdatedCall = UpdateInventoryItemAsset; - Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); - - lock (invCaps) - invCaps.Add(userID, capsHandlers); - - return capsHandlers; - } - - string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) - { - string capUrl = "/" + authToken + "/" + capType + "/"; - - m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); - caps.Add(capType, capUrl); - return capUrl; - } - - void DeregisterCaps(IHttpServer httpServer, Hashtable caps) - { - foreach (string capUrl in caps.Values) - { - m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); - httpServer.RemoveStreamHandler("POST", capUrl); - } - } - - #endregion Caps - - #region Local vs Remote - - bool VerifyKey(UUID userID, string key) - { - // Remote call to the Authorization server - if (m_userService == null) - return AuthClient.VerifyKey(m_UserServerURL, userID, key); - // local call - else - return ((IAuthentication)m_userService).VerifyKey(userID, key); - } - - AssetBase FetchAsset(UUID assetID, bool isTexture) - { - // Remote call to the Asset server - if (m_assetProvider == null) - return m_AssetClient.SyncGetAsset(assetID, isTexture); - // local call - else - return m_assetProvider.FetchAsset(assetID); - } - - void StoreAsset(AssetBase asset) - { - // Remote call to the Asset server - if (m_assetProvider == null) - m_AssetClient.StoreAsset(asset); - // local call - else - m_assetProvider.CreateAsset(asset); - } - - #endregion Local vs Remote - } - - class SynchronousGridAssetClient : GridAssetClient - { - public SynchronousGridAssetClient(string url) - : base(url) - { - } - - public AssetBase SyncGetAsset(UUID assetID, bool isTexture) - { - AssetRequest assReq = new AssetRequest(); - assReq.AssetID = assetID; - assReq.IsTexture = isTexture; - return base.GetAsset(assReq); - } - - } -} +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * 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 Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Clients; +using OpenSim.Framework.Communications.Cache; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; +using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.Interfaces; + +using OpenMetaverse.StructuredData; + +namespace OpenSim.Framework.Communications.Services +{ + public class HGInventoryService + { + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private InventoryServiceBase m_inventoryService; + IHttpServer httpServer; + private string m_thisInventoryUrl = "http://localhost:9000"; + private string m_thisHostname = "127.0.0.1"; + private uint m_thisPort = 9000; + + // These two used for local access, standalone mode + private UserManagerBase m_userService = null; + IAssetDataPlugin m_assetProvider = null; + + // These two used for remote access + string m_UserServerURL = string.Empty; + string m_AssetServerURL = string.Empty; + SynchronousGridAssetClient m_AssetClient = null; + + // Constructor for grid inventory server + public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) + { + m_UserServerURL = userServiceURL; + m_AssetServerURL = assetServiceURL; + + m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); + + Init(invService, thisurl, httpserver); + } + + // Constructor for standalone mode + public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) + { + m_userService = userService; + m_assetProvider = assetService; + + Init(invService, thisurl, httpserver); + } + + private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) + { + m_inventoryService = invService; + m_thisInventoryUrl = thisurl; + if (!m_thisInventoryUrl.EndsWith("/")) + m_thisInventoryUrl += "/"; + + Uri uri = new Uri(m_thisInventoryUrl); + if (uri != null) + { + m_thisHostname = uri.Host; + m_thisPort = (uint)uri.Port; + } + + httpServer = httpserver; + + AddHttpHandlers(); + } + + public virtual void AddHttpHandlers() + { + httpServer.AddHTTPHandler("/InvCap/", CapHandler); + } + + public bool CheckAuthSession(string session_id, string avatar_id) + { + return true; + } + + + // In truth, this is not called from the outside, for standalones. I'm just making it + // a handler already so that this can be reused for the InventoryServer. + public string CreateCapUrl(Guid _userid) + { + UUID userID = new UUID(_userid); + UUID random = UUID.Random(); + string url = m_thisInventoryUrl + random.ToString() + "/"; + m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); + return url; + } + + /// + /// Return a user's entire inventory + /// + /// + /// The user's inventory. If an inventory cannot be found then an empty collection is returned. + public InventoryCollection GetUserInventory(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List allFolders = m_inventoryService.GetInventorySkeleton(userID); + + if (null == allFolders) + { + m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); + + return invCollection; + } + + List allItems = new List(); + + foreach (InventoryFolderBase folder in allFolders) + { + List items = m_inventoryService.RequestFolderItems(folder.ID); + + if (items != null) + { + allItems.InsertRange(0, items); + } + } + + invCollection.UserID = userID; + invCollection.Folders = allFolders; + invCollection.Items = allItems; + + // foreach (InventoryFolderBase folder in invCollection.Folders) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); + // } + // + // foreach (InventoryItemBase item in invCollection.Items) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); + // } + + m_log.InfoFormat( + "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", + invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); + + return invCollection; + } + + public InventoryCollection FetchDescendants(InventoryFolderBase fb) + { + m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List items = m_inventoryService.RequestFolderItems(fb.ID); + List folders = m_inventoryService.RequestSubFolders(fb.ID); + + invCollection.UserID = fb.Owner; + invCollection.Folders = folders; + invCollection.Items = items; + + m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); + + return invCollection; + } + + public bool RemoveFolder(InventoryFolderBase folder) + { + m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); + return false; + } + + public InventoryItemBase GetInventoryItem(InventoryItemBase item) + { + m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); + + item = m_inventoryService.GetInventoryItem(item.ID); + if (item == null) + m_log.Debug("[HGStandaloneInvService]: null item"); + return item; + } + + public InventoryItemBase AddItem(InventoryItemBase item) + { + m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); + if (m_inventoryService.AddItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase UpdateItem(InventoryItemBase item) + { + m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); + InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); + item.CurrentPermissions = it.CurrentPermissions; + item.AssetID = it.AssetID; + if (m_inventoryService.UpdateItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase MoveItem(InventoryItemBase newitem) + { + m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); + InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); + if (Item != null) + { + if (newitem.Name != String.Empty) + { + Item.Name = newitem.Name; + } + Item.Folder = newitem.Folder; + m_inventoryService.UpdateItem(Item); + return Item; + } + else + { + m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); + newitem.ID = UUID.Zero; + return newitem; + } + + } + + public InventoryItemBase DeleteItem(InventoryItemBase item) + { + item = m_inventoryService.GetInventoryItem(item.ID); + if (m_inventoryService.DeleteItem(item)) + return item; + else + { + item.ID = UUID.Zero; + return item; + } + } + + public InventoryItemBase CopyItem(InventoryItemBase olditem) + { + m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); + InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id + // BIG HACK here + UUID newID = olditem.AssetID; + if (Item != null) + { + if (olditem.Name != String.Empty) + { + Item.Name = olditem.Name; + } + Item.ID = newID; + Item.Folder = olditem.Folder; + Item.Owner = olditem.Owner; + // There should be some tests here about the owner, etc but I'm going to ignore that + // because I'm not sure it makes any sense + // Also I should probably clone the asset... + m_inventoryService.AddItem(Item); + return Item; + } + else + { + m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); + olditem.ID = UUID.Zero; + return olditem; + } + + } + + /// + /// Guid to UUID wrapper for same name IInventoryServices method + /// + /// + /// + public List GetInventorySkeleton(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + return m_inventoryService.GetInventorySkeleton(userID); + } + + public List GetActiveGestures(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); + + return m_inventoryService.GetActiveGestures(userID); + } + + public AssetBase GetAsset(InventoryItemBase item) + { + m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); + AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data + InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); + if (item2 == null) + { + m_log.Debug("[HGStandaloneInvService]: null item"); + return asset; + } + if (item2.Owner != item.Owner) + { + m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); + return asset; + } + + // All good, get the asset + //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); + AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); + + m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); + if (theasset != null) + { + asset = theasset; + //m_log.Debug(" >> Sending assetID " + item.AssetID); + } + return asset; + } + + public bool PostAsset(AssetBase asset) + { + m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); + //m_assetProvider.CreateAsset(asset); + StoreAsset(asset); + + return true; + } + + /// + /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) + /// + public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) + { + m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); + InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); + + if (item != null) + { + // We're still not dealing with permissions + //if ((InventoryType)item.InvType == InventoryType.Notecard) + //{ + // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) + // { + // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); + // return UUID.Zero; + // } + + // //remoteClient.SendAgentAlertMessage("Notecard saved", false); + //} + //else if ((InventoryType)item.InvType == InventoryType.LSL) + //{ + // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) + // { + // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); + // return UUID.Zero; + // } + + // //remoteClient.SendAgentAlertMessage("Script saved", false); + //} + + AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); + PostAsset(asset); + + item.AssetID = asset.FullID; + item.Owner = userID; + m_inventoryService.UpdateItem(item); + + return (asset.FullID); + } + return UUID.Zero; + } + + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) + { + AssetBase asset = new AssetBase(); + asset.Name = name; + asset.Description = description; + asset.Type = assetType; + asset.FullID = UUID.Random(); + asset.Data = (data == null) ? new byte[1] : data; + + return asset; + } + + #region Caps + + Dictionary invCaps = new Dictionary(); + + public Hashtable CapHandler(Hashtable request) + { + m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); + + m_log.Debug("---------------------------"); + m_log.Debug(" >> uri=" + request["uri"]); + m_log.Debug(" >> content-type=" + request["content-type"]); + m_log.Debug(" >> http-method=" + request["http-method"]); + m_log.Debug("---------------------------\n"); + + // these are requests if the type + // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ + + Hashtable responsedata = new Hashtable(); + responsedata["content_type"] = "text/plain"; + + UUID userID; + string authToken = string.Empty; + string authority = string.Empty; + if (!GetParams(request, out userID, out authority, out authToken)) + { + m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); + responsedata["int_response_code"] = 404; + responsedata["str_response_string"] = "Not found"; + + return responsedata; + } + + // Next, let's parse the verb + string method = (string)request["http-method"]; + if (method.Equals("GET")) + { + DoInvCapPost(request, responsedata, userID, authority, authToken); + return responsedata; + } + //else if (method.Equals("DELETE")) + //{ + // DoAgentDelete(request, responsedata, agentID, action, regionHandle); + + // return responsedata; + //} + else + { + m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); + responsedata["int_response_code"] = 405; + responsedata["str_response_string"] = "Method not allowed"; + + return responsedata; + } + + } + + public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authority, string authToken) + { + + // This is the meaning of POST agent + + // Check Auth Token + if ((m_userService != null) && !(m_userService is IAuthentication)) + { + m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); + responsedata["int_response_code"] = 501; + responsedata["str_response_string"] = "Not implemented"; + return; + } + + bool success = VerifyKey(userID, authority, authToken); + + if (success) + { + + m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); + + // Then establish secret service handlers + + Hashtable usercaps = RegisterCaps(userID, authToken); + + responsedata["int_response_code"] = 200; + //responsedata["str_response_string"] = "OK"; + responsedata["str_response_string"] = SerializeHashtable(usercaps); + } + else + { + m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); + responsedata["int_response_code"] = 403; + responsedata["str_response_string"] = "Forbidden"; + } + } + + + /// + /// Extract the params from a request. + /// + public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) + { + uuid = UUID.Zero; + authority = string.Empty; + authKey = string.Empty; + + string uri = (string)request["uri"]; + uri = uri.Trim(new char[] { '/' }); + string[] parts = uri.Split('/'); + if (parts.Length <= 1) + { + return false; + } + else + { + if (!UUID.TryParse(parts[1], out uuid)) + return false; + + if (parts.Length >= 3) + { + authKey = parts[2]; + return true; + } + } + + Uri authUri; + Hashtable headers = (Hashtable)request["headers"]; + + // Authorization keys look like this: + // http://orgrid.org:8002/ + if (headers.ContainsKey("authorization")) + { + if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) + { + authority = authUri.Authority; + authKey = authUri.PathAndQuery.Trim('/'); + m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); + return true; + } + else + m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); + } + else + m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); + + return false; + } + + string SerializeHashtable(Hashtable hash) + { + string result = string.Empty; + foreach (object key in hash.Keys) + { + result += key.ToString() + "," + hash[key].ToString() + ";"; + } + return result; + } + + Hashtable RegisterCaps(UUID userID, string authToken) + { + lock (invCaps) + { + if (invCaps.ContainsKey(userID)) + { + // Remove the old ones + DeregisterCaps(httpServer, invCaps[userID]); + invCaps.Remove(userID); + } + } + + Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); + caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); + caps.ItemUpdatedCall = UpdateInventoryItemAsset; + Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); + + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); + + lock (invCaps) + invCaps.Add(userID, capsHandlers); + + return capsHandlers; + } + + string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) + { + string capUrl = "/" + authToken + "/" + capType + "/"; + + m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); + caps.Add(capType, capUrl); + return capUrl; + } + + void DeregisterCaps(IHttpServer httpServer, Hashtable caps) + { + foreach (string capUrl in caps.Values) + { + m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); + httpServer.RemoveStreamHandler("POST", capUrl); + } + } + + #endregion Caps + + #region Local vs Remote + + bool VerifyKey(UUID userID, string authority, string key) + { + // Remote call to the Authorization server + if (m_userService == null) + return AuthClient.VerifyKey("http://" + authority, userID, key); + // local call + else + return ((IAuthentication)m_userService).VerifyKey(userID, key); + } + + AssetBase FetchAsset(UUID assetID, bool isTexture) + { + // Remote call to the Asset server + if (m_assetProvider == null) + return m_AssetClient.SyncGetAsset(assetID, isTexture); + // local call + else + return m_assetProvider.FetchAsset(assetID); + } + + void StoreAsset(AssetBase asset) + { + // Remote call to the Asset server + if (m_assetProvider == null) + m_AssetClient.StoreAsset(asset); + // local call + else + m_assetProvider.CreateAsset(asset); + } + + #endregion Local vs Remote + } + + class SynchronousGridAssetClient : GridAssetClient + { + public SynchronousGridAssetClient(string url) + : base(url) + { + } + + public AssetBase SyncGetAsset(UUID assetID, bool isTexture) + { + AssetRequest assReq = new AssetRequest(); + assReq.AssetID = assetID; + assReq.IsTexture = isTexture; + return base.GetAsset(assReq); + } + + } +} diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 72e2dfb..99fbb2b 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -1,328 +1,328 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; - -using OpenMetaverse; - -using log4net; -using Nini.Config; -using Nwc.XmlRpc; - -namespace OpenSim.Framework.Communications.Services -{ - public class HGLoginAuthService : LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected NetworkServersInfo m_serversInfo; - protected bool m_authUsers = false; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_interServiceInventoryService; - - /// - /// Used to make requests to the local regions. - /// - protected ILoginServiceToRegionsConnector m_regionsConnector; - - - public HGLoginAuthService( - UserManagerBase userManager, string welcomeMess, - IInterServiceInventoryServices interServiceInventoryService, - NetworkServersInfo serversInfo, - bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) - : base(userManager, libraryRootFolder, welcomeMess) - { - this.m_serversInfo = serversInfo; - if (m_serversInfo != null) - { - m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; - m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; - } - m_authUsers = authenticate; - - m_interServiceInventoryService = interServiceInventoryService; - m_regionsConnector = regionsConnector; - m_inventoryService = interServiceInventoryService; - } - - public void SetServersInfo(NetworkServersInfo sinfo) - { - m_serversInfo = sinfo; - } - - public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); - XmlRpcResponse response = base.XmlRpcLoginMethod(request); - Hashtable responseData = (Hashtable)response.Value; - - responseData["grid_service"] = m_serversInfo.GridURL; - responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; - responseData["inventory_service"] = m_serversInfo.InventoryURL; - responseData["asset_service"] = m_serversInfo.AssetURL; - responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; - int x = (Int32)responseData["region_x"]; - int y = (Int32)responseData["region_y"]; - uint ux = (uint)(x / Constants.RegionSize); - uint uy = (uint)(y / Constants.RegionSize); - ulong regionHandle = Util.UIntsToLong(ux, uy); - responseData["region_handle"] = regionHandle.ToString(); - - // Let's remove the seed cap from the login - //responseData.Remove("seed_capability"); - - // Let's add the appearance - UUID userID = UUID.Zero; - UUID.TryParse((string)responseData["agent_id"], out userID); - AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); - if (appearance == null) - { - m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); - appearance = new AvatarAppearance(); - } - - responseData["appearance"] = appearance.ToHashTable(); - - // Let's also send the auth token - UUID token = UUID.Random(); - responseData["auth_token"] = token.ToString(); - UserProfileData userProfile = m_userManager.GetUserProfile(userID); - if (userProfile != null) - { - userProfile.WebLoginKey = token; - m_userManager.CommitAgent(ref userProfile); - } - - return response; - } - - public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) - { - - // Verify the key of who's calling - UUID userID = UUID.Zero; - UUID authKey = UUID.Zero; - UUID.TryParse((string)request.Params[0], out userID); - UUID.TryParse((string)request.Params[1], out authKey); - - m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); - string newKey = string.Empty; - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); - } - else - { - newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = (string) newKey; - return response; - } - - public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) - { - bool success = false; - - if (request.Params.Count >= 2) - { - // Verify the key of who's calling - UUID userID = UUID.Zero; - string authKey = string.Empty; - if (UUID.TryParse((string)request.Params[0], out userID)) - { - authKey = (string)request.Params[1]; - - m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); - } - else - { - success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); - } - } - } - - m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = success; - return response; - } - - public override UserProfileData GetTheUser(string firstname, string lastname) - { - UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); - if (profile != null) - { - return profile; - } - - if (!m_authUsers) - { - //no current user account so make one - m_log.Info("[LOGIN]: No user account found so creating a new one."); - - m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); - - return m_userManager.GetUserProfile(firstname, lastname); - } - - return null; - } - - public override bool AuthenticateUser(UserProfileData profile, string password) - { - if (!m_authUsers) - { - //for now we will accept any password in sandbox mode - m_log.Info("[LOGIN]: Authorising user (no actual password check)"); - - return true; - } - else - { - m_log.Info( - "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); - - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - - bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); - return loginresult; - } - } - - protected override RegionInfo RequestClosestRegion(string region) - { - return m_regionsConnector.RequestClosestRegion(region); - } - - protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); - } - - protected override RegionInfo GetRegionInfo(UUID homeRegionId) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionId); - } - - - /// - /// Not really informing the region. Just filling out the response fields related to the region. - /// - /// - /// - /// - /// true if the region was successfully contacted, false otherwise - protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) - { - IPEndPoint endPoint = regionInfo.ExternalEndPoint; - response.SimAddress = endPoint.Address.ToString(); - response.SimPort = (uint)endPoint.Port; - response.RegionX = regionInfo.RegionLocX; - response.RegionY = regionInfo.RegionLocY; - response.SimHttpPort = regionInfo.HttpPort; - - string capsPath = CapsUtil.GetRandomCapsObjectPath(); - string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); - - // Don't use the following! It Fails for logging into any region not on the same port as the http server! - // Kept here so it doesn't happen again! - // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; - - string seedcap = "http://"; - - if (m_serversInfo.HttpUsesSSL) - { - seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; - } - else - { - seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; - } - - response.SeedCapability = seedcap; - - // Notify the target of an incoming user - m_log.InfoFormat( - "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", - regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); - - // Update agent with target sim - user.CurrentAgent.Region = regionInfo.RegionID; - user.CurrentAgent.Handle = regionInfo.RegionHandle; - - return true; - } - - public override void LogOffUser(UserProfileData theUser, string message) - { - RegionInfo SimInfo; - try - { - SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); - - if (SimInfo == null) - { - m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); - return; - } - } - catch (Exception) - { - m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); - return; - } - - m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.Net; +using System.Reflection; +using System.Text.RegularExpressions; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; + +using OpenMetaverse; + +using log4net; +using Nini.Config; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Communications.Services +{ + public class HGLoginAuthService : LoginService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected NetworkServersInfo m_serversInfo; + protected bool m_authUsers = false; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_interServiceInventoryService; + + /// + /// Used to make requests to the local regions. + /// + protected ILoginServiceToRegionsConnector m_regionsConnector; + + + public HGLoginAuthService( + UserManagerBase userManager, string welcomeMess, + IInterServiceInventoryServices interServiceInventoryService, + NetworkServersInfo serversInfo, + bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) + : base(userManager, libraryRootFolder, welcomeMess) + { + this.m_serversInfo = serversInfo; + if (m_serversInfo != null) + { + m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; + m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; + } + m_authUsers = authenticate; + + m_interServiceInventoryService = interServiceInventoryService; + m_regionsConnector = regionsConnector; + m_inventoryService = interServiceInventoryService; + } + + public void SetServersInfo(NetworkServersInfo sinfo) + { + m_serversInfo = sinfo; + } + + public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); + XmlRpcResponse response = base.XmlRpcLoginMethod(request); + Hashtable responseData = (Hashtable)response.Value; + + responseData["grid_service"] = m_serversInfo.GridURL; + responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; + responseData["inventory_service"] = m_serversInfo.InventoryURL; + responseData["asset_service"] = m_serversInfo.AssetURL; + responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; + int x = (Int32)responseData["region_x"]; + int y = (Int32)responseData["region_y"]; + uint ux = (uint)(x / Constants.RegionSize); + uint uy = (uint)(y / Constants.RegionSize); + ulong regionHandle = Util.UIntsToLong(ux, uy); + responseData["region_handle"] = regionHandle.ToString(); + + // Let's remove the seed cap from the login + //responseData.Remove("seed_capability"); + + // Let's add the appearance + UUID userID = UUID.Zero; + UUID.TryParse((string)responseData["agent_id"], out userID); + AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); + if (appearance == null) + { + m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); + appearance = new AvatarAppearance(); + } + + responseData["appearance"] = appearance.ToHashTable(); + + // Let's also send the auth token + UUID token = UUID.Random(); + responseData["auth_token"] = token.ToString(); + UserProfileData userProfile = m_userManager.GetUserProfile(userID); + if (userProfile != null) + { + userProfile.WebLoginKey = token; + m_userManager.CommitAgent(ref userProfile); + } + + return response; + } + + public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) + { + + // Verify the key of who's calling + UUID userID = UUID.Zero; + UUID authKey = UUID.Zero; + UUID.TryParse((string)request.Params[0], out userID); + UUID.TryParse((string)request.Params[1], out authKey); + + m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); + string newKey = string.Empty; + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); + } + else + { + newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = (string) newKey; + return response; + } + + public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) + { + bool success = false; + + if (request.Params.Count >= 2) + { + // Verify the key of who's calling + UUID userID = UUID.Zero; + string authKey = string.Empty; + if (UUID.TryParse((string)request.Params[0], out userID)) + { + authKey = (string)request.Params[1]; + + m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); + + if (!(m_userManager is IAuthentication)) + { + m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); + } + else + { + success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); + } + } + } + + m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = success; + return response; + } + + public override UserProfileData GetTheUser(string firstname, string lastname) + { + UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); + if (profile != null) + { + return profile; + } + + if (!m_authUsers) + { + //no current user account so make one + m_log.Info("[LOGIN]: No user account found so creating a new one."); + + m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); + + return m_userManager.GetUserProfile(firstname, lastname); + } + + return null; + } + + public override bool AuthenticateUser(UserProfileData profile, string password) + { + if (!m_authUsers) + { + //for now we will accept any password in sandbox mode + m_log.Info("[LOGIN]: Authorising user (no actual password check)"); + + return true; + } + else + { + m_log.Info( + "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); + + if (!password.StartsWith("$1$")) + password = "$1$" + Util.Md5Hash(password); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + + bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + return loginresult; + } + } + + protected override RegionInfo RequestClosestRegion(string region) + { + return m_regionsConnector.RequestClosestRegion(region); + } + + protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); + } + + protected override RegionInfo GetRegionInfo(UUID homeRegionId) + { + return m_regionsConnector.RequestNeighbourInfo(homeRegionId); + } + + + /// + /// Not really informing the region. Just filling out the response fields related to the region. + /// + /// + /// + /// + /// true if the region was successfully contacted, false otherwise + protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) + { + IPEndPoint endPoint = regionInfo.ExternalEndPoint; + response.SimAddress = endPoint.Address.ToString(); + response.SimPort = (uint)endPoint.Port; + response.RegionX = regionInfo.RegionLocX; + response.RegionY = regionInfo.RegionLocY; + response.SimHttpPort = regionInfo.HttpPort; + + string capsPath = CapsUtil.GetRandomCapsObjectPath(); + string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); + + // Don't use the following! It Fails for logging into any region not on the same port as the http server! + // Kept here so it doesn't happen again! + // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; + + string seedcap = "http://"; + + if (m_serversInfo.HttpUsesSSL) + { + seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; + } + else + { + seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; + } + + response.SeedCapability = seedcap; + + // Notify the target of an incoming user + m_log.InfoFormat( + "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", + regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); + + // Update agent with target sim + user.CurrentAgent.Region = regionInfo.RegionID; + user.CurrentAgent.Handle = regionInfo.RegionHandle; + + return true; + } + + public override void LogOffUser(UserProfileData theUser, string message) + { + RegionInfo SimInfo; + try + { + SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); + + if (SimInfo == null) + { + m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); + return; + } + } + catch (Exception) + { + m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); + return; + } + + m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); + } + } +} -- cgit v1.1 From 54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 31 Mar 2009 02:00:33 +0000 Subject: Update svn properties, add copyright header, formatting cleanup. --- .../Framework/Communications/Cache/AssetCache.cs | 4 +- .../Framework/Communications/IAuthentication.cs | 51 +- .../Communications/Services/GridInfoService.cs | 344 +-- .../Communications/Services/LoginResponse.cs | 1624 +++++++-------- .../Communications/Services/LoginService.cs | 2186 ++++++++++---------- 5 files changed, 2117 insertions(+), 2092 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index d79645e..73aa6ba 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -503,7 +503,7 @@ namespace OpenSim.Framework.Communications.Cache req.Params = transferRequest.TransferInfo.Params; req.AssetInf = new AssetInfo(asset); req.NumPackets = CalculateNumPackets(asset.Data); - lock(AssetRequests) AssetRequests.Add(req); + lock (AssetRequests) AssetRequests.Add(req); } /// @@ -526,7 +526,7 @@ namespace OpenSim.Framework.Communications.Cache for (int i = 0; i < num; i++) { - lock(AssetRequests) + lock (AssetRequests) { req = AssetRequests[0]; AssetRequests.RemoveAt(0); diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs index 5d6d5f2..0f62569 100644 --- a/OpenSim/Framework/Communications/IAuthentication.cs +++ b/OpenSim/Framework/Communications/IAuthentication.cs @@ -1,13 +1,38 @@ -using System; - -using OpenMetaverse; - - -namespace OpenSim.Framework.Communications -{ - public interface IAuthentication - { - string GetNewKey(string url, UUID userID, UUID authToken); - bool VerifyKey(UUID userID, string key); - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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 OpenMetaverse; + +namespace OpenSim.Framework.Communications +{ + public interface IAuthentication + { + string GetNewKey(string url, UUID userID, UUID authToken); + bool VerifyKey(UUID userID, string key); + } +} diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index 96fe0d8..030ea61 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -1,172 +1,172 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.IO; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers; - -namespace OpenSim.Framework.Communications.Services -{ - public class GridInfoService - { - private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable _info = new Hashtable(); - - /// - /// Instantiate a GridInfoService object. - /// - /// path to config path containing - /// grid information - /// - /// GridInfoService uses the [GridInfo] section of the - /// standard OpenSim.ini file --- which is not optimal, but - /// anything else requires a general redesign of the config - /// system. - /// - public GridInfoService(IConfigSource configSource) - { - loadGridInfo(configSource); - } - - /// - /// Default constructor, uses OpenSim.ini. - /// - public GridInfoService() - { - try - { - IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); - loadGridInfo(configSource); - } - catch (FileNotFoundException) - { - _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); - } - } - - private void loadGridInfo(IConfigSource configSource) - { - _info["platform"] = "OpenSim"; - try - { - IConfig startupCfg = configSource.Configs["Startup"]; - IConfig gridCfg = configSource.Configs["GridInfo"]; - IConfig netCfg = configSource.Configs["Network"]; - - bool grid = startupCfg.GetBoolean("gridmode", false); - - if (grid) - _info["mode"] = "grid"; - else - _info["mode"] = "standalone"; - - - if (null != gridCfg) - { - foreach (string k in gridCfg.GetKeys()) - { - _info[k] = gridCfg.GetString(k); - } - } - else if (null != netCfg) - { - if (grid) - _info["login"] - = netCfg.GetString( - "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); - else - _info["login"] - = String.Format( - "http://127.0.0.1:{0}/", - netCfg.GetString( - "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); - - IssueWarning(); - } - else - { - _info["login"] = "http://127.0.0.1:9000/"; - IssueWarning(); - } - } - catch (Exception) - { - _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); - } - _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); - - } - - private void IssueWarning() - { - _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); - _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); - foreach (string k in _info.Keys) - { - _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); - } - } - - public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - - _log.Info("[GridInfo]: Request for grid info"); - - foreach (string k in _info.Keys) - { - responseData[k] = _info[k]; - } - response.Value = responseData; - - return response; - } - - public string RestGetGridInfoMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - StringBuilder sb = new StringBuilder(); - - sb.Append("\n"); - foreach (string k in _info.Keys) - { - sb.AppendFormat("<{0}>{1}\n", k, _info[k]); - } - sb.Append("\n"); - - return sb.ToString(); - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework.Servers; + +namespace OpenSim.Framework.Communications.Services +{ + public class GridInfoService + { + private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable _info = new Hashtable(); + + /// + /// Instantiate a GridInfoService object. + /// + /// path to config path containing + /// grid information + /// + /// GridInfoService uses the [GridInfo] section of the + /// standard OpenSim.ini file --- which is not optimal, but + /// anything else requires a general redesign of the config + /// system. + /// + public GridInfoService(IConfigSource configSource) + { + loadGridInfo(configSource); + } + + /// + /// Default constructor, uses OpenSim.ini. + /// + public GridInfoService() + { + try + { + IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); + loadGridInfo(configSource); + } + catch (FileNotFoundException) + { + _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); + } + } + + private void loadGridInfo(IConfigSource configSource) + { + _info["platform"] = "OpenSim"; + try + { + IConfig startupCfg = configSource.Configs["Startup"]; + IConfig gridCfg = configSource.Configs["GridInfo"]; + IConfig netCfg = configSource.Configs["Network"]; + + bool grid = startupCfg.GetBoolean("gridmode", false); + + if (grid) + _info["mode"] = "grid"; + else + _info["mode"] = "standalone"; + + + if (null != gridCfg) + { + foreach (string k in gridCfg.GetKeys()) + { + _info[k] = gridCfg.GetString(k); + } + } + else if (null != netCfg) + { + if (grid) + _info["login"] + = netCfg.GetString( + "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + else + _info["login"] + = String.Format( + "http://127.0.0.1:{0}/", + netCfg.GetString( + "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); + + IssueWarning(); + } + else + { + _info["login"] = "http://127.0.0.1:9000/"; + IssueWarning(); + } + } + catch (Exception) + { + _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); + } + _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); + + } + + private void IssueWarning() + { + _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); + _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); + foreach (string k in _info.Keys) + { + _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); + } + } + + public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + _log.Info("[GridInfo]: Request for grid info"); + + foreach (string k in _info.Keys) + { + responseData[k] = _info[k]; + } + response.Value = responseData; + + return response; + } + + public string RestGetGridInfoMethod(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StringBuilder sb = new StringBuilder(); + + sb.Append("\n"); + foreach (string k in _info.Keys) + { + sb.AppendFormat("<{0}>{1}\n", k, _info[k]); + } + sb.Append("\n"); + + return sb.ToString(); + } + } +} diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index 82515e0..db208a4 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -1,812 +1,812 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -namespace OpenSim.Framework.Communications.Services -{ - /// - /// A temp class to handle login response. - /// Should make use of UserProfileManager where possible. - /// - public class LoginResponse - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable loginFlagsHash; - private Hashtable globalTexturesHash; - private Hashtable loginError; - private Hashtable uiConfigHash; - - private ArrayList loginFlags; - private ArrayList globalTextures; - private ArrayList eventCategories; - private ArrayList uiConfig; - private ArrayList classifiedCategories; - private ArrayList inventoryRoot; - private ArrayList initialOutfit; - private ArrayList agentInventory; - private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibRoot; - private ArrayList inventoryLibrary; - private ArrayList activeGestures; - - private UserInfo userProfile; - - private UUID agentID; - private UUID sessionID; - private UUID secureSessionID; - - // Login Flags - private string dst; - private string stipendSinceLogin; - private string gendered; - private string everLoggedIn; - private string login; - private uint simPort; - private uint simHttpPort; - private string simAddress; - private string agentAccess; - private Int32 circuitCode; - private uint regionX; - private uint regionY; - - // Login - private string firstname; - private string lastname; - - // Global Textures - private string sunTexture; - private string cloudTexture; - private string moonTexture; - - // Error Flags - private string errorReason; - private string errorMessage; - - // Response - private XmlRpcResponse xmlRpcResponse; - // private XmlRpcResponse defaultXmlRpcResponse; - - private string welcomeMessage; - private string startLocation; - private string allowFirstLife; - private string home; - private string seedCapability; - private string lookAt; - - private BuddyList m_buddyList = null; - - public LoginResponse() - { - loginFlags = new ArrayList(); - globalTextures = new ArrayList(); - eventCategories = new ArrayList(); - uiConfig = new ArrayList(); - classifiedCategories = new ArrayList(); - - loginError = new Hashtable(); - uiConfigHash = new Hashtable(); - - // defaultXmlRpcResponse = new XmlRpcResponse(); - userProfile = new UserInfo(); - inventoryRoot = new ArrayList(); - initialOutfit = new ArrayList(); - agentInventory = new ArrayList(); - inventoryLibrary = new ArrayList(); - inventoryLibraryOwner = new ArrayList(); - activeGestures = new ArrayList(); - - xmlRpcResponse = new XmlRpcResponse(); - // defaultXmlRpcResponse = new XmlRpcResponse(); - - SetDefaultValues(); - } - - private void SetDefaultValues() - { - DST = "N"; - StipendSinceLogin = "N"; - Gendered = "Y"; - EverLoggedIn = "Y"; - login = "false"; - firstname = "Test"; - lastname = "User"; - agentAccess = "M"; - startLocation = "last"; - allowFirstLife = "Y"; - - SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; - MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; - - ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; - ErrorReason = "key"; - welcomeMessage = "Welcome to OpenSim!"; - seedCapability = String.Empty; - home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + - userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + - userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + - userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; - lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; - RegionX = (uint) 255232; - RegionY = (uint) 254976; - - // Classifieds; - AddClassifiedCategory((Int32) 1, "Shopping"); - AddClassifiedCategory((Int32) 2, "Land Rental"); - AddClassifiedCategory((Int32) 3, "Property Rental"); - AddClassifiedCategory((Int32) 4, "Special Attraction"); - AddClassifiedCategory((Int32) 5, "New Products"); - AddClassifiedCategory((Int32) 6, "Employment"); - AddClassifiedCategory((Int32) 7, "Wanted"); - AddClassifiedCategory((Int32) 8, "Service"); - AddClassifiedCategory((Int32) 9, "Personal"); - - SessionID = UUID.Random(); - SecureSessionID = UUID.Random(); - AgentID = UUID.Random(); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - initialOutfit.Add(InitialOutfitHash); - } - - #region Login Failure Methods - - public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) - { - // Overwrite any default values; - xmlRpcResponse = new XmlRpcResponse(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - loginError["reason"] = ErrorReason; - loginError["message"] = ErrorMessage; - loginError["login"] = login; - xmlRpcResponse.Value = loginError; - return (xmlRpcResponse); - } - - public OSD GenerateFailureResponseLLSD(string reason, string message, string login) - { - OSDMap map = new OSDMap(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - map["reason"] = OSD.FromString(ErrorReason); - map["message"] = OSD.FromString(ErrorMessage); - map["login"] = OSD.FromString(login); - - return map; - } - - public XmlRpcResponse CreateFailedResponse() - { - return (CreateLoginFailedResponse()); - } - - public OSD CreateFailedResponseLLSD() - { - return CreateLoginFailedResponseLLSD(); - } - - public XmlRpcResponse CreateLoginFailedResponse() - { - return - (GenerateFailureResponse("key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false")); - } - - public OSD CreateLoginFailedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false"); - } - - /// - /// Response to indicate that login failed because the agent's inventory was not available. - /// - /// - public XmlRpcResponse CreateLoginInventoryFailedResponse() - { - return GenerateFailureResponse( - "key", - "The avatar inventory service is not responding. Please notify your login region operator.", - "false"); - } - - public XmlRpcResponse CreateAlreadyLoggedInResponse() - { - return - (GenerateFailureResponse("presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", - "false")); - } - - public OSD CreateAlreadyLoggedInResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner", - "false"); - } - - public XmlRpcResponse CreateLoginBlockedResponse() - { - return - (GenerateFailureResponse("presence", - "Logins are currently restricted. Please try again later", - "false")); - } - - public OSD CreateLoginBlockedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "Logins are currently restricted. Please try again later", - "false"); - } - - public XmlRpcResponse CreateDeadRegionResponse() - { - return - (GenerateFailureResponse("key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false")); - } - - public OSD CreateDeadRegionResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false"); - } - - public XmlRpcResponse CreateGridErrorResponse() - { - return - (GenerateFailureResponse("key", - "Error connecting to grid. Could not percieve credentials from login XML.", - "false")); - } - - public OSD CreateGridErrorResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Error connecting to grid. Could not percieve credentials from login XML.", - "false"); - } - - #endregion - - public virtual XmlRpcResponse ToXmlRpcResponse() - { - try - { - Hashtable responseData = new Hashtable(); - - loginFlagsHash = new Hashtable(); - loginFlagsHash["daylight_savings"] = DST; - loginFlagsHash["stipend_since_login"] = StipendSinceLogin; - loginFlagsHash["gendered"] = Gendered; - loginFlagsHash["ever_logged_in"] = EverLoggedIn; - loginFlags.Add(loginFlagsHash); - - responseData["first_name"] = Firstname; - responseData["last_name"] = Lastname; - responseData["agent_access"] = agentAccess; - - globalTexturesHash = new Hashtable(); - globalTexturesHash["sun_texture_id"] = SunTexture; - globalTexturesHash["cloud_texture_id"] = CloudTexture; - globalTexturesHash["moon_texture_id"] = MoonTexture; - globalTextures.Add(globalTexturesHash); - // this.eventCategories.Add(this.eventCategoriesHash); - - AddToUIConfig("allow_first_life", allowFirstLife); - uiConfig.Add(uiConfigHash); - - responseData["sim_port"] = (Int32) SimPort; - responseData["sim_ip"] = SimAddress; - responseData["http_port"] = (Int32)SimHttpPort; - - responseData["agent_id"] = AgentID.ToString(); - responseData["session_id"] = SessionID.ToString(); - responseData["secure_session_id"] = SecureSessionID.ToString(); - responseData["circuit_code"] = CircuitCode; - responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = loginFlags; - responseData["global-textures"] = globalTextures; - responseData["seed_capability"] = seedCapability; - - responseData["event_categories"] = eventCategories; - responseData["event_notifications"] = new ArrayList(); // todo - responseData["classified_categories"] = classifiedCategories; - responseData["ui-config"] = uiConfig; - - responseData["inventory-skeleton"] = agentInventory; - responseData["inventory-skel-lib"] = inventoryLibrary; - responseData["inventory-root"] = inventoryRoot; - responseData["inventory-lib-root"] = inventoryLibRoot; - responseData["gestures"] = activeGestures; - responseData["inventory-lib-owner"] = inventoryLibraryOwner; - responseData["initial-outfit"] = initialOutfit; - responseData["start_location"] = startLocation; - responseData["seed_capability"] = seedCapability; - responseData["home"] = home; - responseData["look_at"] = lookAt; - responseData["message"] = welcomeMessage; - responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); - responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); - - //responseData["inventory-lib-root"] = new ArrayList(); // todo - - if (m_buddyList != null) - { - responseData["buddy-list"] = m_buddyList.ToArray(); - } - - responseData["login"] = "true"; - xmlRpcResponse.Value = responseData; - - return (xmlRpcResponse); - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); - - return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); - } - } - - public OSD ToLLSDResponse() - { - try - { - OSDMap map = new OSDMap(); - - map["first_name"] = OSD.FromString(Firstname); - map["last_name"] = OSD.FromString(Lastname); - map["agent_access"] = OSD.FromString(agentAccess); - - map["sim_port"] = OSD.FromInteger(SimPort); - map["sim_ip"] = OSD.FromString(SimAddress); - - map["agent_id"] = OSD.FromUUID(AgentID); - map["session_id"] = OSD.FromUUID(SessionID); - map["secure_session_id"] = OSD.FromUUID(SecureSessionID); - map["circuit_code"] = OSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); - - #region Login Flags - - OSDMap loginFlagsLLSD = new OSDMap(); - loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); - map["login-flags"] = WrapOSDMap(loginFlagsLLSD); - - #endregion Login Flags - - #region Global Textures - - OSDMap globalTexturesLLSD = new OSDMap(); - globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); - - map["global-textures"] = WrapOSDMap(globalTexturesLLSD); - - #endregion Global Textures - - map["seed_capability"] = OSD.FromString(seedCapability); - - map["event_categories"] = ArrayListToOSDArray(eventCategories); - //map["event_notifications"] = new OSDArray(); // todo - map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); - - #region UI Config - - OSDMap uiConfigLLSD = new OSDMap(); - uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); - map["ui-config"] = WrapOSDMap(uiConfigLLSD); - - #endregion UI Config - - #region Inventory - - map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); - - map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); - - #endregion Inventory - - map["gestures"] = ArrayListToOSDArray(activeGestures); - - map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); - map["start_location"] = OSD.FromString(startLocation); - - map["seed_capability"] = OSD.FromString(seedCapability); - map["home"] = OSD.FromString(home); - map["look_at"] = OSD.FromString(lookAt); - map["message"] = OSD.FromString(welcomeMessage); - map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); - - if (m_buddyList != null) - { - map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); - } - - map["login"] = OSD.FromString("true"); - - return map; - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); - - return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); - } - } - - public OSDArray ArrayListToOSDArray(ArrayList arrlst) - { - OSDArray llsdBack = new OSDArray(); - foreach (Hashtable ht in arrlst) - { - OSDMap mp = new OSDMap(); - foreach (DictionaryEntry deHt in ht) - { - mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); - } - llsdBack.Add(mp); - } - return llsdBack; - } - - private static OSDArray WrapOSDMap(OSDMap wrapMe) - { - OSDArray array = new OSDArray(); - array.Add(wrapMe); - return array; - } - - public void SetEventCategories(string category, string value) - { - // this.eventCategoriesHash[category] = value; - //TODO - } - - public void AddToUIConfig(string itemName, string item) - { - uiConfigHash[itemName] = item; - } - - public void AddClassifiedCategory(Int32 ID, string categoryName) - { - Hashtable hash = new Hashtable(); - hash["category_name"] = categoryName; - hash["category_id"] = ID; - classifiedCategories.Add(hash); - // this.classifiedCategoriesHash.Clear(); - } - - #region Properties - - public string Login - { - get { return login; } - set { login = value; } - } - - public string DST - { - get { return dst; } - set { dst = value; } - } - - public string StipendSinceLogin - { - get { return stipendSinceLogin; } - set { stipendSinceLogin = value; } - } - - public string Gendered - { - get { return gendered; } - set { gendered = value; } - } - - public string EverLoggedIn - { - get { return everLoggedIn; } - set { everLoggedIn = value; } - } - - public uint SimPort - { - get { return simPort; } - set { simPort = value; } - } - - public uint SimHttpPort - { - get { return simHttpPort; } - set { simHttpPort = value; } - } - - public string SimAddress - { - get { return simAddress; } - set { simAddress = value; } - } - - public UUID AgentID - { - get { return agentID; } - set { agentID = value; } - } - - public UUID SessionID - { - get { return sessionID; } - set { sessionID = value; } - } - - public UUID SecureSessionID - { - get { return secureSessionID; } - set { secureSessionID = value; } - } - - public Int32 CircuitCode - { - get { return circuitCode; } - set { circuitCode = value; } - } - - public uint RegionX - { - get { return regionX; } - set { regionX = value; } - } - - public uint RegionY - { - get { return regionY; } - set { regionY = value; } - } - - public string SunTexture - { - get { return sunTexture; } - set { sunTexture = value; } - } - - public string CloudTexture - { - get { return cloudTexture; } - set { cloudTexture = value; } - } - - public string MoonTexture - { - get { return moonTexture; } - set { moonTexture = value; } - } - - public string Firstname - { - get { return firstname; } - set { firstname = value; } - } - - public string Lastname - { - get { return lastname; } - set { lastname = value; } - } - - public string AgentAccess - { - get { return agentAccess; } - set { agentAccess = value; } - } - - public string StartLocation - { - get { return startLocation; } - set { startLocation = value; } - } - - public string LookAt - { - get { return lookAt; } - set { lookAt = value; } - } - - public string SeedCapability - { - get { return seedCapability; } - set { seedCapability = value; } - } - - public string ErrorReason - { - get { return errorReason; } - set { errorReason = value; } - } - - public string ErrorMessage - { - get { return errorMessage; } - set { errorMessage = value; } - } - - public ArrayList InventoryRoot - { - get { return inventoryRoot; } - set { inventoryRoot = value; } - } - - public ArrayList InventorySkeleton - { - get { return agentInventory; } - set { agentInventory = value; } - } - - public ArrayList InventoryLibrary - { - get { return inventoryLibrary; } - set { inventoryLibrary = value; } - } - - public ArrayList InventoryLibraryOwner - { - get { return inventoryLibraryOwner; } - set { inventoryLibraryOwner = value; } - } - - public ArrayList InventoryLibRoot - { - get { return inventoryLibRoot; } - set { inventoryLibRoot = value; } - } - - public ArrayList ActiveGestures - { - get { return activeGestures; } - set { activeGestures = value; } - } - - public string Home - { - get { return home; } - set { home = value; } - } - - public string Message - { - get { return welcomeMessage; } - set { welcomeMessage = value; } - } - - public BuddyList BuddList - { - get { return m_buddyList; } - set { m_buddyList = value; } - } - - #endregion - - public class UserInfo - { - public string firstname; - public string lastname; - public ulong homeregionhandle; - public Vector3 homepos; - public Vector3 homelookat; - } - - public class BuddyList - { - public List Buddies = new List(); - - public void AddNewBuddy(BuddyInfo buddy) - { - if (!Buddies.Contains(buddy)) - { - Buddies.Add(buddy); - } - } - - public ArrayList ToArray() - { - ArrayList buddyArray = new ArrayList(); - foreach (BuddyInfo buddy in Buddies) - { - buddyArray.Add(buddy.ToHashTable()); - } - return buddyArray; - } - - public class BuddyInfo - { - public int BuddyRightsHave = 1; - public int BuddyRightsGiven = 1; - public UUID BuddyID; - - public BuddyInfo(string buddyID) - { - BuddyID = new UUID(buddyID); - } - - public BuddyInfo(UUID buddyID) - { - BuddyID = buddyID; - } - - public Hashtable ToHashTable() - { - Hashtable hTable = new Hashtable(); - hTable["buddy_rights_has"] = BuddyRightsHave; - hTable["buddy_rights_given"] = BuddyRightsGiven; - hTable["buddy_id"] = BuddyID.ToString(); - return hTable; - } - } - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +namespace OpenSim.Framework.Communications.Services +{ + /// + /// A temp class to handle login response. + /// Should make use of UserProfileManager where possible. + /// + public class LoginResponse + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Hashtable loginFlagsHash; + private Hashtable globalTexturesHash; + private Hashtable loginError; + private Hashtable uiConfigHash; + + private ArrayList loginFlags; + private ArrayList globalTextures; + private ArrayList eventCategories; + private ArrayList uiConfig; + private ArrayList classifiedCategories; + private ArrayList inventoryRoot; + private ArrayList initialOutfit; + private ArrayList agentInventory; + private ArrayList inventoryLibraryOwner; + private ArrayList inventoryLibRoot; + private ArrayList inventoryLibrary; + private ArrayList activeGestures; + + private UserInfo userProfile; + + private UUID agentID; + private UUID sessionID; + private UUID secureSessionID; + + // Login Flags + private string dst; + private string stipendSinceLogin; + private string gendered; + private string everLoggedIn; + private string login; + private uint simPort; + private uint simHttpPort; + private string simAddress; + private string agentAccess; + private Int32 circuitCode; + private uint regionX; + private uint regionY; + + // Login + private string firstname; + private string lastname; + + // Global Textures + private string sunTexture; + private string cloudTexture; + private string moonTexture; + + // Error Flags + private string errorReason; + private string errorMessage; + + // Response + private XmlRpcResponse xmlRpcResponse; + // private XmlRpcResponse defaultXmlRpcResponse; + + private string welcomeMessage; + private string startLocation; + private string allowFirstLife; + private string home; + private string seedCapability; + private string lookAt; + + private BuddyList m_buddyList = null; + + public LoginResponse() + { + loginFlags = new ArrayList(); + globalTextures = new ArrayList(); + eventCategories = new ArrayList(); + uiConfig = new ArrayList(); + classifiedCategories = new ArrayList(); + + loginError = new Hashtable(); + uiConfigHash = new Hashtable(); + + // defaultXmlRpcResponse = new XmlRpcResponse(); + userProfile = new UserInfo(); + inventoryRoot = new ArrayList(); + initialOutfit = new ArrayList(); + agentInventory = new ArrayList(); + inventoryLibrary = new ArrayList(); + inventoryLibraryOwner = new ArrayList(); + activeGestures = new ArrayList(); + + xmlRpcResponse = new XmlRpcResponse(); + // defaultXmlRpcResponse = new XmlRpcResponse(); + + SetDefaultValues(); + } + + private void SetDefaultValues() + { + DST = "N"; + StipendSinceLogin = "N"; + Gendered = "Y"; + EverLoggedIn = "Y"; + login = "false"; + firstname = "Test"; + lastname = "User"; + agentAccess = "M"; + startLocation = "last"; + allowFirstLife = "Y"; + + SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; + MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; + + ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + ErrorReason = "key"; + welcomeMessage = "Welcome to OpenSim!"; + seedCapability = String.Empty; + home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + + userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + + userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + + userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; + lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + RegionX = (uint) 255232; + RegionY = (uint) 254976; + + // Classifieds; + AddClassifiedCategory((Int32) 1, "Shopping"); + AddClassifiedCategory((Int32) 2, "Land Rental"); + AddClassifiedCategory((Int32) 3, "Property Rental"); + AddClassifiedCategory((Int32) 4, "Special Attraction"); + AddClassifiedCategory((Int32) 5, "New Products"); + AddClassifiedCategory((Int32) 6, "Employment"); + AddClassifiedCategory((Int32) 7, "Wanted"); + AddClassifiedCategory((Int32) 8, "Service"); + AddClassifiedCategory((Int32) 9, "Personal"); + + SessionID = UUID.Random(); + SecureSessionID = UUID.Random(); + AgentID = UUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + initialOutfit.Add(InitialOutfitHash); + } + + #region Login Failure Methods + + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) + { + // Overwrite any default values; + xmlRpcResponse = new XmlRpcResponse(); + + // Ensure Login Failed message/reason; + ErrorMessage = message; + ErrorReason = reason; + + loginError["reason"] = ErrorReason; + loginError["message"] = ErrorMessage; + loginError["login"] = login; + xmlRpcResponse.Value = loginError; + return (xmlRpcResponse); + } + + public OSD GenerateFailureResponseLLSD(string reason, string message, string login) + { + OSDMap map = new OSDMap(); + + // Ensure Login Failed message/reason; + ErrorMessage = message; + ErrorReason = reason; + + map["reason"] = OSD.FromString(ErrorReason); + map["message"] = OSD.FromString(ErrorMessage); + map["login"] = OSD.FromString(login); + + return map; + } + + public XmlRpcResponse CreateFailedResponse() + { + return (CreateLoginFailedResponse()); + } + + public OSD CreateFailedResponseLLSD() + { + return CreateLoginFailedResponseLLSD(); + } + + public XmlRpcResponse CreateLoginFailedResponse() + { + return + (GenerateFailureResponse("key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false")); + } + + public OSD CreateLoginFailedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false"); + } + + /// + /// Response to indicate that login failed because the agent's inventory was not available. + /// + /// + public XmlRpcResponse CreateLoginInventoryFailedResponse() + { + return GenerateFailureResponse( + "key", + "The avatar inventory service is not responding. Please notify your login region operator.", + "false"); + } + + public XmlRpcResponse CreateAlreadyLoggedInResponse() + { + return + (GenerateFailureResponse("presence", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner. " + + "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", + "false")); + } + + public OSD CreateAlreadyLoggedInResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "You appear to be already logged in. " + + "If this is not the case please wait for your session to timeout. " + + "If this takes longer than a few minutes please contact the grid owner", + "false"); + } + + public XmlRpcResponse CreateLoginBlockedResponse() + { + return + (GenerateFailureResponse("presence", + "Logins are currently restricted. Please try again later", + "false")); + } + + public OSD CreateLoginBlockedResponseLLSD() + { + return GenerateFailureResponseLLSD( + "presence", + "Logins are currently restricted. Please try again later", + "false"); + } + + public XmlRpcResponse CreateDeadRegionResponse() + { + return + (GenerateFailureResponse("key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false")); + } + + public OSD CreateDeadRegionResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false"); + } + + public XmlRpcResponse CreateGridErrorResponse() + { + return + (GenerateFailureResponse("key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false")); + } + + public OSD CreateGridErrorResponseLLSD() + { + return GenerateFailureResponseLLSD( + "key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false"); + } + + #endregion + + public virtual XmlRpcResponse ToXmlRpcResponse() + { + try + { + Hashtable responseData = new Hashtable(); + + loginFlagsHash = new Hashtable(); + loginFlagsHash["daylight_savings"] = DST; + loginFlagsHash["stipend_since_login"] = StipendSinceLogin; + loginFlagsHash["gendered"] = Gendered; + loginFlagsHash["ever_logged_in"] = EverLoggedIn; + loginFlags.Add(loginFlagsHash); + + responseData["first_name"] = Firstname; + responseData["last_name"] = Lastname; + responseData["agent_access"] = agentAccess; + + globalTexturesHash = new Hashtable(); + globalTexturesHash["sun_texture_id"] = SunTexture; + globalTexturesHash["cloud_texture_id"] = CloudTexture; + globalTexturesHash["moon_texture_id"] = MoonTexture; + globalTextures.Add(globalTexturesHash); + // this.eventCategories.Add(this.eventCategoriesHash); + + AddToUIConfig("allow_first_life", allowFirstLife); + uiConfig.Add(uiConfigHash); + + responseData["sim_port"] = (Int32) SimPort; + responseData["sim_ip"] = SimAddress; + responseData["http_port"] = (Int32)SimHttpPort; + + responseData["agent_id"] = AgentID.ToString(); + responseData["session_id"] = SessionID.ToString(); + responseData["secure_session_id"] = SecureSessionID.ToString(); + responseData["circuit_code"] = CircuitCode; + responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = loginFlags; + responseData["global-textures"] = globalTextures; + responseData["seed_capability"] = seedCapability; + + responseData["event_categories"] = eventCategories; + responseData["event_notifications"] = new ArrayList(); // todo + responseData["classified_categories"] = classifiedCategories; + responseData["ui-config"] = uiConfig; + + responseData["inventory-skeleton"] = agentInventory; + responseData["inventory-skel-lib"] = inventoryLibrary; + responseData["inventory-root"] = inventoryRoot; + responseData["inventory-lib-root"] = inventoryLibRoot; + responseData["gestures"] = activeGestures; + responseData["inventory-lib-owner"] = inventoryLibraryOwner; + responseData["initial-outfit"] = initialOutfit; + responseData["start_location"] = startLocation; + responseData["seed_capability"] = seedCapability; + responseData["home"] = home; + responseData["look_at"] = lookAt; + responseData["message"] = welcomeMessage; + responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); + responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); + + //responseData["inventory-lib-root"] = new ArrayList(); // todo + + if (m_buddyList != null) + { + responseData["buddy-list"] = m_buddyList.ToArray(); + } + + responseData["login"] = "true"; + xmlRpcResponse.Value = responseData; + + return (xmlRpcResponse); + } + catch (Exception e) + { + m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); + + return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); + } + } + + public OSD ToLLSDResponse() + { + try + { + OSDMap map = new OSDMap(); + + map["first_name"] = OSD.FromString(Firstname); + map["last_name"] = OSD.FromString(Lastname); + map["agent_access"] = OSD.FromString(agentAccess); + + map["sim_port"] = OSD.FromInteger(SimPort); + map["sim_ip"] = OSD.FromString(SimAddress); + + map["agent_id"] = OSD.FromUUID(AgentID); + map["session_id"] = OSD.FromUUID(SessionID); + map["secure_session_id"] = OSD.FromUUID(SecureSessionID); + map["circuit_code"] = OSD.FromInteger(CircuitCode); + map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); + + #region Login Flags + + OSDMap loginFlagsLLSD = new OSDMap(); + loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); + loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); + loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); + loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); + map["login-flags"] = WrapOSDMap(loginFlagsLLSD); + + #endregion Login Flags + + #region Global Textures + + OSDMap globalTexturesLLSD = new OSDMap(); + globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); + globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); + globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); + + map["global-textures"] = WrapOSDMap(globalTexturesLLSD); + + #endregion Global Textures + + map["seed_capability"] = OSD.FromString(seedCapability); + + map["event_categories"] = ArrayListToOSDArray(eventCategories); + //map["event_notifications"] = new OSDArray(); // todo + map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); + + #region UI Config + + OSDMap uiConfigLLSD = new OSDMap(); + uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); + map["ui-config"] = WrapOSDMap(uiConfigLLSD); + + #endregion UI Config + + #region Inventory + + map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); + + map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); + map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; + map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); + map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); + + #endregion Inventory + + map["gestures"] = ArrayListToOSDArray(activeGestures); + + map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); + map["start_location"] = OSD.FromString(startLocation); + + map["seed_capability"] = OSD.FromString(seedCapability); + map["home"] = OSD.FromString(home); + map["look_at"] = OSD.FromString(lookAt); + map["message"] = OSD.FromString(welcomeMessage); + map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); + map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); + + if (m_buddyList != null) + { + map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); + } + + map["login"] = OSD.FromString("true"); + + return map; + } + catch (Exception e) + { + m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); + + return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); + } + } + + public OSDArray ArrayListToOSDArray(ArrayList arrlst) + { + OSDArray llsdBack = new OSDArray(); + foreach (Hashtable ht in arrlst) + { + OSDMap mp = new OSDMap(); + foreach (DictionaryEntry deHt in ht) + { + mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); + } + llsdBack.Add(mp); + } + return llsdBack; + } + + private static OSDArray WrapOSDMap(OSDMap wrapMe) + { + OSDArray array = new OSDArray(); + array.Add(wrapMe); + return array; + } + + public void SetEventCategories(string category, string value) + { + // this.eventCategoriesHash[category] = value; + //TODO + } + + public void AddToUIConfig(string itemName, string item) + { + uiConfigHash[itemName] = item; + } + + public void AddClassifiedCategory(Int32 ID, string categoryName) + { + Hashtable hash = new Hashtable(); + hash["category_name"] = categoryName; + hash["category_id"] = ID; + classifiedCategories.Add(hash); + // this.classifiedCategoriesHash.Clear(); + } + + #region Properties + + public string Login + { + get { return login; } + set { login = value; } + } + + public string DST + { + get { return dst; } + set { dst = value; } + } + + public string StipendSinceLogin + { + get { return stipendSinceLogin; } + set { stipendSinceLogin = value; } + } + + public string Gendered + { + get { return gendered; } + set { gendered = value; } + } + + public string EverLoggedIn + { + get { return everLoggedIn; } + set { everLoggedIn = value; } + } + + public uint SimPort + { + get { return simPort; } + set { simPort = value; } + } + + public uint SimHttpPort + { + get { return simHttpPort; } + set { simHttpPort = value; } + } + + public string SimAddress + { + get { return simAddress; } + set { simAddress = value; } + } + + public UUID AgentID + { + get { return agentID; } + set { agentID = value; } + } + + public UUID SessionID + { + get { return sessionID; } + set { sessionID = value; } + } + + public UUID SecureSessionID + { + get { return secureSessionID; } + set { secureSessionID = value; } + } + + public Int32 CircuitCode + { + get { return circuitCode; } + set { circuitCode = value; } + } + + public uint RegionX + { + get { return regionX; } + set { regionX = value; } + } + + public uint RegionY + { + get { return regionY; } + set { regionY = value; } + } + + public string SunTexture + { + get { return sunTexture; } + set { sunTexture = value; } + } + + public string CloudTexture + { + get { return cloudTexture; } + set { cloudTexture = value; } + } + + public string MoonTexture + { + get { return moonTexture; } + set { moonTexture = value; } + } + + public string Firstname + { + get { return firstname; } + set { firstname = value; } + } + + public string Lastname + { + get { return lastname; } + set { lastname = value; } + } + + public string AgentAccess + { + get { return agentAccess; } + set { agentAccess = value; } + } + + public string StartLocation + { + get { return startLocation; } + set { startLocation = value; } + } + + public string LookAt + { + get { return lookAt; } + set { lookAt = value; } + } + + public string SeedCapability + { + get { return seedCapability; } + set { seedCapability = value; } + } + + public string ErrorReason + { + get { return errorReason; } + set { errorReason = value; } + } + + public string ErrorMessage + { + get { return errorMessage; } + set { errorMessage = value; } + } + + public ArrayList InventoryRoot + { + get { return inventoryRoot; } + set { inventoryRoot = value; } + } + + public ArrayList InventorySkeleton + { + get { return agentInventory; } + set { agentInventory = value; } + } + + public ArrayList InventoryLibrary + { + get { return inventoryLibrary; } + set { inventoryLibrary = value; } + } + + public ArrayList InventoryLibraryOwner + { + get { return inventoryLibraryOwner; } + set { inventoryLibraryOwner = value; } + } + + public ArrayList InventoryLibRoot + { + get { return inventoryLibRoot; } + set { inventoryLibRoot = value; } + } + + public ArrayList ActiveGestures + { + get { return activeGestures; } + set { activeGestures = value; } + } + + public string Home + { + get { return home; } + set { home = value; } + } + + public string Message + { + get { return welcomeMessage; } + set { welcomeMessage = value; } + } + + public BuddyList BuddList + { + get { return m_buddyList; } + set { m_buddyList = value; } + } + + #endregion + + public class UserInfo + { + public string firstname; + public string lastname; + public ulong homeregionhandle; + public Vector3 homepos; + public Vector3 homelookat; + } + + public class BuddyList + { + public List Buddies = new List(); + + public void AddNewBuddy(BuddyInfo buddy) + { + if (!Buddies.Contains(buddy)) + { + Buddies.Add(buddy); + } + } + + public ArrayList ToArray() + { + ArrayList buddyArray = new ArrayList(); + foreach (BuddyInfo buddy in Buddies) + { + buddyArray.Add(buddy.ToHashTable()); + } + return buddyArray; + } + + public class BuddyInfo + { + public int BuddyRightsHave = 1; + public int BuddyRightsGiven = 1; + public UUID BuddyID; + + public BuddyInfo(string buddyID) + { + BuddyID = new UUID(buddyID); + } + + public BuddyInfo(UUID buddyID) + { + BuddyID = buddyID; + } + + public Hashtable ToHashTable() + { + Hashtable hTable = new Hashtable(); + hTable["buddy_rights_has"] = BuddyRightsHave; + hTable["buddy_rights_given"] = BuddyRightsGiven; + hTable["buddy_id"] = BuddyID.ToString(); + return hTable; + } + } + } + } +} diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 51158c9..1b6520d 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1,1093 +1,1093 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using System.Web; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Statistics; - -namespace OpenSim.Framework.Communications.Services -{ - public abstract class LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected int m_minLoginLevel = 0; - protected UserManagerBase m_userManager = null; - protected Mutex m_loginMutex = new Mutex(false); - - /// - /// Used during login to send the skeleton of the OpenSim Library to the client. - /// - protected LibraryRootFolder m_libraryRootFolder; - - protected uint m_defaultHomeX; - protected uint m_defaultHomeY; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_inventoryService; - - /// - /// Constructor - /// - /// - /// - /// - public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, - string welcomeMess) - { - m_userManager = userManager; - m_libraryRootFolder = libraryRootFolder; - - if (welcomeMess != String.Empty) - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// If the user is already logged in, try to notify the region that the user they've got is dead. - /// - /// - public virtual void LogOffUser(UserProfileData theUser, string message) - { - } - - - /// - /// Called when we receive the client's initial XMLRPC login_to_simulator request message - /// - /// The XMLRPC request - /// The response to send - public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. - //CKF: m_log.Info("[LOGIN]: Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - SniffLoginKey((Uri)request.Params[2], requestData); - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && - (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - - string startLocationRequest = "last"; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - string firstname; - string lastname; - - if (GoodXML) - { - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - } - - firstname = (string)requestData["first"]; - lastname = (string)requestData["last"]; - - m_log.InfoFormat( - "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", - firstname, lastname); - - string clientVersion = "Unknown"; - - if (requestData.Contains("version")) - { - clientVersion = (string)requestData["version"]; - } - - m_log.DebugFormat( - "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - - if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) - { - return logResponse.CreateLoginFailedResponse(); - } - } - else - { - m_log.Info( - "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); - - return logResponse.CreateGridErrorResponse(); - } - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponse(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - //TODO: The following statements can cause trouble: - // If agentOnline could not turn from true back to false normally - // because of some problem, for instance, the crashment of server or client, - // the user cannot log in any longer. - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - - // try to tell the region that their user is dead. - LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); - - // Reject the login - - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", - firstname, lastname); - - return logResponse.CreateAlreadyLoggedInResponse(); - } - - // Otherwise... - // Create a new agent session - - m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - try - { - UUID agentID = userProfile.ID; - InventoryData inventData; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", - agentID, e); - - return logResponse.CreateLoginInventoryFailedResponse(); - } - - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) - { - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); - - return logResponse.ToXmlRpcResponse(); - } - else - { - m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); - return logResponse.CreateDeadRegionResponse(); - } - } - catch (Exception e) - { - m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); - m_log.Error(e.StackTrace); - } - } - - m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); - return response; - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) - { - Hashtable requestData = (Hashtable)request.Params[0]; - - bool GoodLogin = false; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); - } - else - { - if (requestData.Contains("passwd")) - { - string passwd = (string)requestData["passwd"]; - GoodLogin = AuthenticateUser(userProfile, passwd); - } - if (!GoodLogin && (requestData.Contains("web_login_key"))) - { - try - { - UUID webloginkey = new UUID((string)requestData["web_login_key"]); - GoodLogin = AuthenticateUser(userProfile, webloginkey); - } - catch (Exception e) - { - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", - requestData["web_login_key"], firstname, lastname, e); - } - } - } - - return GoodLogin; - } - - protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) - { - bool GoodLogin = false; - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); - - return false; - } - - GoodLogin = AuthenticateUser(userProfile, passwd); - return GoodLogin; - } - - /// - /// Called when we receive the client's initial LLSD login_to_simulator request message - /// - /// The LLSD request - /// The response to send - public OSD LLSDLoginMethod(OSD request) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - // bool GoodLogin = false; - - string startLocationRequest = "last"; - - UserProfileData userProfile = null; - LoginResponse logResponse = new LoginResponse(); - - if (request.Type == OSDType.Map) - { - OSDMap map = (OSDMap)request; - - if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) - { - string firstname = map["first"].AsString(); - string lastname = map["last"].AsString(); - string passwd = map["passwd"].AsString(); - - if (map.ContainsKey("start")) - { - m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); - startLocationRequest = map["start"].AsString(); - } - m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); - - if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) - { - return logResponse.CreateLoginFailedResponseLLSD(); - } - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponseLLSD(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - // try to tell the region that their user is dead. - LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); - - // Reject the login - - m_log.InfoFormat( - "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", - userProfile.FirstName, userProfile.SurName); - - userProfile.CurrentAgent = null; - return logResponse.CreateAlreadyLoggedInResponseLLSD(); - } - - // Otherwise... - // Create a new agent session - - m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - try - { - UUID agentID = userProfile.ID; - - //InventoryData inventData = GetInventorySkeleton(agentID); - InventoryData inventData = null; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", - agentID, e.GetType(), e.Message); - - return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); - } - - - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; - - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - try - { - CustomiseResponse(logResponse, userProfile, startLocationRequest); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateDeadRegionResponseLLSD(); - } - - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", - userProfile.FirstName, userProfile.SurName); - - return logResponse.ToLLSDResponse(); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateFailedResponseLLSD(); - } - } - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - public Hashtable ProcessHTMLLogin(Hashtable keysvals) - { - // Matches all unspecified characters - // Currently specified,; lowercase letters, upper case letters, numbers, underline - // period, space, parens, and dash. - - Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); - - Hashtable returnactions = new Hashtable(); - int statuscode = 200; - - string firstname = String.Empty; - string lastname = String.Empty; - string location = String.Empty; - string region = String.Empty; - string grid = String.Empty; - string channel = String.Empty; - string version = String.Empty; - string lang = String.Empty; - string password = String.Empty; - string errormessages = String.Empty; - - // the client requires the HTML form field be named 'username' - // however, the data it sends when it loads the first time is 'firstname' - // another one of those little nuances. - - if (keysvals.Contains("firstname")) - firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); - - if (keysvals.Contains("username")) - firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); - - if (keysvals.Contains("lastname")) - lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); - - if (keysvals.Contains("location")) - location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); - - if (keysvals.Contains("region")) - region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); - - if (keysvals.Contains("grid")) - grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); - - if (keysvals.Contains("channel")) - channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); - - if (keysvals.Contains("version")) - version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); - - if (keysvals.Contains("lang")) - lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); - - if (keysvals.Contains("password")) - password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); - - // load our login form. - string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - - if (keysvals.ContainsKey("show_login_form")) - { - UserProfileData user = GetTheUser(firstname, lastname); - bool goodweblogin = false; - - if (user != null) - goodweblogin = AuthenticateUser(user, password); - - if (goodweblogin) - { - UUID webloginkey = UUID.Random(); - m_userManager.StoreWebLoginKey(user.ID, webloginkey); - //statuscode = 301; - - // string redirectURL = "about:blank?redirect-http-hack=" + - // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + - // lastname + - // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); - //m_log.Info("[WEB]: R:" + redirectURL); - returnactions["int_response_code"] = statuscode; - //returnactions["str_redirect_location"] = redirectURL; - //returnactions["str_response_string"] = "GoodLogin"; - returnactions["str_response_string"] = webloginkey.ToString(); - } - else - { - errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; - - loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - } - else - { - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - return returnactions; - } - - public string GetLoginForm(string firstname, string lastname, string location, string region, - string grid, string channel, string version, string lang, - string password, string errormessages) - { - // inject our values in the form at the markers - - string loginform = String.Empty; - string file = Path.Combine(Util.configDir(), "http_loginform.html"); - if (!File.Exists(file)) - { - loginform = GetDefaultLoginForm(); - } - else - { - StreamReader sr = File.OpenText(file); - loginform = sr.ReadToEnd(); - sr.Close(); - } - - loginform = loginform.Replace("[$firstname]", firstname); - loginform = loginform.Replace("[$lastname]", lastname); - loginform = loginform.Replace("[$location]", location); - loginform = loginform.Replace("[$region]", region); - loginform = loginform.Replace("[$grid]", grid); - loginform = loginform.Replace("[$channel]", channel); - loginform = loginform.Replace("[$version]", version); - loginform = loginform.Replace("[$lang]", lang); - loginform = loginform.Replace("[$password]", password); - loginform = loginform.Replace("[$errors]", errormessages); - - return loginform; - } - - public string GetDefaultLoginForm() - { - string responseString = - ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "OpenSim Login"; - responseString += "
"; - responseString += "
"; - - responseString += "
"; - - responseString += "
[$errors]
"; - responseString += "
"; - responseString += "First Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Last Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Password:"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += "
Connecting...
"; - - responseString += "
"; - - responseString += "
[$channel] | [$version]=[$lang]
"; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - - return responseString; - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - return m_userManager.CommitAgent(ref profile); - } - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - bool passwordSuccess = false; - //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Web Login method seems to also occasionally send the hashed password itself - - // we do this to get our hash in a form that the server password code can consume - // when the web-login-form submits the password in the clear (supposed to be over SSL!) - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - // Testing... - //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); - //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - - passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); - - return passwordSuccess; - } - - public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) - { - bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Match web login key unless it's the default weblogin key UUID.Zero - passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); - - return passwordSuccess; - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - m_userManager.CreateAgent(profile, request); - } - - public void CreateAgent(UserProfileData profile, OSD request) - { - m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) - { - LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); - foreach (FriendListItem fl in LFL) - { - LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); - buddyitem.BuddyID = fl.Friend; - buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; - buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; - buddylistreturn.AddNewBuddy(buddyitem); - } - return buddylistreturn; - } - - /// - /// Converts the inventory library skeleton into the form required by the rpc request. - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - Dictionary rootFolders - = m_libraryRootFolder.RequestSelfAndDescendentFolders(); - ArrayList folderHashes = new ArrayList(); - - foreach (InventoryFolderBase folder in rootFolders.Values) - { - Hashtable TempHash = new Hashtable(); - TempHash["name"] = folder.Name; - TempHash["parent_id"] = folder.ParentID.ToString(); - TempHash["version"] = (Int32)folder.Version; - TempHash["type_default"] = (Int32)folder.Type; - TempHash["folder_id"] = folder.ID.ToString(); - folderHashes.Add(TempHash); - } - - return folderHashes; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public UUID RootFolderID = UUID.Zero; - - public InventoryData(ArrayList invList, UUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - - protected void SniffLoginKey(Uri uri, Hashtable requestData) - { - string uri_str = uri.ToString(); - string[] parts = uri_str.Split(new char[] { '=' }); - if (parts.Length > 1) - { - string web_login_key = parts[1]; - requestData.Add("web_login_key", web_login_key); - m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); - } - } - - /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// The requested start location - /// true on success, false if the region was not successfully told to expect a user connection - public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) - { - // add active gestures to login-response - AddActiveGestures(response, theUser); - - // HomeLocation - RegionInfo homeInfo = null; - - // use the homeRegionID if it is stored already. If not, use the regionHandle as before - UUID homeRegionId = theUser.HomeRegionID; - ulong homeRegionHandle = theUser.HomeRegion; - if (homeRegionId != UUID.Zero) - { - homeInfo = GetRegionInfo(homeRegionId); - } - else - { - homeInfo = GetRegionInfo(homeRegionHandle); - } - - if (homeInfo != null) - { - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - (homeInfo.RegionLocX * Constants.RegionSize), - (homeInfo.RegionLocY * Constants.RegionSize), - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - } - else - { - m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); - // Emergency mode: Home-region isn't available, so we can't request the region info. - // Use the stored home regionHandle instead. - // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = homeRegionHandle >> 32; - ulong regionY = homeRegionHandle & 0xffffffff; - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - regionX, regionY, - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - - m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", - theUser.FirstName, theUser.SurName, - regionX, regionY); - } - - // StartLocation - RegionInfo regionInfo = null; - if (startLocationRequest == "home") - { - regionInfo = homeInfo; - theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; - } - else if (startLocationRequest == "last") - { - UUID lastRegion = theUser.CurrentAgent.Region; - regionInfo = GetRegionInfo(lastRegion); - response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; - } - else - { - Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); - Match uriMatch = reURI.Match(startLocationRequest); - if (uriMatch == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); - } - else - { - string region = uriMatch.Groups["region"].ToString(); - regionInfo = RequestClosestRegion(region); - if (regionInfo == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); - } - else - { - theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), - float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); - } - } - response.LookAt = "[r0,r1,r0]"; - // can be: last, home, safe, url - response.StartLocation = "url"; - } - - if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) - { - return true; - } - - // StartLocation not available, send him to a nearby region instead - // regionInfo = m_gridService.RequestClosestRegion(""); - //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); - - // Send him to default region instead - ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | - ((ulong)m_defaultHomeY * Constants.RegionSize); - - if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) - { - m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); - return false; - } - - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - - if (regionInfo == null) - { - m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); - return false; - } - - theUser.CurrentAgent.Position = new Vector3(128, 128, 0); - response.StartLocation = "safe"; - - return PrepareLoginToRegion(regionInfo, theUser, response); - } - - protected abstract RegionInfo RequestClosestRegion(string region); - protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); - protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); - - /// - /// Add active gestures of the user to the login response. - /// - /// - /// A - /// - /// - /// A - /// - protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) - { - List gestures = m_inventoryService.GetActiveGestures(theUser.ID); - //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); - ArrayList list = new ArrayList(); - if (gestures != null) - { - foreach (InventoryItemBase gesture in gestures) - { - Hashtable item = new Hashtable(); - item["item_id"] = gesture.ID.ToString(); - item["asset_id"] = gesture.AssetID.ToString(); - list.Add(item); - } - } - response.ActiveGestures = list; - } - - /// - /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. - /// - /// - /// - /// This will be thrown if there is a problem with the inventory service - protected InventoryData GetInventorySkeleton(UUID userID) - { - List folders = m_inventoryService.GetInventorySkeleton(userID); - - // If we have user auth but no inventory folders for some reason, create a new set of folders. - if (folders == null || folders.Count == 0) - { - m_log.InfoFormat( - "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); - - // Although the create user function creates a new agent inventory along with a new user profile, some - // tools are creating the user profile directly in the database without creating the inventory. At - // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already - // exist. - if (!m_inventoryService.CreateNewUserInventory(userID)) - { - throw new Exception( - String.Format( - "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", - userID)); - } - - m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); - - folders = m_inventoryService.GetInventorySkeleton(userID); - - if (folders == null || folders.Count == 0) - { - throw new Exception( - String.Format( - "A root inventory folder for user {0} could not be retrieved from the inventory service", - userID)); - } - } - - UUID rootID = UUID.Zero; - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolderBase InvFolder in folders) - { - if (InvFolder.ParentID == UUID.Zero) - { - rootID = InvFolder.ID; - } - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.Name; - TempHash["parent_id"] = InvFolder.ParentID.ToString(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.Type; - TempHash["folder_id"] = InvFolder.ID.ToString(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, rootID); - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading; +using System.Web; +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Statistics; + +namespace OpenSim.Framework.Communications.Services +{ + public abstract class LoginService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected string m_welcomeMessage = "Welcome to OpenSim"; + protected int m_minLoginLevel = 0; + protected UserManagerBase m_userManager = null; + protected Mutex m_loginMutex = new Mutex(false); + + /// + /// Used during login to send the skeleton of the OpenSim Library to the client. + /// + protected LibraryRootFolder m_libraryRootFolder; + + protected uint m_defaultHomeX; + protected uint m_defaultHomeY; + + /// + /// Used by the login service to make requests to the inventory service. + /// + protected IInterServiceInventoryServices m_inventoryService; + + /// + /// Constructor + /// + /// + /// + /// + public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, + string welcomeMess) + { + m_userManager = userManager; + m_libraryRootFolder = libraryRootFolder; + + if (welcomeMess != String.Empty) + { + m_welcomeMessage = welcomeMess; + } + } + + /// + /// If the user is already logged in, try to notify the region that the user they've got is dead. + /// + /// + public virtual void LogOffUser(UserProfileData theUser, string message) + { + } + + + /// + /// Called when we receive the client's initial XMLRPC login_to_simulator request message + /// + /// The XMLRPC request + /// The response to send + public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + // Temporary fix + m_loginMutex.WaitOne(); + + try + { + //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. + //CKF: m_log.Info("[LOGIN]: Attempting login now..."); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + SniffLoginKey((Uri)request.Params[2], requestData); + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && + (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); + + string startLocationRequest = "last"; + + UserProfileData userProfile; + LoginResponse logResponse = new LoginResponse(); + + string firstname; + string lastname; + + if (GoodXML) + { + if (requestData.Contains("start")) + { + startLocationRequest = (string)requestData["start"]; + } + + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + + m_log.InfoFormat( + "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", + firstname, lastname); + + string clientVersion = "Unknown"; + + if (requestData.Contains("version")) + { + clientVersion = (string)requestData["version"]; + } + + m_log.DebugFormat( + "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); + + if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) + { + return logResponse.CreateLoginFailedResponse(); + } + } + else + { + m_log.Info( + "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); + + return logResponse.CreateGridErrorResponse(); + } + + if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponse(); + } + else + { + // If we already have a session... + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) + { + //TODO: The following statements can cause trouble: + // If agentOnline could not turn from true back to false normally + // because of some problem, for instance, the crashment of server or client, + // the user cannot log in any longer. + userProfile.CurrentAgent.AgentOnline = false; + + m_userManager.CommitAgent(ref userProfile); + + // try to tell the region that their user is dead. + LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); + + // Reject the login + + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", + firstname, lastname); + + return logResponse.CreateAlreadyLoggedInResponse(); + } + + // Otherwise... + // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + + CreateAgent(userProfile, request); + + try + { + UUID agentID = userProfile.ID; + InventoryData inventData; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", + agentID, e); + + return logResponse.CreateLoginInventoryFailedResponse(); + } + + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderID = inventData.RootFolderID; + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + + logResponse.CircuitCode = Util.RandomClass.Next(); + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; + logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; + + if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) + { + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + + return logResponse.ToXmlRpcResponse(); + } + else + { + m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); + return logResponse.CreateDeadRegionResponse(); + } + } + catch (Exception e) + { + m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); + m_log.Error(e.StackTrace); + } + } + + m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); + return response; + } + finally + { + m_loginMutex.ReleaseMutex(); + } + } + + protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodLogin = false; + + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); + } + else + { + if (requestData.Contains("passwd")) + { + string passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(userProfile, passwd); + } + if (!GoodLogin && (requestData.Contains("web_login_key"))) + { + try + { + UUID webloginkey = new UUID((string)requestData["web_login_key"]); + GoodLogin = AuthenticateUser(userProfile, webloginkey); + } + catch (Exception e) + { + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); + } + } + } + + return GoodLogin; + } + + protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) + { + bool GoodLogin = false; + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) + { + m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); + + return false; + } + + GoodLogin = AuthenticateUser(userProfile, passwd); + return GoodLogin; + } + + /// + /// Called when we receive the client's initial LLSD login_to_simulator request message + /// + /// The LLSD request + /// The response to send + public OSD LLSDLoginMethod(OSD request) + { + // Temporary fix + m_loginMutex.WaitOne(); + + try + { + // bool GoodLogin = false; + + string startLocationRequest = "last"; + + UserProfileData userProfile = null; + LoginResponse logResponse = new LoginResponse(); + + if (request.Type == OSDType.Map) + { + OSDMap map = (OSDMap)request; + + if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) + { + string firstname = map["first"].AsString(); + string lastname = map["last"].AsString(); + string passwd = map["passwd"].AsString(); + + if (map.ContainsKey("start")) + { + m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); + startLocationRequest = map["start"].AsString(); + } + m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); + + if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) + { + return logResponse.CreateLoginFailedResponseLLSD(); + } + } + else + return logResponse.CreateLoginFailedResponseLLSD(); + } + else + return logResponse.CreateLoginFailedResponseLLSD(); + + + if (userProfile.GodLevel < m_minLoginLevel) + { + return logResponse.CreateLoginBlockedResponseLLSD(); + } + else + { + // If we already have a session... + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) + { + userProfile.CurrentAgent.AgentOnline = false; + + m_userManager.CommitAgent(ref userProfile); + // try to tell the region that their user is dead. + LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); + + // Reject the login + + m_log.InfoFormat( + "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", + userProfile.FirstName, userProfile.SurName); + + userProfile.CurrentAgent = null; + return logResponse.CreateAlreadyLoggedInResponseLLSD(); + } + + // Otherwise... + // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + + CreateAgent(userProfile, request); + + try + { + UUID agentID = userProfile.ID; + + //InventoryData inventData = GetInventorySkeleton(agentID); + InventoryData inventData = null; + + try + { + inventData = GetInventorySkeleton(agentID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", + agentID, e.GetType(), e.Message); + + return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); + } + + + ArrayList AgentInventoryArray = inventData.InventoryArray; + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderID = inventData.RootFolderID; + + + // Inventory Library Section + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + ArrayList InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); + + logResponse.InventoryLibRoot = InventoryLibRoot; + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.InventoryLibrary = GetInventoryLibrary(); + + logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; + logResponse.AgentID = agentID; + logResponse.SessionID = userProfile.CurrentAgent.SessionID; + logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; + logResponse.Message = GetMessage(); + logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); + logResponse.StartLocation = startLocationRequest; + + try + { + CustomiseResponse(logResponse, userProfile, startLocationRequest); + } + catch (Exception ex) + { + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); + return logResponse.CreateDeadRegionResponseLLSD(); + } + + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", + userProfile.FirstName, userProfile.SurName); + + return logResponse.ToLLSDResponse(); + } + catch (Exception ex) + { + m_log.Info("[LOGIN]: LLSD " + ex.ToString()); + return logResponse.CreateFailedResponseLLSD(); + } + } + } + finally + { + m_loginMutex.ReleaseMutex(); + } + } + + public Hashtable ProcessHTMLLogin(Hashtable keysvals) + { + // Matches all unspecified characters + // Currently specified,; lowercase letters, upper case letters, numbers, underline + // period, space, parens, and dash. + + Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); + + Hashtable returnactions = new Hashtable(); + int statuscode = 200; + + string firstname = String.Empty; + string lastname = String.Empty; + string location = String.Empty; + string region = String.Empty; + string grid = String.Empty; + string channel = String.Empty; + string version = String.Empty; + string lang = String.Empty; + string password = String.Empty; + string errormessages = String.Empty; + + // the client requires the HTML form field be named 'username' + // however, the data it sends when it loads the first time is 'firstname' + // another one of those little nuances. + + if (keysvals.Contains("firstname")) + firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); + + if (keysvals.Contains("username")) + firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); + + if (keysvals.Contains("lastname")) + lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); + + if (keysvals.Contains("location")) + location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); + + if (keysvals.Contains("region")) + region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); + + if (keysvals.Contains("grid")) + grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); + + if (keysvals.Contains("channel")) + channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); + + if (keysvals.Contains("version")) + version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); + + if (keysvals.Contains("lang")) + lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); + + if (keysvals.Contains("password")) + password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); + + // load our login form. + string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + + if (keysvals.ContainsKey("show_login_form")) + { + UserProfileData user = GetTheUser(firstname, lastname); + bool goodweblogin = false; + + if (user != null) + goodweblogin = AuthenticateUser(user, password); + + if (goodweblogin) + { + UUID webloginkey = UUID.Random(); + m_userManager.StoreWebLoginKey(user.ID, webloginkey); + //statuscode = 301; + + // string redirectURL = "about:blank?redirect-http-hack=" + + // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + // lastname + + // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + //m_log.Info("[WEB]: R:" + redirectURL); + returnactions["int_response_code"] = statuscode; + //returnactions["str_redirect_location"] = redirectURL; + //returnactions["str_response_string"] = "GoodLogin"; + returnactions["str_response_string"] = webloginkey.ToString(); + } + else + { + errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; + + loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; + } + } + else + { + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; + } + return returnactions; + } + + public string GetLoginForm(string firstname, string lastname, string location, string region, + string grid, string channel, string version, string lang, + string password, string errormessages) + { + // inject our values in the form at the markers + + string loginform = String.Empty; + string file = Path.Combine(Util.configDir(), "http_loginform.html"); + if (!File.Exists(file)) + { + loginform = GetDefaultLoginForm(); + } + else + { + StreamReader sr = File.OpenText(file); + loginform = sr.ReadToEnd(); + sr.Close(); + } + + loginform = loginform.Replace("[$firstname]", firstname); + loginform = loginform.Replace("[$lastname]", lastname); + loginform = loginform.Replace("[$location]", location); + loginform = loginform.Replace("[$region]", region); + loginform = loginform.Replace("[$grid]", grid); + loginform = loginform.Replace("[$channel]", channel); + loginform = loginform.Replace("[$version]", version); + loginform = loginform.Replace("[$lang]", lang); + loginform = loginform.Replace("[$password]", password); + loginform = loginform.Replace("[$errors]", errormessages); + + return loginform; + } + + public string GetDefaultLoginForm() + { + string responseString = + ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "OpenSim Login"; + responseString += "
"; + responseString += "
"; + + responseString += "
"; + + responseString += "
[$errors]
"; + responseString += "
"; + responseString += "First Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Last Name:"; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += "Password:"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += ""; + responseString += "
"; + responseString += ""; + responseString += "
"; + responseString += "
Connecting...
"; + + responseString += "
"; + + responseString += "
[$channel] | [$version]=[$lang]
"; + responseString += "
"; + responseString += ""; + responseString += "
"; + responseString += ""; + responseString += ""; + responseString += ""; + + return responseString; + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + return m_userManager.CommitAgent(ref profile); + } + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(UserProfileData profile, string password) + { + bool passwordSuccess = false; + //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); + + // Web Login method seems to also occasionally send the hashed password itself + + // we do this to get our hash in a form that the server password code can consume + // when the web-login-form submits the password in the clear (supposed to be over SSL!) + if (!password.StartsWith("$1$")) + password = "$1$" + Util.Md5Hash(password); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); + // Testing... + //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); + //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); + + passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + + return passwordSuccess; + } + + public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) + { + bool passwordSuccess = false; + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); + + // Match web login key unless it's the default weblogin key UUID.Zero + passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); + + return passwordSuccess; + } + + /// + /// + /// + /// + /// + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) + { + m_userManager.CreateAgent(profile, request); + } + + public void CreateAgent(UserProfileData profile, OSD request) + { + m_userManager.CreateAgent(profile, request); + } + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return m_userManager.GetUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return m_welcomeMessage; + } + + private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) + { + LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); + foreach (FriendListItem fl in LFL) + { + LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); + buddyitem.BuddyID = fl.Friend; + buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; + buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; + buddylistreturn.AddNewBuddy(buddyitem); + } + return buddylistreturn; + } + + /// + /// Converts the inventory library skeleton into the form required by the rpc request. + /// + /// + protected virtual ArrayList GetInventoryLibrary() + { + Dictionary rootFolders + = m_libraryRootFolder.RequestSelfAndDescendentFolders(); + ArrayList folderHashes = new ArrayList(); + + foreach (InventoryFolderBase folder in rootFolders.Values) + { + Hashtable TempHash = new Hashtable(); + TempHash["name"] = folder.Name; + TempHash["parent_id"] = folder.ParentID.ToString(); + TempHash["version"] = (Int32)folder.Version; + TempHash["type_default"] = (Int32)folder.Type; + TempHash["folder_id"] = folder.ID.ToString(); + folderHashes.Add(TempHash); + } + + return folderHashes; + } + + /// + /// + /// + /// + protected virtual ArrayList GetLibraryOwner() + { + //for now create random inventory library owner + Hashtable TempHash = new Hashtable(); + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + ArrayList inventoryLibOwner = new ArrayList(); + inventoryLibOwner.Add(TempHash); + return inventoryLibOwner; + } + + public class InventoryData + { + public ArrayList InventoryArray = null; + public UUID RootFolderID = UUID.Zero; + + public InventoryData(ArrayList invList, UUID rootID) + { + InventoryArray = invList; + RootFolderID = rootID; + } + } + + protected void SniffLoginKey(Uri uri, Hashtable requestData) + { + string uri_str = uri.ToString(); + string[] parts = uri_str.Split(new char[] { '=' }); + if (parts.Length > 1) + { + string web_login_key = parts[1]; + requestData.Add("web_login_key", web_login_key); + m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); + } + } + + /// + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. + /// + /// The existing response + /// The user profile + /// The requested start location + /// true on success, false if the region was not successfully told to expect a user connection + public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + { + // add active gestures to login-response + AddActiveGestures(response, theUser); + + // HomeLocation + RegionInfo homeInfo = null; + + // use the homeRegionID if it is stored already. If not, use the regionHandle as before + UUID homeRegionId = theUser.HomeRegionID; + ulong homeRegionHandle = theUser.HomeRegion; + if (homeRegionId != UUID.Zero) + { + homeInfo = GetRegionInfo(homeRegionId); + } + else + { + homeInfo = GetRegionInfo(homeRegionHandle); + } + + if (homeInfo != null) + { + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + (homeInfo.RegionLocX * Constants.RegionSize), + (homeInfo.RegionLocY * Constants.RegionSize), + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + } + else + { + m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); + // Emergency mode: Home-region isn't available, so we can't request the region info. + // Use the stored home regionHandle instead. + // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again + ulong regionX = homeRegionHandle >> 32; + ulong regionY = homeRegionHandle & 0xffffffff; + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + regionX, regionY, + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + + m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", + theUser.FirstName, theUser.SurName, + regionX, regionY); + } + + // StartLocation + RegionInfo regionInfo = null; + if (startLocationRequest == "home") + { + regionInfo = homeInfo; + theUser.CurrentAgent.Position = theUser.HomeLocation; + response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + } + else if (startLocationRequest == "last") + { + UUID lastRegion = theUser.CurrentAgent.Region; + regionInfo = GetRegionInfo(lastRegion); + response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + } + else + { + Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); + Match uriMatch = reURI.Match(startLocationRequest); + if (uriMatch == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); + } + else + { + string region = uriMatch.Groups["region"].ToString(); + regionInfo = RequestClosestRegion(region); + if (regionInfo == null) + { + m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); + } + else + { + theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), + float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); + } + } + response.LookAt = "[r0,r1,r0]"; + // can be: last, home, safe, url + response.StartLocation = "url"; + } + + if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) + { + return true; + } + + // StartLocation not available, send him to a nearby region instead + // regionInfo = m_gridService.RequestClosestRegion(""); + //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + + // Send him to default region instead + ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | + ((ulong)m_defaultHomeY * Constants.RegionSize); + + if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + { + m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); + return false; + } + + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); + + if (regionInfo == null) + { + m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); + return false; + } + + theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + response.StartLocation = "safe"; + + return PrepareLoginToRegion(regionInfo, theUser, response); + } + + protected abstract RegionInfo RequestClosestRegion(string region); + protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); + protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); + protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); + + /// + /// Add active gestures of the user to the login response. + /// + /// + /// A + /// + /// + /// A + /// + protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) + { + List gestures = m_inventoryService.GetActiveGestures(theUser.ID); + //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); + ArrayList list = new ArrayList(); + if (gestures != null) + { + foreach (InventoryItemBase gesture in gestures) + { + Hashtable item = new Hashtable(); + item["item_id"] = gesture.ID.ToString(); + item["asset_id"] = gesture.AssetID.ToString(); + list.Add(item); + } + } + response.ActiveGestures = list; + } + + /// + /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. + /// + /// + /// + /// This will be thrown if there is a problem with the inventory service + protected InventoryData GetInventorySkeleton(UUID userID) + { + List folders = m_inventoryService.GetInventorySkeleton(userID); + + // If we have user auth but no inventory folders for some reason, create a new set of folders. + if (folders == null || folders.Count == 0) + { + m_log.InfoFormat( + "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); + + // Although the create user function creates a new agent inventory along with a new user profile, some + // tools are creating the user profile directly in the database without creating the inventory. At + // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already + // exist. + if (!m_inventoryService.CreateNewUserInventory(userID)) + { + throw new Exception( + String.Format( + "The inventory creation request for user {0} did not succeed." + + " Please contact your inventory service provider for more information.", + userID)); + } + + m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); + + folders = m_inventoryService.GetInventorySkeleton(userID); + + if (folders == null || folders.Count == 0) + { + throw new Exception( + String.Format( + "A root inventory folder for user {0} could not be retrieved from the inventory service", + userID)); + } + } + + UUID rootID = UUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.ParentID == UUID.Zero) + { + rootID = InvFolder.ID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.Name; + TempHash["parent_id"] = InvFolder.ParentID.ToString(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.Type; + TempHash["folder_id"] = InvFolder.ID.ToString(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, rootID); + } + } +} -- cgit v1.1 From fb9a358b797418fbc4c38dd9ec67e12bb5b7c98a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 31 Mar 2009 05:51:28 +0000 Subject: * Refactored out and de-duplicated Base64ToString(string) * Fixed minor typo --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 73aa6ba..e0d0bd7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -34,6 +34,7 @@ using log4net; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework.Statistics; +using System.Text; namespace OpenSim.Framework.Communications.Cache { @@ -334,7 +335,7 @@ namespace OpenSim.Framework.Communications.Cache { AssetInfo assetInf = new AssetInfo(asset); - ProcessRecievedAsset(IsTexture, assetInf); + ProcessReceivedAsset(IsTexture, assetInf); if (!m_memcache.Contains(assetInf.FullID)) { @@ -389,8 +390,8 @@ namespace OpenSim.Framework.Communications.Cache } } - protected void ProcessRecievedAsset(bool IsTexture, AssetInfo assetInf) - { + protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) + { } // See IAssetReceiver -- cgit v1.1 From d4f6750f8214dea3816b3496c73aef8829423168 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 1 Apr 2009 01:18:21 +0000 Subject: Added AllowLoginWithoutInventory to LoginService, to be overwritten in subclasses. Default is false. HGLoginAuthService sets it true. Better error handling dealing with inventory service faults. --- .../Communications/Services/HGLoginAuthService.cs | 6 ++++ .../Communications/Services/LoginResponse.cs | 9 ++--- .../Communications/Services/LoginService.cs | 41 ++++++++++++++++------ 3 files changed, 41 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 99fbb2b..5e357d5 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -324,5 +324,11 @@ namespace OpenSim.Framework.Communications.Services m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); } + + protected override bool AllowLoginWithoutInventory() + { + return true; + } + } } diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index db208a4..c81febd 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -371,9 +371,12 @@ namespace OpenSim.Framework.Communications.Services responseData["classified_categories"] = classifiedCategories; responseData["ui-config"] = uiConfig; - responseData["inventory-skeleton"] = agentInventory; + if (agentInventory != null) + { + responseData["inventory-skeleton"] = agentInventory; + responseData["inventory-root"] = inventoryRoot; + } responseData["inventory-skel-lib"] = inventoryLibrary; - responseData["inventory-root"] = inventoryRoot; responseData["inventory-lib-root"] = inventoryLibRoot; responseData["gestures"] = activeGestures; responseData["inventory-lib-owner"] = inventoryLibraryOwner; @@ -386,8 +389,6 @@ namespace OpenSim.Framework.Communications.Services responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); - //responseData["inventory-lib-root"] = new ArrayList(); // todo - if (m_buddyList != null) { responseData["buddy-list"] = m_buddyList.ToArray(); diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 1b6520d..d9556e4 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -197,7 +197,7 @@ namespace OpenSim.Framework.Communications.Services try { UUID agentID = userProfile.ID; - InventoryData inventData; + InventoryData inventData = null; try { @@ -209,16 +209,24 @@ namespace OpenSim.Framework.Communications.Services "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", agentID, e); - return logResponse.CreateLoginInventoryFailedResponse(); + // Let's not panic + if (!AllowLoginWithoutInventory()) + return logResponse.CreateLoginInventoryFailedResponse(); } - ArrayList AgentInventoryArray = inventData.InventoryArray; + if (inventData != null) + { + ArrayList AgentInventoryArray = inventData.InventoryArray; - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + userProfile.RootInventoryFolderID = inventData.RootFolderID; + + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + } // Inventory Library Section Hashtable InventoryLibRootHash = new Hashtable(); @@ -228,8 +236,6 @@ namespace OpenSim.Framework.Communications.Services logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); logResponse.CircuitCode = Util.RandomClass.Next(); @@ -1011,7 +1017,15 @@ namespace OpenSim.Framework.Communications.Services /// protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) { - List gestures = m_inventoryService.GetActiveGestures(theUser.ID); + List gestures = null; + try + { + gestures = m_inventoryService.GetActiveGestures(theUser.ID); + } + catch (Exception e) + { + m_log.Debug("[LOGIN]: Unable to retrieve active gestures from inventory server. Reason: " + e.Message); + } //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); ArrayList list = new ArrayList(); if (gestures != null) @@ -1089,5 +1103,10 @@ namespace OpenSim.Framework.Communications.Services return new InventoryData(AgentInventoryArray, rootID); } + + protected virtual bool AllowLoginWithoutInventory() + { + return false; + } } } -- cgit v1.1 From 958d764172fcbaa5d3a33b787b01426caa300a8a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 1 Apr 2009 19:44:46 +0000 Subject: * Upped trunk version number to 0.6.4 as we just tagged 0.6.4-release --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index e2f31c1..3754016 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.3.*")] +[assembly : AssemblyVersion("0.6.4.*")] [assembly : AssemblyFileVersion("1.0.0.0")] -- cgit v1.1 From 86c753a6bdce8788c6a23bebaf9a6015d5af238a Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 1 Apr 2009 23:35:48 +0000 Subject: More refactoring. This time extracting the client-side of RESTInterregionComms into a RegionClient class. --- .../Communications/Clients/RegionClient.cs | 555 +++++++++++++++++++++ 1 file changed, 555 insertions(+) create mode 100644 OpenSim/Framework/Communications/Clients/RegionClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs new file mode 100644 index 0000000..d98852b --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -0,0 +1,555 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using log4net; + +namespace OpenSim.Framework.Communications.Clients +{ + public class RegionClient + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) + { + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); + + HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); + AgentCreateRequest.Method = "POST"; + AgentCreateRequest.ContentType = "application/json"; + AgentCreateRequest.Timeout = 10000; + //AgentCreateRequest.KeepAlive = false; + + // Fill it in + OSDMap args = null; + try + { + args = aCircuit.PackAgentCircuitData(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = AgentCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = AgentCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) + { + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); + + HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); + ChildUpdateRequest.Method = "PUT"; + ChildUpdateRequest.ContentType = "application/json"; + ChildUpdateRequest.Timeout = 10000; + //ChildUpdateRequest.KeepAlive = false; + + // Fill it in + OSDMap args = null; + try + { + args = cAgentData.Pack(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ChildUpdateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); + + try + { + WebResponse webResponse = ChildUpdateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); + // ignore, really + } + + return true; + } + + public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) + { + agent = null; + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + request.Method = "GET"; + request.Timeout = 10000; + //request.Headers.Add("authorization", ""); // coming soon + + HttpWebResponse webResponse = null; + string reply = string.Empty; + try + { + webResponse = (HttpWebResponse)request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent get "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + reply = sr.ReadToEnd().Trim(); + sr.Close(); + + //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); + // ignore, really + return false; + } + + if (webResponse.StatusCode == HttpStatusCode.OK) + { + // we know it's jason + OSDMap args = GetOSDMap(reply); + if (args == null) + { + //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); + return false; + } + + agent = new CompleteAgentData(); + agent.Unpack(args); + return true; + } + + //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); + return false; + } + + public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) + { + //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent delete "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); + // ignore, really + } + + return true; + } + + + public bool DoCloseAgentCall(RegionInfo region, UUID id) + { + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + + //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent delete "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); + // ignore, really + } + + return true; + } + + public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) + { + ulong regionHandle = GetRegionHandle(region.RegionHandle); + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "POST"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["sog"] = OSD.FromString(sog.ToXmlString2()); + args["extra"] = OSD.FromString(sog.ExtraToXmlString()); + if (allowScriptCrossing) + { + string state = sog.GetStateSnapshot(); + if (state.Length > 0) + args["state"] = OSD.FromString(state); + } + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) + { + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; + //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); + + WebRequest HelloNeighbourRequest = WebRequest.Create(uri); + HelloNeighbourRequest.Method = "POST"; + HelloNeighbourRequest.ContentType = "application/json"; + HelloNeighbourRequest.Timeout = 10000; + + // Fill it in + OSDMap args = null; + try + { + args = thisRegion.PackRegionInfoData(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send + os = HelloNeighbourRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); + + try + { + WebResponse webResponse = HelloNeighbourRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + #region Hyperlinks + + public virtual ulong GetRegionHandle(ulong handle) + { + return handle; + } + + public virtual bool IsHyperlink(ulong handle) + { + return false; + } + + public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) + { + } + + public virtual void AdjustUserInformation(AgentCircuitData aCircuit) + { + } + + #endregion /* Hyperlinks */ + + public static OSDMap GetOSDMap(string data) + { + OSDMap args = null; + try + { + OSD buffer; + // We should pay attention to the content-type, but let's assume we know it's Json + buffer = OSDParser.DeserializeJson(data); + if (buffer.Type == OSDType.Map) + { + args = (OSDMap)buffer; + return args; + } + else + { + // uh? + System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); + return null; + } + } + catch (Exception ex) + { + System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); + return null; + } + } + + + } +} -- cgit v1.1 From 7322e1921249f4b64a87a1825de1b3b5707b24d6 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 3 Apr 2009 16:08:07 +0000 Subject: Added one more delegate to Caps, and a few guards, so that these objects can be used from more than just Scenes. Added the NewFileAgentInvengory cap to HGInventoryService. --- .../Framework/Communications/Capabilities/Caps.cs | 42 ++++++++++++++-------- .../Communications/Services/HGInventoryService.cs | 14 ++++++++ 2 files changed, 42 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 94614a1..1423e3a 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -49,6 +49,8 @@ namespace OpenSim.Framework.Communications.Capabilities public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); + public delegate void NewAsset(AssetBase asset); + public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, @@ -120,6 +122,7 @@ namespace OpenSim.Framework.Communications.Capabilities // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls public NewInventoryItem AddNewInventoryItem = null; + public NewAsset AddNewAsset = null; public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; @@ -674,30 +677,38 @@ namespace OpenSim.Framework.Communications.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { + //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); + //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); + if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { - IClientAPI client = GetClient(m_agentID); - IScene scene = client.Scene; + IClientAPI client = null; + IScene scene = null; + if (GetClient != null) + { + client = GetClient(m_agentID); + scene = client.Scene; - IMoneyModule mm = scene.RequestModuleInterface(); + IMoneyModule mm = scene.RequestModuleInterface(); - if (mm != null) - { - if (!mm.UploadCovered(client)) + if (mm != null) { - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; + if (!mm.UploadCovered(client)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } } } } - //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; @@ -771,7 +782,10 @@ namespace OpenSim.Framework.Communications.Capabilities asset.Type = assType; asset.Name = assetName; asset.Data = data; - m_assetCache.AddAsset(asset); + if (AddNewAsset != null) + AddNewAsset(asset); + else if (m_assetCache != null) + m_assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); item.Owner = m_agentID; diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index 7eaed89..d59d1ae 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -234,6 +234,11 @@ namespace OpenSim.Framework.Communications.Services } } + public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) + { + AddItem(item); + } + public InventoryItemBase UpdateItem(InventoryItemBase item) { m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); @@ -372,6 +377,11 @@ namespace OpenSim.Framework.Communications.Services return true; } + public void PostAnAsset(AssetBase asset) + { + PostAsset(asset); + } + /// /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) /// @@ -598,6 +608,10 @@ namespace OpenSim.Framework.Communications.Services Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); caps.ItemUpdatedCall = UpdateInventoryItemAsset; + caps.AddNewInventoryItem = AddUploadedInventoryItem; + caps.AddNewAsset = PostAnAsset; + //caps.GetClient = + Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( -- cgit v1.1 From c6283cacacd9c2a0992e233f54b6d9d272564449 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 4 Apr 2009 14:26:24 +0000 Subject: Remove some Mono warnings. --- OpenSim/Framework/Communications/Services/HGInventoryService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index d59d1ae..adc2056 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -62,14 +62,14 @@ namespace OpenSim.Framework.Communications.Services IAssetDataPlugin m_assetProvider = null; // These two used for remote access - string m_UserServerURL = string.Empty; + //string m_UserServerURL = string.Empty; string m_AssetServerURL = string.Empty; SynchronousGridAssetClient m_AssetClient = null; // Constructor for grid inventory server public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) { - m_UserServerURL = userServiceURL; + //m_UserServerURL = userServiceURL; m_AssetServerURL = assetServiceURL; m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); -- cgit v1.1 From 7acec9860de67a7a5f4fa1b121b5d6469f52ab3f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 4 Apr 2009 14:26:35 +0000 Subject: DST setting wasn't transferred to client, leading to wrong time display. --- OpenSim/Framework/Communications/Services/LoginResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index c81febd..d91bf84 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Services private void SetDefaultValues() { - DST = "N"; + DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; StipendSinceLogin = "N"; Gendered = "Y"; EverLoggedIn = "Y"; -- cgit v1.1 From 9a4192d14e3cd6940c12928181d5ca363abece64 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 5 Apr 2009 02:51:10 +0000 Subject: * Fixed copyright headers on HyperGrid source files. (Now match the rest of OpenSim, license text is unchanged) * Added Bitmap[,] to IParcel for MRM --- OpenSim/Framework/Communications/IHyperlink.cs | 49 +++++++++++----------- .../Communications/Services/HGInventoryService.cs | 49 +++++++++++----------- 2 files changed, 48 insertions(+), 50 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs index 6c61d82..b6c4981 100644 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -1,29 +1,28 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. +/* + * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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. - * + * + * 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.Framework.Communications diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index adc2056..abb9b92 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -1,29 +1,28 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. +/* + * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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. - * + * + * 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; -- cgit v1.1 From 3c9cba162739b93a07067d8a286f6dad55e02217 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 5 Apr 2009 03:27:50 +0000 Subject: Added CreateObject(regionhandle, userID, itemID) to post objects that are to be fetched from the user's inventory server and rezzed in the region. Added all code necessary to fetch the item and the asset, and rez it inworld. The access to the item is uncap-ed and unverified -- I may place it later either under a cap or with auth verification. But in this model regions don't have the user's inventory, so they would have to guess the item IDs. Added safemode config to Standalone Hypergrid, similar effect to AllowRegionAccessToInventory in Inventory Server. Everyone should have these vars set to their default values except me! --- .../Communications/Clients/InventoryClient.cs | 78 ++++++++++++++++++++++ .../Communications/Clients/RegionClient.cs | 76 +++++++++++++++++++++ .../Communications/Services/HGInventoryService.cs | 18 ++++- 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Framework/Communications/Clients/InventoryClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs new file mode 100644 index 0000000..8fe4268 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/InventoryClient.cs @@ -0,0 +1,78 @@ +/** + * Copyright (c), Contributors. All rights reserved. + * 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 Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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 OpenSim.Framework.Servers; + +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Clients +{ + public class InventoryClient + { + private string ServerURL; + + public InventoryClient(string url) + { + ServerURL = url; + } + + public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse callBack) + { + System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL); + try + { + RestSessionObjectPosterResponse requester + = new RestSessionObjectPosterResponse(); + requester.ResponseCallback = callBack; + + requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty); + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); + } + } + + public InventoryItemBase GetInventoryItem(InventoryItemBase item) + { + System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL); + try + { + item = SynchronousRestSessionObjectPoster.BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, "", ""); + return item; + } + catch (Exception e) + { + System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); + } + return null; + } + + } +} diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index d98852b..196bcf9 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -417,6 +417,82 @@ namespace OpenSim.Framework.Communications.Clients } + public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) + { + ulong regionHandle = GetRegionHandle(region.RegionHandle); + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "PUT"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["userid"] = OSD.FromUUID(userID); + args["itemid"] = OSD.FromUUID(itemID); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) { string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index abb9b92..a3234bf 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -107,6 +107,17 @@ namespace OpenSim.Framework.Communications.Services public virtual void AddHttpHandlers() { httpServer.AddHTTPHandler("/InvCap/", CapHandler); + + // Un-cap'ed for now + httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( + "POST", "/GetItem/", GetInventoryItem, CheckAuthSession)); + + } + + public InventoryItemBase GetInventoryItem(Guid id) + { + UUID itemID = new UUID(id); + return m_inventoryService.GetInventoryItem(itemID); } public bool CheckAuthSession(string session_id, string avatar_id) @@ -353,10 +364,15 @@ namespace OpenSim.Framework.Communications.Services m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); return asset; } + UUID assetID = item2.AssetID; + if (assetID != item.AssetID) + { + m_log.WarnFormat("[HGStandaloneInvService]: asset IDs don't match {0}, {1}", item.AssetID, item2.AssetID); + } // All good, get the asset //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); - AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); + AssetBase theasset = FetchAsset(assetID, (item.InvType == (int)InventoryType.Texture)); m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); if (theasset != null) -- cgit v1.1 From 5f34bd73fbca765064c4b3811d1f67da36cbf5ae Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 6 Apr 2009 14:24:13 +0000 Subject: Update svn properties. --- .../Communications/Clients/RegionClient.cs | 1262 ++++++++++---------- 1 file changed, 631 insertions(+), 631 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 196bcf9..27353b0 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -1,631 +1,631 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; - -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -using log4net; - -namespace OpenSim.Framework.Communications.Clients -{ - public class RegionClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) - { - // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; - //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); - - HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); - AgentCreateRequest.Method = "POST"; - AgentCreateRequest.ContentType = "application/json"; - AgentCreateRequest.Timeout = 10000; - //AgentCreateRequest.KeepAlive = false; - - // Fill it in - OSDMap args = null; - try - { - args = aCircuit.PackAgentCircuitData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = AgentCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); - //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - - return false; - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - try - { - WebResponse webResponse = AgentCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - // ignore, really - } - - return true; - - } - - public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) - { - // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; - //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); - - HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); - ChildUpdateRequest.Method = "PUT"; - ChildUpdateRequest.ContentType = "application/json"; - ChildUpdateRequest.Timeout = 10000; - //ChildUpdateRequest.KeepAlive = false; - - // Fill it in - OSDMap args = null; - try - { - args = cAgentData.Pack(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ChildUpdateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); - //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - - return false; - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); - - try - { - WebResponse webResponse = ChildUpdateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); - // ignore, really - } - - return true; - } - - public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) - { - agent = null; - // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); - request.Method = "GET"; - request.Timeout = 10000; - //request.Headers.Add("authorization", ""); // coming soon - - HttpWebResponse webResponse = null; - string reply = string.Empty; - try - { - webResponse = (HttpWebResponse)request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent get "); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - reply = sr.ReadToEnd().Trim(); - sr.Close(); - - //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); - // ignore, really - return false; - } - - if (webResponse.StatusCode == HttpStatusCode.OK) - { - // we know it's jason - OSDMap args = GetOSDMap(reply); - if (args == null) - { - //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); - return false; - } - - agent = new CompleteAgentData(); - agent.Unpack(args); - return true; - } - - //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); - return false; - } - - public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) - { - //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - - return true; - } - - - public bool DoCloseAgentCall(RegionInfo region, UUID id) - { - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - - //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - - return true; - } - - public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "POST"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["sog"] = OSD.FromString(sog.ToXmlString2()); - args["extra"] = OSD.FromString(sog.ExtraToXmlString()); - if (allowScriptCrossing) - { - string state = sog.GetStateSnapshot(); - if (state.Length > 0) - args["state"] = OSD.FromString(state); - } - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); - m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - - return true; - - } - - public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "PUT"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["userid"] = OSD.FromUUID(userID); - args["itemid"] = OSD.FromUUID(itemID); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); - //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - - return true; - - } - - public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) - { - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; - //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); - - WebRequest HelloNeighbourRequest = WebRequest.Create(uri); - HelloNeighbourRequest.Method = "POST"; - HelloNeighbourRequest.ContentType = "application/json"; - HelloNeighbourRequest.Timeout = 10000; - - // Fill it in - OSDMap args = null; - try - { - args = thisRegion.PackRegionInfoData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send - os = HelloNeighbourRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); - //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); - - return false; - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); - - try - { - WebResponse webResponse = HelloNeighbourRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); - } - - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); - // ignore, really - } - - return true; - - } - - #region Hyperlinks - - public virtual ulong GetRegionHandle(ulong handle) - { - return handle; - } - - public virtual bool IsHyperlink(ulong handle) - { - return false; - } - - public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) - { - } - - public virtual void AdjustUserInformation(AgentCircuitData aCircuit) - { - } - - #endregion /* Hyperlinks */ - - public static OSDMap GetOSDMap(string data) - { - OSDMap args = null; - try - { - OSD buffer; - // We should pay attention to the content-type, but let's assume we know it's Json - buffer = OSDParser.DeserializeJson(data); - if (buffer.Type == OSDType.Map) - { - args = (OSDMap)buffer; - return args; - } - else - { - // uh? - System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); - return null; - } - } - catch (Exception ex) - { - System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); - return null; - } - } - - - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using log4net; + +namespace OpenSim.Framework.Communications.Clients +{ + public class RegionClient + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) + { + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); + + HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); + AgentCreateRequest.Method = "POST"; + AgentCreateRequest.ContentType = "application/json"; + AgentCreateRequest.Timeout = 10000; + //AgentCreateRequest.KeepAlive = false; + + // Fill it in + OSDMap args = null; + try + { + args = aCircuit.PackAgentCircuitData(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = AgentCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = AgentCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) + { + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); + + HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); + ChildUpdateRequest.Method = "PUT"; + ChildUpdateRequest.ContentType = "application/json"; + ChildUpdateRequest.Timeout = 10000; + //ChildUpdateRequest.KeepAlive = false; + + // Fill it in + OSDMap args = null; + try + { + args = cAgentData.Pack(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ChildUpdateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); + + try + { + WebResponse webResponse = ChildUpdateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); + // ignore, really + } + + return true; + } + + public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) + { + agent = null; + // Eventually, we want to use a caps url instead of the agentID + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + request.Method = "GET"; + request.Timeout = 10000; + //request.Headers.Add("authorization", ""); // coming soon + + HttpWebResponse webResponse = null; + string reply = string.Empty; + try + { + webResponse = (HttpWebResponse)request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent get "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + reply = sr.ReadToEnd().Trim(); + sr.Close(); + + //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); + // ignore, really + return false; + } + + if (webResponse.StatusCode == HttpStatusCode.OK) + { + // we know it's jason + OSDMap args = GetOSDMap(reply); + if (args == null) + { + //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); + return false; + } + + agent = new CompleteAgentData(); + agent.Unpack(args); + return true; + } + + //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); + return false; + } + + public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) + { + //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent delete "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); + // ignore, really + } + + return true; + } + + + public bool DoCloseAgentCall(RegionInfo region, UUID id) + { + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + + //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on agent delete "); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); + // ignore, really + } + + return true; + } + + public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) + { + ulong regionHandle = GetRegionHandle(region.RegionHandle); + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "POST"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["sog"] = OSD.FromString(sog.ToXmlString2()); + args["extra"] = OSD.FromString(sog.ExtraToXmlString()); + if (allowScriptCrossing) + { + string state = sog.GetStateSnapshot(); + if (state.Length > 0) + args["state"] = OSD.FromString(state); + } + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) + { + ulong regionHandle = GetRegionHandle(region.RegionHandle); + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "PUT"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["userid"] = OSD.FromUUID(userID); + args["itemid"] = OSD.FromUUID(itemID); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) + { + string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; + //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); + + WebRequest HelloNeighbourRequest = WebRequest.Create(uri); + HelloNeighbourRequest.Method = "POST"; + HelloNeighbourRequest.ContentType = "application/json"; + HelloNeighbourRequest.Timeout = 10000; + + // Fill it in + OSDMap args = null; + try + { + args = thisRegion.PackRegionInfoData(); + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); + } + // Add the regionhandle of the destination region + ulong regionHandle = GetRegionHandle(region.RegionHandle); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + UTF8Encoding str = new UTF8Encoding(); + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send + os = HelloNeighbourRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + os.Close(); + //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); + } + //catch (WebException ex) + catch + { + //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); + + return false; + } + + // Let's wait for the response + //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); + + try + { + WebResponse webResponse = HelloNeighbourRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); + } + + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); + // ignore, really + } + + return true; + + } + + #region Hyperlinks + + public virtual ulong GetRegionHandle(ulong handle) + { + return handle; + } + + public virtual bool IsHyperlink(ulong handle) + { + return false; + } + + public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) + { + } + + public virtual void AdjustUserInformation(AgentCircuitData aCircuit) + { + } + + #endregion /* Hyperlinks */ + + public static OSDMap GetOSDMap(string data) + { + OSDMap args = null; + try + { + OSD buffer; + // We should pay attention to the content-type, but let's assume we know it's Json + buffer = OSDParser.DeserializeJson(data); + if (buffer.Type == OSDType.Map) + { + args = (OSDMap)buffer; + return args; + } + else + { + // uh? + System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); + return null; + } + } + catch (Exception ex) + { + System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); + return null; + } + } + + + } +} -- cgit v1.1 From f3c7298fc5bdb35e8a293c9aee4134c8e8fe2856 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 8 Apr 2009 17:50:57 +0000 Subject: * Make it possible to store creator strings in user inventory items as well as UUIDs * All existing functionality should be unaffected. * Database schemas have not been changed. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/Caps.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 93f126f..ec62ed2 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications.Cache { InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; - item.Creator = libOwner; + item.CreatorId = libOwner.ToString(); item.ID = inventoryID; item.AssetID = assetID; item.Description = description; @@ -159,7 +159,7 @@ namespace OpenSim.Framework.Communications.Cache { InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; - item.Creator = libOwner; + item.CreatorId = libOwner.ToString(); item.ID = new UUID(config.GetString("inventoryID", ID.ToString())); item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); item.Folder = new UUID(config.GetString("folderID", ID.ToString())); diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 1423e3a..a2e8042 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -440,7 +440,7 @@ namespace OpenSim.Framework.Communications.Capabilities llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower(); llsdItem.permissions = new LLSDPermissions(); - llsdItem.permissions.creator_id = invItem.Creator; + llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; llsdItem.permissions.group_id = UUID.Zero; @@ -789,7 +789,7 @@ namespace OpenSim.Framework.Communications.Capabilities InventoryItemBase item = new InventoryItemBase(); item.Owner = m_agentID; - item.Creator = m_agentID; + item.CreatorId = m_agentID.ToString(); item.ID = inventoryItem; item.AssetID = asset.FullID; item.Description = assetDescription; -- cgit v1.1 From e93b782f9d86e4049a28d7f90c691dc5d242f234 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 8 Apr 2009 19:59:37 +0000 Subject: * Introduced some experimental code with regards to asset data substitution --- .../Framework/Communications/Cache/AssetCache.cs | 43 ++++++++++++++++++++++ OpenSim/Framework/Communications/IUserService.cs | 3 ++ .../Communications/Tests/Cache/AssetCacheTests.cs | 17 +++++++-- .../Framework/Communications/UserManagerBase.cs | 5 +++ 4 files changed, 65 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e0d0bd7..b571c0b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Text.RegularExpressions; using System.Threading; using GlynnTucker.Cache; using log4net; @@ -547,9 +548,49 @@ namespace OpenSim.Framework.Communications.Cache req.RequestUser.SendAsset(req2); } + } + + public byte[] ProcessAssetData(byte[] assetData) + { + string data = Encoding.ASCII.GetString(assetData); + + data = ProcessAssetDataString(data); + + return Encoding.ASCII.GetBytes( data ); + } + + public string ProcessAssetDataString(string data) + { + Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); + + data = regex.Replace(data, delegate(Match m) + { + string result = String.Empty; + string key = m.Groups[1].Captures[0].Value; + + string value = m.Groups[2].Captures[0].Value; + + Guid id = Util.GetHashGuid(value, AssetInfo.Secret); + + switch (key) + { + case "creator_url": + result = "creator_id " + id; + break; + + case "owner_url": + result = "owner_id " + id; + break; + } + + return result; + }); + + return data; } + public class AssetRequest { public IClientAPI RequestUser; @@ -578,6 +619,8 @@ namespace OpenSim.Framework.Communications.Cache Name = aBase.Name; Description = aBase.Description; } + + public const string Secret = "secret"; } public class TextureImage : AssetBase diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 0846024..38c360a 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using OpenMetaverse; @@ -46,6 +47,8 @@ namespace OpenSim.Framework.Communications /// The target UUID /// A user profile. Returns null if no user profile is found. UserProfileData GetUserProfile(UUID userId); + + UserProfileData GetUserProfile(Uri uri); UserAgentData GetAgentByUUID(UUID userId); diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 18ae9a7..70a398e 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -73,16 +73,27 @@ namespace OpenSim.Framework.Communications.Tests Assert.That( assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received"); } - + private void AssetRequestCallback(UUID assetId, AssetBase asset) { m_assetIdReceived = assetId; m_assetReceived = asset; - + lock (this) { Monitor.PulseAll(this); - } + } + } + + [Test] + public void ProcessAssetDataTest() + { + string url = "http://host/dir/"; + string data = " creator_url " + url + " "; + + AssetCache assetCache = new AssetCache(); + + Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data )); } } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index c177d4f..b7280d3 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -122,6 +122,11 @@ namespace OpenSim.Framework.Communications } } + public UserProfileData GetUserProfile(Uri uri) + { + throw new System.NotImplementedException(); + } + public UserAgentData GetAgentByUUID(UUID userId) { foreach (IUserDataPlugin plugin in _plugins) -- cgit v1.1 From d2a412e94bf3ef1e332d44b7106c606f26b1636b Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 9 Apr 2009 16:45:22 +0000 Subject: * Added some more experimental code; nothing wired in so far. --- .../Framework/Communications/Cache/AssetCache.cs | 43 +++++++--- .../Communications/Tests/Cache/AssetCacheTests.cs | 98 +++++++++++++++++++++- 2 files changed, 127 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index b571c0b..cbb2a5a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -393,22 +393,26 @@ namespace OpenSim.Framework.Communications.Cache protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) { + if(!IsTexture && assetInf.ContainsReferences && false ) + { + assetInf.Data = ProcessAssetData(assetInf.Data); + } } // See IAssetReceiver - public virtual void AssetNotFound(UUID assetID, bool IsTexture) + public virtual void AssetNotFound(UUID assetId, bool isTexture) { -// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); +// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetId); // Remember the fact that this asset could not be found to prevent delays from repeated requests - m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); + m_memcache.Add(assetId, null, TimeSpan.FromHours(24)); // Notify requesters for this asset AssetRequestsList reqList; lock (RequestLists) { - if (RequestLists.TryGetValue(assetID, out reqList)) - RequestLists.Remove(assetID); + if (RequestLists.TryGetValue(assetId, out reqList)) + RequestLists.Remove(assetId); } if (reqList != null) @@ -418,7 +422,7 @@ namespace OpenSim.Framework.Communications.Cache foreach (NewAssetRequest req in reqList.Requests) { - req.Callback(assetID, null); + req.Callback(assetId, null); } } } @@ -554,12 +558,12 @@ namespace OpenSim.Framework.Communications.Cache { string data = Encoding.ASCII.GetString(assetData); - data = ProcessAssetDataString(data); + data = ProcessAssetDataString(data, null); return Encoding.ASCII.GetBytes( data ); } - public string ProcessAssetDataString(string data) + public string ProcessAssetDataString(string data, IUserService userService) { Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); @@ -571,16 +575,18 @@ namespace OpenSim.Framework.Communications.Cache string value = m.Groups[2].Captures[0].Value; - Guid id = Util.GetHashGuid(value, AssetInfo.Secret); + Uri userUri; switch (key) { case "creator_url": - result = "creator_id " + id; + userUri = new Uri(value); + result = "creator_id " + ResolveUserUri(userService, userUri); break; case "owner_url": - result = "owner_id " + id; + userUri = new Uri(value); + result = "owner_id " + ResolveUserUri(userService, userUri); break; } @@ -590,6 +596,21 @@ namespace OpenSim.Framework.Communications.Cache return data; } + private Guid ResolveUserUri(IUserService userService, Uri userUri) + { + Guid id; + UserProfileData userProfile = userService.GetUserProfile(userUri); + if( userProfile == null ) + { + id = Guid.Empty; + } + else + { + id = userProfile.ID.Guid; + } + return id; + } + public class AssetRequest { diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 70a398e..3779f55 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Collections.Generic; using System.Threading; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -85,15 +87,105 @@ namespace OpenSim.Framework.Communications.Tests } } + private class FakeUserService : IUserService + { + public UserProfileData GetUserProfile(string firstName, string lastName) + { + throw new NotImplementedException(); + } + + public UserProfileData GetUserProfile(UUID userId) + { + throw new NotImplementedException(); + } + + public UserProfileData GetUserProfile(Uri uri) + { + UserProfileData userProfile = new UserProfileData(); + + userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); + + return userProfile; + } + + public UserAgentData GetAgentByUUID(UUID userId) + { + throw new NotImplementedException(); + } + + public void ClearUserAgent(UUID avatarID) + { + throw new NotImplementedException(); + } + + public List GenerateAgentPickerRequestResponse(UUID QueryID, string Query) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(string firstName, string lastName) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(string firstName, string lastName, string password) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(UUID userId) + { + throw new NotImplementedException(); + } + + public bool UpdateUserProfile(UserProfileData data) + { + throw new NotImplementedException(); + } + + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) + { + throw new NotImplementedException(); + } + + public void RemoveUserFriend(UUID friendlistowner, UUID friend) + { + throw new NotImplementedException(); + } + + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) + { + throw new NotImplementedException(); + } + + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) + { + throw new NotImplementedException(); + } + + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) + { + throw new NotImplementedException(); + } + + public List GetUserFriendList(UUID friendlistowner) + { + throw new NotImplementedException(); + } + } + [Test] - public void ProcessAssetDataTest() + public void TestProcessAssetData() { string url = "http://host/dir/"; - string data = " creator_url " + url + " "; + string creatorData = " creator_url " + url + " "; + string ownerData = " owner_url " + url + " "; AssetCache assetCache = new AssetCache(); + FakeUserService fakeUserService = new FakeUserService(); - Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data )); + Assert.AreEqual(" creator_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(creatorData, fakeUserService)); + Assert.AreEqual(" owner_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(ownerData, fakeUserService)); } } } -- cgit v1.1 From 29355de6ee01b1f44f32ea45b9c06f636ae9a241 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 13 Apr 2009 20:04:18 +0000 Subject: * Some more experimental work on distributed assets. Nothing hotwired yet. * Introduced preprocess step in FetchAsset (Might revert this later) * Some minor CCC * Added actual implementation of GetUserProfile( uri ) and the corresponding handler to OGS1. * Introduced non-functioning GetUserUri( userProfile) awaiting user server wireup (this might move elsewhere) --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++++----- OpenSim/Framework/Communications/IUserService.cs | 2 ++ .../Framework/Communications/Tests/Cache/AssetCacheTests.cs | 5 +++++ OpenSim/Framework/Communications/UserManagerBase.cs | 8 ++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index cbb2a5a..4d2db17 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Cache { AssetInfo assetInf = new AssetInfo(asset); - ProcessReceivedAsset(IsTexture, assetInf); + ProcessReceivedAsset(IsTexture, assetInf, null); if (!m_memcache.Contains(assetInf.FullID)) { @@ -391,11 +391,11 @@ namespace OpenSim.Framework.Communications.Cache } } - protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) + protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) { if(!IsTexture && assetInf.ContainsReferences && false ) { - assetInf.Data = ProcessAssetData(assetInf.Data); + assetInf.Data = ProcessAssetData(assetInf.Data, userService ); } } @@ -554,11 +554,11 @@ namespace OpenSim.Framework.Communications.Cache } } - public byte[] ProcessAssetData(byte[] assetData) + public byte[] ProcessAssetData(byte[] assetData, IUserService userService) { string data = Encoding.ASCII.GetString(assetData); - data = ProcessAssetDataString(data, null); + data = ProcessAssetDataString(data, userService ); return Encoding.ASCII.GetBytes( data ); } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 38c360a..3c09b40 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -50,6 +50,8 @@ namespace OpenSim.Framework.Communications UserProfileData GetUserProfile(Uri uri); + Uri GetUserUri(UserProfileData userProfile); + UserAgentData GetAgentByUUID(UUID userId); void ClearUserAgent(UUID avatarID); diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 3779f55..9d9810b 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -108,6 +108,11 @@ namespace OpenSim.Framework.Communications.Tests return userProfile; } + public Uri GetUserUri(UserProfileData userProfile) + { + throw new NotImplementedException(); + } + public UserAgentData GetAgentByUUID(UUID userId) { throw new NotImplementedException(); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b7280d3..155f5cd 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -124,7 +124,7 @@ namespace OpenSim.Framework.Communications public UserProfileData GetUserProfile(Uri uri) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public UserAgentData GetAgentByUUID(UUID userId) @@ -142,6 +142,11 @@ namespace OpenSim.Framework.Communications return null; } + public Uri GetUserUri(UserProfileData userProfile) + { + throw new NotImplementedException(); + } + // see IUserService public virtual UserProfileData GetUserProfile(UUID uuid) { @@ -835,6 +840,5 @@ namespace OpenSim.Framework.Communications } #endregion - } } -- cgit v1.1 From 6204f23230734a81d483f7a2da8d73a37c56a2a6 Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 14 Apr 2009 03:00:17 +0000 Subject: This was needed for the prior commit. --- .../Framework/Communications/Clients/AuthClient.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 39a886c..6111aee 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.Collections.Generic; using Nwc.XmlRpc; using OpenMetaverse; @@ -114,5 +115,28 @@ namespace OpenSim.Framework.Communications.Clients return false; } } + + public static bool VerifySession(string authurl, UUID userID, UUID sessionID) + { + Hashtable requestData = new Hashtable(); + requestData["avatar_uuid"] = userID.ToString(); + requestData["session_id"] = sessionID.ToString(); + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); + XmlRpcResponse UserResp = UserReq.Send(authurl, 3000); + + Hashtable responseData = (Hashtable)UserResp.Value; + if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") + { + System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); + return true; + } + else + { + System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); + return false; + } + } } } -- cgit v1.1 From cad0aab7934bf0f81634c44fc03876f4b252eaa8 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 14 Apr 2009 11:38:33 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4d2db17..f8b5757 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -393,9 +393,9 @@ namespace OpenSim.Framework.Communications.Cache protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) { - if(!IsTexture && assetInf.ContainsReferences && false ) + if (!IsTexture && assetInf.ContainsReferences && false) { - assetInf.Data = ProcessAssetData(assetInf.Data, userService ); + assetInf.Data = ProcessAssetData(assetInf.Data, userService); } } @@ -558,9 +558,9 @@ namespace OpenSim.Framework.Communications.Cache { string data = Encoding.ASCII.GetString(assetData); - data = ProcessAssetDataString(data, userService ); + data = ProcessAssetDataString(data, userService); - return Encoding.ASCII.GetBytes( data ); + return Encoding.ASCII.GetBytes(data); } public string ProcessAssetDataString(string data, IUserService userService) @@ -600,7 +600,7 @@ namespace OpenSim.Framework.Communications.Cache { Guid id; UserProfileData userProfile = userService.GetUserProfile(userUri); - if( userProfile == null ) + if (userProfile == null) { id = Guid.Empty; } -- cgit v1.1 From ad2bd740574b7695a74bb65a63c4bb884cafdf7d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 14 Apr 2009 16:36:32 +0000 Subject: * refactor: rename AssetCache.Initialize() to AssetCache.Reset() to avoid having Initialise() and Initialize() in the same class - very difficult to read. --- .../Framework/Communications/Cache/AssetCache.cs | 83 +++++++++++----------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f8b5757..8c451b0 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -49,6 +49,26 @@ namespace OpenSim.Framework.Communications.Cache /// AssetNotFound(), which means they do share the same asset and texture caches. public class AssetCache : IAssetCache { + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected ICache m_memcache = new SimpleMemoryCache(); + + /// + /// Assets requests which are waiting for asset server data. This includes texture requests + /// + private Dictionary RequestedAssets; + + /// + /// Asset requests with data which are ready to be sent back to requesters. This includes textures. + /// + private List AssetRequests; + + /// + /// Until the asset request is fulfilled, each asset request is associated with a list of requesters + /// + private Dictionary RequestLists; + #region IPlugin /// @@ -77,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation"); m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version); - Initialize(); + Reset(); m_assetServer = assetServer; m_assetServer.SetReceiver(this); @@ -95,42 +115,31 @@ namespace OpenSim.Framework.Communications.Cache Initialise(assetServer); } - public AssetCache() - { - m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)"); - } - public void Dispose() { } - #endregion - - protected ICache m_memcache = new SimpleMemoryCache(); - - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Assets requests which are waiting for asset server data. This includes texture requests - /// - private Dictionary RequestedAssets; - - /// - /// Asset requests with data which are ready to be sent back to requesters. This includes textures. - /// - private List AssetRequests; - - /// - /// Until the asset request is fulfilled, each asset request is associated with a list of requesters - /// - private Dictionary RequestLists; + #endregion public IAssetServer AssetServer { get { return m_assetServer; } } - private IAssetServer m_assetServer; + private IAssetServer m_assetServer; + + public AssetCache() + { + m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)"); + } + + /// + /// Constructor. + /// + /// + public AssetCache(IAssetServer assetServer) + { + Initialise(assetServer); + } public void ShowState() { @@ -148,31 +157,20 @@ namespace OpenSim.Framework.Communications.Cache if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.ClearAssetCacheStatistics(); - Initialize(); + Reset(); } /// - /// Initialize the cache. + /// Reset the cache. /// - private void Initialize() + private void Reset() { AssetRequests = new List(); - RequestedAssets = new Dictionary(); RequestLists = new Dictionary(); } /// - /// Constructor. Initialize will need to be called separately. - /// - /// - public AssetCache(IAssetServer assetServer) - { - m_log.Info("[ASSET CACHE]: Asset cache direct constructor"); - Initialise(assetServer); - } - - /// /// Process the asset queue which holds data which is packeted up and sent /// directly back to the client. /// @@ -550,7 +548,6 @@ namespace OpenSim.Framework.Communications.Cache req2.RequestAssetID = req.RequestAssetID; req2.TransferRequestID = req.TransferRequestID; req.RequestUser.SendAsset(req2); - } } -- cgit v1.1 From 1894157dd3608a15c3336efc2d58eee0de092610 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 14 Apr 2009 17:15:09 +0000 Subject: * Explicitly start the asset server thread so that unit tests can run single rather than multi-threaded (which may be behind the occasional test freezes) --- .../Communications/Cache/AssetServerBase.cs | 39 +++++++++++----------- .../Communications/Cache/CryptoGridAssetClient.cs | 5 --- .../Communications/Cache/GridAssetClient.cs | 5 --- .../Communications/Cache/SQLAssetServer.cs | 5 --- .../Communications/Tests/Cache/AssetCacheTests.cs | 4 ++- 5 files changed, 22 insertions(+), 36 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 1d0c030..343667a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications.Cache = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IAssetReceiver m_receiver; - protected BlockingQueue m_assetRequests; + protected BlockingQueue m_assetRequests = new BlockingQueue(); protected Thread m_localAssetServerThread; protected IAssetDataPlugin m_assetProvider; @@ -109,6 +109,22 @@ namespace OpenSim.Framework.Communications.Cache // Temporarily hardcoded - should be a plugin protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); + public virtual void Start() + { + m_log.Debug("[ASSET SERVER]: Starting asset server"); + + m_localAssetServerThread = new Thread(RunRequests); + m_localAssetServerThread.Name = "LocalAssetServerThread"; + m_localAssetServerThread.IsBackground = true; + m_localAssetServerThread.Start(); + ThreadTracker.Add(m_localAssetServerThread); + } + + public virtual void Stop() + { + m_localAssetServerThread.Abort(); + } + public abstract void StoreAsset(AssetBase asset); /// @@ -121,8 +137,8 @@ namespace OpenSim.Framework.Communications.Cache /// Thrown if the request failed for some other reason than that the /// asset cannot be found. /// - protected abstract AssetBase GetAsset(AssetRequest req); - + protected abstract AssetBase GetAsset(AssetRequest req); + /// /// Process an asset request. This method will call GetAsset(AssetRequest req) /// on the subclass. @@ -169,18 +185,6 @@ namespace OpenSim.Framework.Communications.Cache assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); } - public AssetServerBase() - { - m_log.Info("[ASSET SERVER]: Starting asset storage system"); - m_assetRequests = new BlockingQueue(); - - m_localAssetServerThread = new Thread(RunRequests); - m_localAssetServerThread.Name = "LocalAssetServerThread"; - m_localAssetServerThread.IsBackground = true; - m_localAssetServerThread.Start(); - ThreadTracker.Add(m_localAssetServerThread); - } - private void RunRequests() { while (true) // Since it's a 'blocking queue' @@ -222,11 +226,6 @@ namespace OpenSim.Framework.Communications.Cache m_assetProvider.UpdateAsset(asset); } - public virtual void Close() - { - m_localAssetServerThread.Abort(); - } - public void SetServerInfo(string ServerUrl, string ServerKey) { } diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index f1c19fa..6e4dd1c 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -554,11 +554,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - throw new Exception("The method or operation is not implemented."); - } - #endregion } } diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 7131cb5..c7d4c99 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -135,11 +135,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - throw new Exception("The method or operation is not implemented."); - } - #endregion } } diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 41a9561..227744d 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -100,11 +100,6 @@ namespace OpenSim.Framework.Communications.Cache } } - public override void Close() - { - base.Close(); - } - protected override AssetBase GetAsset(AssetRequest req) { return m_assetProvider.FetchAsset(req.AssetID); diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 9d9810b..264bfe1 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -62,7 +62,9 @@ namespace OpenSim.Framework.Communications.Tests TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); assetPlugin.CreateAsset(asset); - IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin)); + IAssetServer assetServer = new SQLAssetServer(assetPlugin); + IAssetCache assetCache = new AssetCache(assetServer); + assetServer.Start(); lock (this) { -- cgit v1.1 From 2a49272b6286f65bc0389a4e1a1795d50a104f3b Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 14 Apr 2009 17:32:05 +0000 Subject: Changing the CAP seed to be the string representation of a full UUID, instead of a trunkated UUID. --- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index 874a27f..f804abb 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -52,7 +52,10 @@ namespace OpenSim.Framework.Communications.Capabilities { UUID caps = UUID.Random(); string capsPath = caps.ToString(); - capsPath = capsPath.Remove(capsPath.Length - 4, 4); + // I'm commenting this, rather than delete, to keep as historical record. + // The caps seed is now a full UUID string that gets added four more digits + // for producing certain CAPs URLs in OpenSim + //capsPath = capsPath.Remove(capsPath.Length - 4, 4); return capsPath; } } -- cgit v1.1 From e1c449b492a08b95e9f4ea0556b6ec77f32ef0e7 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 14 Apr 2009 17:44:10 +0000 Subject: * Change simple asset cache test to manually pump the asset server rather than relying on another thread --- .../Communications/Cache/AssetServerBase.cs | 29 ++++++++++++++++------ .../Communications/Tests/Cache/AssetCacheTests.cs | 15 ++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 343667a..24cb598 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -138,14 +138,29 @@ namespace OpenSim.Framework.Communications.Cache /// asset cannot be found. /// protected abstract AssetBase GetAsset(AssetRequest req); - + + /// + /// Does the asset server have any waiting requests? + /// + /// + /// This does include any request that is currently being handled. This information is not reliable where + /// another thread may be processing requests. + /// + /// + /// True if there are waiting requests. False if there are no waiting requests. + /// + public virtual bool HasWaitingRequests() + { + return m_assetRequests.Count() != 0; + } + /// /// Process an asset request. This method will call GetAsset(AssetRequest req) /// on the subclass. /// - /// - protected virtual void ProcessRequest(AssetRequest req) + public virtual void ProcessNextRequest() { + AssetRequest req = m_assetRequests.Dequeue(); AssetBase asset; try @@ -160,7 +175,7 @@ namespace OpenSim.Framework.Communications.Cache StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); m_receiver.AssetNotFound(req.AssetID, req.IsTexture); - + return; } @@ -190,10 +205,8 @@ namespace OpenSim.Framework.Communications.Cache while (true) // Since it's a 'blocking queue' { try - { - AssetRequest req = m_assetRequests.Dequeue(); - - ProcessRequest(req); + { + ProcessNextRequest(); } catch (Exception e) { diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 264bfe1..5d6bc8d 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -62,15 +62,14 @@ namespace OpenSim.Framework.Communications.Tests TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); assetPlugin.CreateAsset(asset); - IAssetServer assetServer = new SQLAssetServer(assetPlugin); + SQLAssetServer assetServer = new SQLAssetServer(assetPlugin); IAssetCache assetCache = new AssetCache(assetServer); - assetServer.Start(); - - lock (this) - { - assetCache.GetAsset(assetId, AssetRequestCallback, false); - Monitor.Wait(this, 60000); - } + + assetCache.GetAsset(assetId, AssetRequestCallback, false); + + // Manually pump the asset server + while (assetServer.HasWaitingRequests()) + assetServer.ProcessNextRequest(); Assert.That( assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received"); -- cgit v1.1 From 0413d052a3ec541164049e7d39278c57fb92ed06 Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 14 Apr 2009 19:35:35 +0000 Subject: Adds session authentication upon NewUserConnections. Adds user key authentication (in safemode only) upon CreateChildAgents. All of this for Hypergrid users too. This addresses assorted spoofing vulnerabilities. --- .../Communications/Clients/RegionClient.cs | 7 ++-- .../Framework/Communications/IAuthentication.cs | 1 + OpenSim/Framework/Communications/IUserService.cs | 4 ++ .../Communications/Services/LoginService.cs | 46 ++++++++++++++++++++++ .../Communications/Tests/Cache/AssetCacheTests.cs | 5 +++ .../Framework/Communications/UserManagerBase.cs | 15 +++++++ 6 files changed, 75 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 27353b0..da3f620 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit) + public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey) { // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; @@ -54,6 +54,7 @@ namespace OpenSim.Framework.Communications.Clients AgentCreateRequest.ContentType = "application/json"; AgentCreateRequest.Timeout = 10000; //AgentCreateRequest.KeepAlive = false; + AgentCreateRequest.Headers.Add("Authorization", authKey); // Fill it in OSDMap args = null; @@ -80,7 +81,7 @@ namespace OpenSim.Framework.Communications.Clients } catch (Exception e) { - m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message); + m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); // ignore. buffer will be empty, caller should check. } @@ -91,7 +92,7 @@ namespace OpenSim.Framework.Communications.Clients os = AgentCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it os.Close(); - //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); + //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); } //catch (WebException ex) catch diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs index 0f62569..bd568e4 100644 --- a/OpenSim/Framework/Communications/IAuthentication.cs +++ b/OpenSim/Framework/Communications/IAuthentication.cs @@ -34,5 +34,6 @@ namespace OpenSim.Framework.Communications { string GetNewKey(string url, UUID userID, UUID authToken); bool VerifyKey(UUID userID, string key); + bool VerifySession(UUID iserID, UUID sessionID); } } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 3c09b40..3a56d35 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -119,5 +119,9 @@ namespace OpenSim.Framework.Communications /// /// The agent that we're retreiving the friends Data. List GetUserFriendList(UUID friendlistowner); + + // This probably shouldn't be here, it belongs to IAuthentication + // But since Scenes only have IUserService references, I'm placing it here for now. + bool VerifySession(UUID userID, UUID sessionID); } } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index d9556e4..d491309 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -37,6 +37,7 @@ using log4net; using Nwc.XmlRpc; using OpenMetaverse; using OpenMetaverse.StructuredData; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; @@ -194,6 +195,12 @@ namespace OpenSim.Framework.Communications.Services CreateAgent(userProfile, request); + // We need to commit the agent right here, even though the userProfile info is not complete + // at this point. There is another commit further down. + // This is for the new sessionID to be stored so that the region can check it for session authentication. + // CustomiseResponse->PrepareLoginToRegion + CommitAgent(ref userProfile); + try { UUID agentID = userProfile.ID; @@ -1108,5 +1115,44 @@ namespace OpenSim.Framework.Communications.Services { return false; } + + public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + string authed = "FALSE"; + if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) + { + UUID guess_aid; + UUID guess_sid; + + UUID.TryParse((string)requestData["avatar_uuid"], out guess_aid); + if (guess_aid == UUID.Zero) + { + return Util.CreateUnknownUserErrorResponse(); + } + UUID.TryParse((string)requestData["session_id"], out guess_sid); + if (guess_sid == UUID.Zero) + { + return Util.CreateUnknownUserErrorResponse(); + } + if (m_userManager.VerifySession(guess_aid, guess_sid)) + { + authed = "TRUE"; + } + m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); + } + else + { + m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); + return Util.CreateUnknownUserErrorResponse(); + } + Hashtable responseData = new Hashtable(); + responseData["auth_session"] = authed; + response.Value = responseData; + return response; + } + } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 5d6bc8d..178c356 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -178,6 +178,11 @@ namespace OpenSim.Framework.Communications.Tests { throw new NotImplementedException(); } + + public bool VerifySession(UUID userID, UUID sessionID) + { + return true; + } } [Test] diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 155f5cd..1115041 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -839,6 +839,21 @@ namespace OpenSim.Framework.Communications } } + public bool VerifySession(UUID userID, UUID sessionID) + { + UserProfileData userProfile = GetUserProfile(userID); + + if (userProfile != null && userProfile.CurrentAgent != null) + { + m_log.DebugFormat("[USERAUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID); + if (userProfile.CurrentAgent.SessionID == sessionID) + { + return true; + } + } + return false; + } + #endregion } } -- cgit v1.1 From 2a321746fdfb40bd0437daf1205c9e617869ff8e Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Tue, 14 Apr 2009 20:44:51 +0000 Subject: Fix a test-breakage introduced in r9144 --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 303efe1..e7dbf2d 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -111,7 +111,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" + m_regionExternalName - + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); } @@ -160,7 +160,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" + m_regionExternalName - + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{8}0000/$"); + + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); } -- cgit v1.1 From cab7a2a45ccc37acb4ea95f38dfc780580d0b161 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 16 Apr 2009 20:12:46 +0000 Subject: * Add name keyed cache to UserProfileCacheService --- .../Cache/UserProfileCacheService.cs | 147 +++++++++++++++------ 1 file changed, 105 insertions(+), 42 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b1ce3e7..4aed338 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -39,16 +39,28 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Standard format for names. + /// + public const string NAME_FORMAT = "{0} {1}"; + /// /// The comms manager holds references to services (user, grid, inventory, etc.) /// private readonly CommunicationsManager m_commsManager; /// - /// Each user has a cached profile. + /// User profiles indexed by UUID /// - private readonly Dictionary m_userProfiles = new Dictionary(); - + private readonly Dictionary m_userProfilesById + = new Dictionary(); + + /// + /// User profiles indexed by name + /// + private readonly Dictionary m_userProfilesByName + = new Dictionary(); + /// /// The root library folder. /// @@ -89,25 +101,49 @@ namespace OpenSim.Framework.Communications.Cache /// true if the user was successfully removed, false otherwise public bool RemoveUser(UUID userId) { - lock (m_userProfiles) + if (!RemoveFromCaches(userId)) { - if (m_userProfiles.ContainsKey(userId)) - { - m_userProfiles.Remove(userId); - return true; - } + m_log.WarnFormat( + "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); + + return false; } - m_log.WarnFormat( - "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); - - return false; + return true; } /// - /// Get cached details of the given user. If the user isn't in cache then the user is requested from the - /// profile service. + /// Get details of the given user. /// + /// If the user isn't in cache then the user is requested from the profile service. + /// + /// null if no user details are found + public CachedUserInfo GetUserDetails(string fname, string lname) + { + lock (m_userProfilesByName) + { + CachedUserInfo userInfo; + + if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) + { + return userInfo; + } + else + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); + + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; + } + } + } + + /// + /// Get details of the given user. + /// + /// If the user isn't in cache then the user is requested from the profile service. /// /// null if no user details are found public CachedUserInfo GetUserDetails(UUID userID) @@ -115,51 +151,78 @@ namespace OpenSim.Framework.Communications.Cache if (userID == UUID.Zero) return null; - lock (m_userProfiles) + lock (m_userProfilesById) { - if (m_userProfiles.ContainsKey(userID)) + if (m_userProfilesById.ContainsKey(userID)) { - return m_userProfiles[userID]; + return m_userProfilesById[userID]; } else { - UserProfileData userprofile = m_commsManager.UserService.GetUserProfile(userID); - if (userprofile != null) - { - CachedUserInfo userinfo = new CachedUserInfo(m_commsManager, userprofile); - m_userProfiles.Add(userID, userinfo); - return userinfo; - } + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); + if (userProfile != null) + return AddToCaches(userProfile); else - { return null; - } } } } - + /// - /// Preloads User data into the region cache. Modules may use this service to add non-standard clients + /// Populate caches with the given user profile /// - /// - /// - public void PreloadUserCache(UUID userID, UserProfileData userData) + /// + protected CachedUserInfo AddToCaches(UserProfileData userProfile) { - if (userID == UUID.Zero) - return; - - lock (m_userProfiles) + CachedUserInfo createdUserInfo = new CachedUserInfo(m_commsManager, userProfile); + + lock (m_userProfilesById) { - if (m_userProfiles.ContainsKey(userID)) + m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; + + lock (m_userProfilesByName) { - return; + m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; } - else + } + + return createdUserInfo; + } + + /// + /// Remove profile belong to the given uuid from the caches + /// + /// + /// true if there was a profile to remove, false otherwise + protected bool RemoveFromCaches(UUID userId) + { + lock (m_userProfilesById) + { + if (m_userProfilesById.ContainsKey(userId)) { - CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData); - m_userProfiles.Add(userID, userInfo); + CachedUserInfo userInfo = m_userProfilesById[userId]; + m_userProfilesById.Remove(userId); + + lock (m_userProfilesByName) + { + m_userProfilesByName.Remove(userInfo.UserProfile.Name); + } + + return true; } - } + } + + return false; + } + + /// + /// Preloads User data into the region cache. Modules may use this service to add non-standard clients + /// + /// + /// + public void PreloadUserCache(UUID userID, UserProfileData userData) + { + AddToCaches(userData); } } } -- cgit v1.1 From 235ae95b50388de7a653a2cdba5f02696e78e014 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 16 Apr 2009 20:24:11 +0000 Subject: * minor: Eliminate redundant argument in PreloadUserCache --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 4aed338..714e279 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -218,9 +218,8 @@ namespace OpenSim.Framework.Communications.Cache /// /// Preloads User data into the region cache. Modules may use this service to add non-standard clients /// - /// /// - public void PreloadUserCache(UUID userID, UserProfileData userData) + public void PreloadUserCache(UserProfileData userData) { AddToCaches(userData); } -- cgit v1.1 From bbe1e196963fe8609a1070793b8439c293261d24 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 17 Apr 2009 05:52:46 +0000 Subject: * Some more work on refactoring configs; * Moved the constants out into a separate DefaultConfig * Pulled configMember up * Some minor CCC --- OpenSim/Framework/Communications/Services/GridInfoService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index 030ea61..47ea61a 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -104,13 +104,13 @@ namespace OpenSim.Framework.Communications.Services if (grid) _info["login"] = netCfg.GetString( - "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + "user_server_url", "http://127.0.0.1:" + DefaultSettings.DefaultUserServerHttpPort.ToString()); else _info["login"] = String.Format( "http://127.0.0.1:{0}/", netCfg.GetString( - "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); + "http_listener_port", DefaultSettings.DefaultRegionHttpPort.ToString())); IssueWarning(); } -- cgit v1.1 From 3db52d95ef42bf82182af02c9c4ad5ea8cecee9e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 17 Apr 2009 14:41:56 +0000 Subject: * Extend get user profile test to cover retrieval by name --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 62 ++++++++++------------ .../Tests/Cache/UserProfileTestUtils.cs | 3 +- 2 files changed, 28 insertions(+), 37 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index e2576ef..34f5c97 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -30,39 +30,46 @@ using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; -//using OpenSim.Framework; namespace OpenSim.Framework.Communications.Tests { - /// - /// User profile cache service tests - /// [TestFixture] public class UserProfileCacheServiceTests { - /// - /// Test user details get. - /// [Test] public void TestGetUserDetails() { - UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); + string firstName = "Bill"; + string lastName = "Bailey"; + CachedUserInfo nonExistingUserInfo; + TestCommunicationsManager commsManager = new TestCommunicationsManager(); - CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); - - Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); - - CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); - - Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); + + // Check we can't retrieve info before it exists by uuid + nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); + + // Check we can't retrieve info before it exists by name + nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); + + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); + + CachedUserInfo existingUserInfo; + + // Check we can retrieve info by uuid + existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); + + // Check we can retrieve info by name + existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); } - /// - /// Test requesting inventory for a user - /// [Test] public void TestFetchInventory() { @@ -72,9 +79,6 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.HasReceivedInventory, Is.True); } - /// - /// Test retrieving a child folder - /// [Test] public void TestGetChildFolder() { @@ -89,9 +93,6 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); } - /// - /// Test creating an inventory folder - /// [Test] public void TestCreateFolder() { @@ -119,9 +120,6 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } - /// - /// Test updating a folder - /// [Test] public void TestUpdateFolder() { @@ -176,9 +174,6 @@ namespace OpenSim.Framework.Communications.Tests } - /// - /// Test moving an inventory folder - /// [Test] public void TestMoveFolder() { @@ -210,9 +205,6 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } - /// - /// Test purging an inventory folder - /// [Test] public void TestPurgeFolder() { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index 93ce916..d0f92d6 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -32,7 +32,7 @@ using OpenSim.Region.Communications.Local; namespace OpenSim.Framework.Communications.Tests { /// - /// Utility functions for carrying out user profile relate tests. + /// Utility functions for carrying out user profile related tests. /// public class UserProfileTestUtils { @@ -56,7 +56,6 @@ namespace OpenSim.Framework.Communications.Tests public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) { LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); -- cgit v1.1 From a189da844a1ec48b321674f49a81c4e0a71c8b81 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 17 Apr 2009 15:09:37 +0000 Subject: * Moved the DefaultConfig settings into already-existing ConfigSettings --- OpenSim/Framework/Communications/Services/GridInfoService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index 47ea61a..e53400c 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -104,13 +104,13 @@ namespace OpenSim.Framework.Communications.Services if (grid) _info["login"] = netCfg.GetString( - "user_server_url", "http://127.0.0.1:" + DefaultSettings.DefaultUserServerHttpPort.ToString()); + "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()); else _info["login"] = String.Format( "http://127.0.0.1:{0}/", netCfg.GetString( - "http_listener_port", DefaultSettings.DefaultRegionHttpPort.ToString())); + "http_listener_port", ConfigSettings.DefaultRegionHttpPort.ToString())); IssueWarning(); } -- cgit v1.1 From bd1b478f2c89fc1696b9e8fc6c0deaa9581bd556 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 17 Apr 2009 19:11:03 +0000 Subject: * Change inventory archiver module to use profile cache * Clean up some log messages --- OpenSim/Framework/Communications/Services/LoginService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index d491309..bb289e3 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -292,7 +292,8 @@ namespace OpenSim.Framework.Communications.Services } } - protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) + protected virtual bool TryAuthenticateXmlRpcLogin( + XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) { Hashtable requestData = (Hashtable)request.Params[0]; -- cgit v1.1 From 37f98a65d4b82302819a5fc6761876fae275ef8a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 17 Apr 2009 20:00:35 +0000 Subject: add fix for LLSDVoiceAccountResponse to work with freeswitch (from Rob Smart) --- .../Communications/Capabilities/LLSDVoiceAccountResponse.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 6cd5ee3..3735c77 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -33,6 +33,8 @@ namespace OpenSim.Framework.Communications.Capabilities { public string username; public string password; + public string voice_sip_uri_hostname; + public string voice_account_server_name; public LLSDVoiceAccountResponse() { @@ -43,5 +45,13 @@ namespace OpenSim.Framework.Communications.Capabilities username = user; password = pass; } + + public LLSDVoiceAccountResponse(string user, string pass, string sipUriHost, string accountServer) + { + username = user; + password = pass; + voice_sip_uri_hostname = sipUriHost; + voice_account_server_name = accountServer; + } } } \ No newline at end of file -- cgit v1.1 From bc02eab4b98e1244e6033e061a8242dfdce3c67c Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 18 Apr 2009 02:37:12 +0000 Subject: Commit agent to DB immediately after creation, for LLSD logins too. Addresses mantis #3471. Requires upgrade of User Server in grid mode for this fix to kick in. --- OpenSim/Framework/Communications/Services/LoginService.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index bb289e3..72a4281 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -425,6 +425,12 @@ namespace OpenSim.Framework.Communications.Services CreateAgent(userProfile, request); + // We need to commit the agent right here, even though the userProfile info is not complete + // at this point. There is another commit further down. + // This is for the new sessionID to be stored so that the region can check it for session authentication. + // CustomiseResponse->PrepareLoginToRegion + CommitAgent(ref userProfile); + try { UUID agentID = userProfile.ID; -- cgit v1.1 From b824e488ba4e43d3e76ff8831ad514607db03928 Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 18 Apr 2009 15:45:05 +0000 Subject: Addresses mantis #3485. --- OpenSim/Framework/Communications/Clients/AuthClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 6111aee..49ec7ba 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -129,12 +129,12 @@ namespace OpenSim.Framework.Communications.Clients Hashtable responseData = (Hashtable)UserResp.Value; if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") { - System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); + //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); return true; } else { - System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); + //System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); return false; } } -- cgit v1.1 From d2d0b9877fcc6150e3a2e21283ec80ef7eda9cae Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 21 Apr 2009 15:21:27 +0000 Subject: * Add the ability to update profiles via the cache, so that cached profiles don't become stale * Add corresponding unit test --- .../Communications/Cache/CachedUserInfo.cs | 2 +- .../Cache/UserProfileCacheService.cs | 23 +++++++++++++++++ .../Tests/Cache/UserProfileCacheServiceTests.cs | 29 ++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 32c235a..98ec287 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache private readonly CommunicationsManager m_commsManager; public UserProfileData UserProfile { get { return m_userProfile; } } - private readonly UserProfileData m_userProfile; + protected internal UserProfileData m_userProfile; /// /// Have we received the user's inventory from the inventory service? diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 714e279..36fe6e3 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -169,6 +169,29 @@ namespace OpenSim.Framework.Communications.Cache } /// + /// Update an existing profile + /// + /// + /// true if a user profile was found to update, false otherwise + public bool UpdateProfile(UserProfileData userProfile) + { + lock (m_userProfilesById) + { + CachedUserInfo userInfo = GetUserDetails(userProfile.ID); + + if (userInfo != null) + { + userInfo.m_userProfile = userProfile; + m_commsManager.UserService.UpdateUserProfile(userProfile); + + return true; + } + } + + return false; + } + + /// /// Populate caches with the given user profile /// /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 34f5c97..68303b0 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -29,6 +29,7 @@ using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Data; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; @@ -69,6 +70,34 @@ namespace OpenSim.Framework.Communications.Tests existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); } + + [Test] + public void TestUpdateProfile() + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); + string firstName = "Inspector"; + string originalLastName = "Morse"; + string newLastName = "Gadget"; + + UserProfileData newProfile = new UserProfileData(); + newProfile.ID = userId; + newProfile.FirstName = firstName; + newProfile.SurName = newLastName; + + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; + + // Check that we can't update info before it exists + Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); + + // Check that we can update a profile once it exists + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); + + Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); + UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; + Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); + } [Test] public void TestFetchInventory() -- cgit v1.1 From 48720ea7a227a0eebecff365deb295fc08207c6c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 21 Apr 2009 16:21:15 +0000 Subject: * extend user cache update test to check data backend --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 68303b0..c7f3bfc 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -86,9 +86,11 @@ namespace OpenSim.Framework.Communications.Tests TestCommunicationsManager commsManager = new TestCommunicationsManager(); UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; + IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; // Check that we can't update info before it exists Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); + Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); // Check that we can update a profile once it exists LocalUserServices lus = (LocalUserServices)commsManager.UserService; @@ -97,6 +99,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); + Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); } [Test] -- cgit v1.1 From 607156cae844ec97b8bab273075127a6248a81c3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 21 Apr 2009 20:12:33 +0000 Subject: * Comment out user profile cache update method for now --- .../Communications/Cache/CachedUserInfo.cs | 2 +- .../Cache/UserProfileCacheService.cs | 37 ++++++++++++---------- .../Tests/Cache/UserProfileCacheServiceTests.cs | 3 ++ 3 files changed, 24 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 98ec287..52869b1 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache private readonly CommunicationsManager m_commsManager; public UserProfileData UserProfile { get { return m_userProfile; } } - protected internal UserProfileData m_userProfile; + private UserProfileData m_userProfile; /// /// Have we received the user's inventory from the inventory service? diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 36fe6e3..8f37f27 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -173,23 +173,26 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if a user profile was found to update, false otherwise - public bool UpdateProfile(UserProfileData userProfile) - { - lock (m_userProfilesById) - { - CachedUserInfo userInfo = GetUserDetails(userProfile.ID); - - if (userInfo != null) - { - userInfo.m_userProfile = userProfile; - m_commsManager.UserService.UpdateUserProfile(userProfile); - - return true; - } - } - - return false; - } + // Commented out for now. The implementation needs to be improved by protecting against race conditions, + // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via + // returning a read only class from the cache). +// public bool UpdateProfile(UserProfileData userProfile) +// { +// lock (m_userProfilesById) +// { +// CachedUserInfo userInfo = GetUserDetails(userProfile.ID); +// +// if (userInfo != null) +// { +// userInfo.m_userProfile = userProfile; +// m_commsManager.UserService.UpdateUserProfile(userProfile); +// +// return true; +// } +// } +// +// return false; +// } /// /// Populate caches with the given user profile diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index c7f3bfc..1711187 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -71,6 +71,8 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); } + /** + * Disabled as not fully implemented [Test] public void TestUpdateProfile() { @@ -101,6 +103,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); } + */ [Test] public void TestFetchInventory() -- cgit v1.1 From 458f7eb9b38609d02980afe5a6ee88d19c7dd7f8 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 22 Apr 2009 09:42:44 +0000 Subject: cleaning up, fixing warnings --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 8c451b0..ad8d625 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -391,10 +391,10 @@ namespace OpenSim.Framework.Communications.Cache protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) { - if (!IsTexture && assetInf.ContainsReferences && false) - { - assetInf.Data = ProcessAssetData(assetInf.Data, userService); - } + // if (!IsTexture && assetInf.ContainsReferences && false) + // { + // assetInf.Data = ProcessAssetData(assetInf.Data, userService); + // } } // See IAssetReceiver -- cgit v1.1 From 2c81e41c8a884ece643f3079349b033d03b6b774 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 22 Apr 2009 18:15:43 +0000 Subject: * Fission OGS1UserServices into user service and OGS1 user data plugin components * Make OGS1UserServices inherit from UserManagerBase * This allows grid mode regions to use the same user data plugin infrastructure as grid servers and standalone OpenSims --- OpenSim/Framework/Communications/IAvatarService.cs | 12 ++- .../Communications/Services/LoginService.cs | 13 +-- .../Framework/Communications/UserManagerBase.cs | 108 ++++++++++----------- 3 files changed, 68 insertions(+), 65 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 3822e9f..db583e1 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -31,10 +31,18 @@ namespace OpenSim.Framework.Communications { public interface IAvatarService { - /// Get's the User Appearance + /// + /// Get avatar appearance information + /// + /// + /// AvatarAppearance GetUserAppearance(UUID user); + /// + /// Update avatar appearance information + /// + /// + /// void UpdateUserAppearance(UUID user, AvatarAppearance appearance); - } } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 72a4281..1b71367 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1147,14 +1147,15 @@ namespace OpenSim.Framework.Communications.Services if (m_userManager.VerifySession(guess_aid, guess_sid)) { authed = "TRUE"; + m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); + } + else + { + m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); + return Util.CreateUnknownUserErrorResponse(); } - m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); - } - else - { - m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); - return Util.CreateUnknownUserErrorResponse(); } + Hashtable responseData = new Hashtable(); responseData["auth_session"] = authed; response.Value = responseData; diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1115041..3b43622 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications /// /// List of plugins to search for user data /// - private List _plugins = new List(); + private List m_plugins = new List(); protected IInterServiceInventoryServices m_interServiceInventoryService; @@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications /// The plugin that will provide user data public void AddPlugin(IUserDataPlugin plugin) { - _plugins.Add(plugin); + m_plugins.Add(plugin); } /// @@ -84,15 +84,15 @@ namespace OpenSim.Framework.Communications /// public void AddPlugin(string provider, string connect) { - _plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); + m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); } #region Get UserProfile // see IUserService - public UserProfileData GetUserProfile(string fname, string lname) + public virtual UserProfileData GetUserProfile(string fname, string lname) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { UserProfileData profile = plugin.GetUserByName(fname, lname); @@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications public void LogoutUsers(UUID regionID) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { plugin.LogoutUsers(regionID); } @@ -116,7 +116,7 @@ namespace OpenSim.Framework.Communications public void ResetAttachments(UUID userID) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { plugin.ResetAttachments(userID); } @@ -124,12 +124,20 @@ namespace OpenSim.Framework.Communications public UserProfileData GetUserProfile(Uri uri) { - throw new NotImplementedException(); + foreach (IUserDataPlugin plugin in m_plugins) + { + UserProfileData profile = plugin.GetUserByUri(uri); + + if (null != profile) + return profile; + } + + return null; } - public UserAgentData GetAgentByUUID(UUID userId) + public virtual UserAgentData GetAgentByUUID(UUID userId) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { UserAgentData agent = plugin.GetAgentByUUID(userId); @@ -150,7 +158,7 @@ namespace OpenSim.Framework.Communications // see IUserService public virtual UserProfileData GetUserProfile(UUID uuid) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { UserProfileData profile = plugin.GetUserByUUID(uuid); @@ -164,10 +172,10 @@ namespace OpenSim.Framework.Communications return null; } - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) + public virtual List GenerateAgentPickerRequestResponse(UUID queryID, string query) { List pickerlist = new List(); - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -188,9 +196,9 @@ namespace OpenSim.Framework.Communications /// /// /// - public bool UpdateUserProfile(UserProfileData data) + public virtual bool UpdateUserProfile(UserProfileData data) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -217,7 +225,7 @@ namespace OpenSim.Framework.Communications /// Agent profiles public UserAgentData GetUserAgent(UUID uuid) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -244,7 +252,7 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string name) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -267,7 +275,7 @@ namespace OpenSim.Framework.Communications /// A user agent public UserAgentData GetUserAgent(string fname, string lname) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -287,9 +295,9 @@ namespace OpenSim.Framework.Communications /// /// the UUID of the friend list owner /// A List of FriendListItems that contains info about the user's friends - public List GetUserFriendList(UUID ownerID) + public virtual List GetUserFriendList(UUID ownerID) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -309,9 +317,9 @@ namespace OpenSim.Framework.Communications return null; } - public Dictionary GetFriendRegionInfos (List uuids) + public virtual Dictionary GetFriendRegionInfos (List uuids) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -332,7 +340,7 @@ namespace OpenSim.Framework.Communications public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -345,13 +353,13 @@ namespace OpenSim.Framework.Communications } } - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) + public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { - plugin.AddNewUserFriend(friendlistowner,friend,perms); + plugin.AddNewUserFriend(friendlistowner, friend, perms); } catch (Exception e) { @@ -360,9 +368,9 @@ namespace OpenSim.Framework.Communications } } - public void RemoveUserFriend(UUID friendlistowner, UUID friend) + public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -375,9 +383,9 @@ namespace OpenSim.Framework.Communications } } - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) + public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -394,7 +402,7 @@ namespace OpenSim.Framework.Communications /// Resets the currentAgent in the user profile /// /// The agent's ID - public void ClearUserAgent(UUID agentID) + public virtual void ClearUserAgent(UUID agentID) { UserProfileData profile = GetUserProfile(agentID); @@ -408,7 +416,6 @@ namespace OpenSim.Framework.Communications UpdateUserProfile(profile); } - #endregion #region CreateAgent @@ -544,7 +551,7 @@ namespace OpenSim.Framework.Communications /// /// /// - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) + public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) { if (StatsManager.UserStats != null) StatsManager.UserStats.AddLogout(); @@ -583,15 +590,6 @@ namespace OpenSim.Framework.Communications } } - /// - /// Process a user logoff from OpenSim (deprecated as of 2008-08-27) - /// - /// - /// - /// - /// - /// - /// public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); @@ -643,7 +641,7 @@ namespace OpenSim.Framework.Communications user.HomeRegionY = regY; user.Email = email; - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -669,13 +667,13 @@ namespace OpenSim.Framework.Communications } /// - /// Reset a user password + /// Reset a user password. /// /// /// /// /// true if the update was successful, false otherwise - public bool ResetUserPassword(string firstName, string lastName, string newPassword) + public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); @@ -705,7 +703,7 @@ namespace OpenSim.Framework.Communications /// The agent data to be added public bool AddUserAgent(UserAgentData agentdata) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -725,9 +723,9 @@ namespace OpenSim.Framework.Communications /// /// /// - public AvatarAppearance GetUserAppearance(UUID user) + public virtual AvatarAppearance GetUserAppearance(UUID user) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -741,14 +739,9 @@ namespace OpenSim.Framework.Communications return null; } - /// - /// Update avatar appearance information - /// - /// - /// - public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) + public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { - foreach (IUserDataPlugin plugin in _plugins) + foreach (IUserDataPlugin plugin in m_plugins) { try { @@ -838,8 +831,8 @@ namespace OpenSim.Framework.Communications return false; } } - - public bool VerifySession(UUID userID, UUID sessionID) + + public virtual bool VerifySession(UUID userID, UUID sessionID) { UserProfileData userProfile = GetUserProfile(userID); @@ -851,6 +844,7 @@ namespace OpenSim.Framework.Communications return true; } } + return false; } -- cgit v1.1 From 4c806855636543eba0423bfca0ef2084d7d7a536 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 22 Apr 2009 19:26:18 +0000 Subject: * Allow plugins to play nicely in UserManagerBase * Some methods were returning the value of the first plugin queried, even if the return was null * Other methods are probably best off querying more than one plugin and aggregating results --- .../Framework/Communications/UserManagerBase.cs | 48 +++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 3b43622..a269b59 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -174,44 +174,46 @@ namespace OpenSim.Framework.Communications public virtual List GenerateAgentPickerRequestResponse(UUID queryID, string query) { - List pickerlist = new List(); + List allPickerList = new List(); + foreach (IUserDataPlugin plugin in m_plugins) { try { - pickerlist = plugin.GeneratePickerResults(queryID, query); + List pickerList = plugin.GeneratePickerResults(queryID, query); + if (pickerList != null) + allPickerList.AddRange(pickerList); } catch (Exception) { - m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); - return new List(); + m_log.Error( + "[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); } } - return pickerlist; + return allPickerList; } - - /// - /// Updates a user profile from data object - /// - /// - /// + public virtual bool UpdateUserProfile(UserProfileData data) { + bool result = false; + foreach (IUserDataPlugin plugin in m_plugins) { try { plugin.UpdateUserProfile(data); - return true; + result = true; } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, - plugin.Name, e.ToString()); + m_log.InfoFormat( + "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", + data.FirstName, data.SurName, plugin.Name, e.ToString()); } } - return false; + + return result; } #endregion @@ -232,9 +234,7 @@ namespace OpenSim.Framework.Communications UserAgentData result = plugin.GetAgentByUUID(uuid); if (result != null) - { return result; - } } catch (Exception e) { @@ -256,7 +256,10 @@ namespace OpenSim.Framework.Communications { try { - return plugin.GetAgentByName(name); + UserAgentData result = plugin.GetAgentByName(name); + + if (result != null) + return result; } catch (Exception e) { @@ -279,7 +282,10 @@ namespace OpenSim.Framework.Communications { try { - return plugin.GetAgentByName(fname, lname); + UserAgentData result = plugin.GetAgentByName(fname, lname); + + if (result != null) + return result; } catch (Exception e) { @@ -304,9 +310,7 @@ namespace OpenSim.Framework.Communications List result = plugin.GetUserFriendList(ownerID); if (result != null) - { return result; - } } catch (Exception e) { @@ -326,9 +330,7 @@ namespace OpenSim.Framework.Communications Dictionary result = plugin.GetFriendRegionInfos(uuids); if (result != null) - { return result; - } } catch (Exception e) { -- cgit v1.1 From 342126b7b9ca386f9160daecb51ecc14487a5f9f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 22 Apr 2009 22:19:43 +0000 Subject: * Resolve http://opensimulator.org/mantis/view.php?id=3509 by putting some service initialization into CommsManager * What is really needed is a plugin and interface request system as being done for region modules --- .../Communications/CommunicationsManager.cs | 6 +++ OpenSim/Framework/Communications/IUserService.cs | 7 +++- .../Framework/Communications/UserManagerBase.cs | 45 ++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index b4078fd..1df1f48 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -36,6 +36,12 @@ namespace OpenSim.Framework.Communications /// /// This class manages references to OpenSim non-region services (asset, inventory, user, etc.) /// + /// + /// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region + /// modules from scene. Among other things, this will allow this class to be used in many different contexts + /// (from a grid service executable, to provide services on a region) without lots of messy nulls and confusion. + /// Also, a post initialize step on the plugins will be needed so that we don't get tortuous problems with + /// circular dependencies between plugins. public class CommunicationsManager { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 3a56d35..fb24c15 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -117,7 +117,12 @@ namespace OpenSim.Framework.Communications /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship /// for UUID friendslistowner /// - /// The agent that we're retreiving the friends Data. + /// + /// The agent for whom we're retreiving the friends Data. + /// + /// A List of FriendListItems that contains info about the user's friends. + /// Always returns a list even if the user has no friends + /// List GetUserFriendList(UUID friendlistowner); // This probably shouldn't be here, it belongs to IAuthentication diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index a269b59..2d0bf63 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -35,6 +35,7 @@ using Nwc.XmlRpc; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Data; +using OpenSim.Framework.Communications; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications @@ -52,15 +53,15 @@ namespace OpenSim.Framework.Communications /// private List m_plugins = new List(); - protected IInterServiceInventoryServices m_interServiceInventoryService; + protected CommunicationsManager m_commsManager; /// /// Constructor /// - /// - public UserManagerBase(IInterServiceInventoryServices interServiceInventoryService) + /// + public UserManagerBase(CommunicationsManager commsManager) { - m_interServiceInventoryService = interServiceInventoryService; + m_commsManager = commsManager; } /// @@ -296,48 +297,48 @@ namespace OpenSim.Framework.Communications return null; } - /// - /// Loads a user's friend list - /// - /// the UUID of the friend list owner - /// A List of FriendListItems that contains info about the user's friends public virtual List GetUserFriendList(UUID ownerID) { + List allFriends = new List(); + foreach (IUserDataPlugin plugin in m_plugins) { try { - List result = plugin.GetUserFriendList(ownerID); + List friends = plugin.GetUserFriendList(ownerID); - if (result != null) - return result; + if (friends != null) + allFriends.AddRange(friends); } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); } } - return null; + return allFriends; } public virtual Dictionary GetFriendRegionInfos (List uuids) { + //Dictionary allFriendRegions = new Dictionary(); + foreach (IUserDataPlugin plugin in m_plugins) { try { - Dictionary result = plugin.GetFriendRegionInfos(uuids); + Dictionary friendRegions = plugin.GetFriendRegionInfos(uuids); - if (result != null) - return result; + if (friendRegions != null) + return friendRegions; } catch (Exception e) { m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); } } - return null; + + return new Dictionary(); } public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) @@ -662,7 +663,7 @@ namespace OpenSim.Framework.Communications } else { - m_interServiceInventoryService.CreateNewUserInventory(userProf.ID); + m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID); return userProf.ID; } @@ -731,13 +732,17 @@ namespace OpenSim.Framework.Communications { try { - return plugin.GetUserAppearance(user); + AvatarAppearance appearance = plugin.GetUserAppearance(user); + + if (appearance != null) + return appearance; } catch (Exception e) { m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } + return null; } -- cgit v1.1 From bd8e4a8892e204e2d9e7e24087f7200c16be57f0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 22 Apr 2009 23:04:32 +0000 Subject: * Fix hypergrid standalone login by overriding AddNewUserAgent in HGUserServices --- .../Framework/Communications/Services/HGLoginAuthService.cs | 5 +---- OpenSim/Framework/Communications/UserManagerBase.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 5e357d5..b62e4a2 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -61,7 +61,6 @@ namespace OpenSim.Framework.Communications.Services /// protected ILoginServiceToRegionsConnector m_regionsConnector; - public HGLoginAuthService( UserManagerBase userManager, string welcomeMess, IInterServiceInventoryServices interServiceInventoryService, @@ -89,7 +88,7 @@ namespace OpenSim.Framework.Communications.Services public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); + m_log.Info("[HGLOGIN]: HGLogin called " + request.MethodName); XmlRpcResponse response = base.XmlRpcLoginMethod(request); Hashtable responseData = (Hashtable)response.Value; @@ -135,7 +134,6 @@ namespace OpenSim.Framework.Communications.Services public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) { - // Verify the key of who's calling UUID userID = UUID.Zero; UUID authKey = UUID.Zero; @@ -254,7 +252,6 @@ namespace OpenSim.Framework.Communications.Services return m_regionsConnector.RequestNeighbourInfo(homeRegionId); } - /// /// Not really informing the region. Just filling out the response fields related to the region. /// diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 2d0bf63..9cd7658 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -430,6 +430,8 @@ namespace OpenSim.Framework.Communications /// The users loginrequest public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { + //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); + UserAgentData agent = new UserAgentData(); // User connection @@ -483,6 +485,8 @@ namespace OpenSim.Framework.Communications public void CreateAgent(UserProfileData profile, OSD request) { + //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); + UserAgentData agent = new UserAgentData(); // User connection @@ -538,6 +542,8 @@ namespace OpenSim.Framework.Communications /// Successful? public bool CommitAgent(ref UserProfileData profile) { + //m_log.DebugFormat("[USER MANAGER]: Committing agent {0} {1}", profile.Name, profile.ID); + // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" // TODO: what is the logic should be? bool ret = false; @@ -704,7 +710,7 @@ namespace OpenSim.Framework.Communications /// Add agent to DB ///
/// The agent data to be added - public bool AddUserAgent(UserAgentData agentdata) + public virtual bool AddUserAgent(UserAgentData agentdata) { foreach (IUserDataPlugin plugin in m_plugins) { @@ -845,7 +851,7 @@ namespace OpenSim.Framework.Communications if (userProfile != null && userProfile.CurrentAgent != null) { - m_log.DebugFormat("[USERAUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID); + m_log.DebugFormat("[USER AUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID); if (userProfile.CurrentAgent.SessionID == sessionID) { return true; -- cgit v1.1 From 31bded51fb8d2a51d8b97abbd5f8f6e142b09e69 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 23 Apr 2009 17:38:08 +0000 Subject: based on recent unit test output, put some extra checking in the RunAssetCache error code --- OpenSim/Framework/Communications/Cache/AssetCache.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index ad8d625..f214e19 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -185,7 +185,15 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.Error("[ASSET CACHE]: " + e.ToString()); + if (e != null) + { + m_log.ErrorFormat("[ASSET CACHE]: {0}", e); + } + else + { + // this looks weird, but we've seen this show up as an issue in unit tests, so leave it here until we know why + m_log.Error("[ASSET CACHE]: an exception was thrown in RunAssetManager, but is now null. Something is very wrong."); + } } } } -- cgit v1.1 From 7943ae48f506f23ac89fdcc0593c296c2cbf6540 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 23 Apr 2009 17:53:18 +0000 Subject: move the lock out a bit further in the ProccessAssetCache loop to reduce the number of times we are going to take this lock in a row (which is just wasted resource), and to keep us from attempting to array access a list which might be changing right now. Extremely curious if this helps prevent some of our mono segfaults. --- .../Framework/Communications/Cache/AssetCache.cs | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f214e19..7d25ca9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -515,7 +515,10 @@ namespace OpenSim.Framework.Communications.Cache req.Params = transferRequest.TransferInfo.Params; req.AssetInf = new AssetInfo(asset); req.NumPackets = CalculateNumPackets(asset.Data); - lock (AssetRequests) AssetRequests.Add(req); + lock (AssetRequests) + { + AssetRequests.Add(req); + } } /// @@ -536,26 +539,25 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; AssetRequestToClient req2 = new AssetRequestToClient(); - for (int i = 0; i < num; i++) + lock (AssetRequests) { - lock (AssetRequests) + for (int i = 0; i < num; i++) { req = AssetRequests[0]; AssetRequests.RemoveAt(0); + req2.AssetInf = req.AssetInf; + req2.AssetRequestSource = req.AssetRequestSource; + req2.DataPointer = req.DataPointer; + req2.DiscardLevel = req.DiscardLevel; + req2.ImageInfo = req.ImageInfo; + req2.IsTextureRequest = req.IsTextureRequest; + req2.NumPackets = req.NumPackets; + req2.PacketCounter = req.PacketCounter; + req2.Params = req.Params; + req2.RequestAssetID = req.RequestAssetID; + req2.TransferRequestID = req.TransferRequestID; + req.RequestUser.SendAsset(req2); } - - req2.AssetInf = req.AssetInf; - req2.AssetRequestSource = req.AssetRequestSource; - req2.DataPointer = req.DataPointer; - req2.DiscardLevel = req.DiscardLevel; - req2.ImageInfo = req.ImageInfo; - req2.IsTextureRequest = req.IsTextureRequest; - req2.NumPackets = req.NumPackets; - req2.PacketCounter = req.PacketCounter; - req2.Params = req.Params; - req2.RequestAssetID = req.RequestAssetID; - req2.TransferRequestID = req.TransferRequestID; - req.RequestUser.SendAsset(req2); } } -- cgit v1.1 From ef9d140022b57b175f41602731ec73775bdf2d9c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 23 Apr 2009 18:24:39 +0000 Subject: * Add user data plugin to store temporary profiles (which are distinct from cached) * Plugin not yet used * Existing functionality should not be affected in any way --- .../Communications/Services/LoginService.cs | 2 +- .../Communications/TemporaryUserProfilePlugin.cs | 88 ++++++++++++++++++++++ .../Communications/Tests/LoginServiceTests.cs | 7 +- .../Framework/Communications/UserManagerBase.cs | 40 +++++----- 4 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 1b71367..168f7a6 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Communications.Services // Reject the login m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", firstname, lastname); return logResponse.CreateAlreadyLoggedInResponse(); diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs new file mode 100644 index 0000000..1cfeaf1 --- /dev/null +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Data; + +namespace OpenSim.Framework.Communications +{ + /// + /// Plugin for managing temporary user profiles. + /// + public class TemporaryUserProfilePlugin : IUserDataPlugin + { + protected Dictionary m_profiles = new Dictionary(); + + public string Name { get { return "TemporaryUserProfilePlugin"; } } + public string Version { get { return "0.1"; } } + public void Initialise() {} + public void Initialise(string connect) {} + public void Dispose() {} + + public UserProfileData GetUserByUUID(UUID user) + { + lock (m_profiles) + { + if (m_profiles.ContainsKey(user)) + return m_profiles[user]; + else + return null; + } + } + + public UserProfileData GetUserByName(string fname, string lname) + { + // We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary + // profiles. + + return null; + } + + public UserProfileData GetUserByUri(Uri uri) { return null; } + public List GeneratePickerResults(UUID queryID, string query) { return null; } + public UserAgentData GetAgentByUUID(UUID user) { return null; } + public UserAgentData GetAgentByName(string name) { return null; } + public UserAgentData GetAgentByName(string fname, string lname) { return null; } + public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} + public void AddNewUserProfile(UserProfileData user) {} + public bool UpdateUserProfile(UserProfileData user) { return false; } + public void AddNewUserAgent(UserAgentData agent) {} + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {} + public void RemoveUserFriend(UUID friendlistowner, UUID friend) {} + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {} + public List GetUserFriendList(UUID friendlistowner) { return null; } + public Dictionary GetFriendRegionInfos(List uuids) { return null; } + public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } + public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } + public AvatarAppearance GetUserAppearance(UUID user) { return null; } + public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} + public void ResetAttachments(UUID userID) {} + public void LogoutUsers(UUID regionID) {} + } +} diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index e7dbf2d..42fdea5 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -280,6 +280,9 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { + Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); + log4net.Config.XmlConfigurator.Configure(); + string error_already_logged = "You appear to be already logged in. " + "If this is not the case please wait for your session to timeout. " + "If this takes longer than a few minutes please contact the grid owner. " + @@ -303,7 +306,6 @@ namespace OpenSim.Framework.Communications.Tests // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); @@ -314,11 +316,12 @@ namespace OpenSim.Framework.Communications.Tests response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); + + Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); } public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector { - private List m_regionsList = new List(); public void AddRegion(RegionInfo regionInfo) diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 9cd7658..b6a7362 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -208,7 +208,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat( + m_log.ErrorFormat( "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, plugin.Name, e.ToString()); } @@ -239,7 +239,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -290,7 +290,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -334,7 +334,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -351,7 +351,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -366,7 +366,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -381,7 +381,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -396,7 +396,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -707,24 +707,30 @@ namespace OpenSim.Framework.Communications public abstract UserProfileData SetupMasterUser(UUID uuid); /// - /// Add agent to DB + /// Add an agent using data plugins. /// /// The agent data to be added + /// + /// true if at least one plugin added the user agent. false if no plugin successfully added the agent + /// public virtual bool AddUserAgent(UserAgentData agentdata) { + bool result = false; + foreach (IUserDataPlugin plugin in m_plugins) { try { plugin.AddNewUserAgent(agentdata); - return true; + result = true; } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); } } - return false; + + return result; } /// @@ -745,7 +751,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); + m_log.ErrorFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } @@ -762,7 +768,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); + m_log.ErrorFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } } @@ -811,10 +817,10 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID); } else - m_log.Info("[USERAUTH]: Unauthorized key generation request. Denying new key."); + m_log.Warn("[USERAUTH]: Unauthorized key generation request. Denying new key."); } else - m_log.Info("[USERAUTH]: User not found."); + m_log.Warn("[USERAUTH]: User not found."); return url + newKey; } -- cgit v1.1 From 0d51c22620315f125ddbd3fe501eb93f318038d8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 23 Apr 2009 18:57:39 +0000 Subject: * Allow interested user data plugins to store temporary user profiles * Database and the OGS1 plugins are not interested and hence ignore these calls --- OpenSim/Framework/Communications/IUserService.cs | 7 +++++++ .../Framework/Communications/TemporaryUserProfilePlugin.cs | 8 ++++++++ .../Framework/Communications/Tests/Cache/AssetCacheTests.cs | 5 +++++ OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 6 +++--- OpenSim/Framework/Communications/UserManagerBase.cs | 13 ++++++++++--- 5 files changed, 33 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index fb24c15..9a3e211 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -34,6 +34,13 @@ namespace OpenSim.Framework.Communications public interface IUserService { /// + /// Add a temporary user profile. + /// + /// A temporary user profile is one that should exist only for the lifetime of the process. + /// + void AddTemporaryUserProfile(UserProfileData userProfile); + + /// /// Loads a user profile by name /// /// First name diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index 1cfeaf1..3b78c99 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -64,6 +64,14 @@ namespace OpenSim.Framework.Communications return null; } + public virtual void AddTemporaryUserProfile(UserProfileData userProfile) + { + lock (m_profiles) + { + m_profiles[userProfile.ID] = userProfile; + } + } + public UserProfileData GetUserByUri(Uri uri) { return null; } public List GeneratePickerResults(UUID queryID, string query) { return null; } public UserAgentData GetAgentByUUID(UUID user) { return null; } diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 178c356..a5ee549 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -90,6 +90,11 @@ namespace OpenSim.Framework.Communications.Tests private class FakeUserService : IUserService { + public void AddTemporaryUserProfile(UserProfileData userProfile) + { + throw new NotImplementedException(); + } + public UserProfileData GetUserProfile(string firstName, string lastName) { throw new NotImplementedException(); diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 42fdea5..d0c1b3b 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -280,8 +280,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { - Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); - log4net.Config.XmlConfigurator.Configure(); + //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); + //log4net.Config.XmlConfigurator.Configure(); string error_already_logged = "You appear to be already logged in. " + "If this is not the case please wait for your session to timeout. " + @@ -317,7 +317,7 @@ namespace OpenSim.Framework.Communications.Tests responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); - Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); + //Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); } public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b6a7362..133f810 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -88,9 +88,16 @@ namespace OpenSim.Framework.Communications m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); } - #region Get UserProfile - - // see IUserService + #region UserProfile + + public virtual void AddTemporaryUserProfile(UserProfileData userProfile) + { + foreach (IUserDataPlugin plugin in m_plugins) + { + plugin.AddTemporaryUserProfile(userProfile); + } + } + public virtual UserProfileData GetUserProfile(string fname, string lname) { foreach (IUserDataPlugin plugin in m_plugins) -- cgit v1.1 From 8fe70c826d06a949cde32ac7ff06022b0696a29f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 24 Apr 2009 19:19:19 +0000 Subject: * minor: move user profile test utils to test/common/setup for future reuse --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 1 + .../Tests/Cache/UserProfileTestUtils.cs | 67 ---------------------- 2 files changed, 1 insertion(+), 67 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 1711187..2972a0a 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -33,6 +33,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; +using OpenSim.Tests.Common.Setup; namespace OpenSim.Framework.Communications.Tests { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs deleted file mode 100644 index d0f92d6..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Region.Communications.Local; - -namespace OpenSim.Framework.Communications.Tests -{ - /// - /// Utility functions for carrying out user profile related tests. - /// - public class UserProfileTestUtils - { - /// - /// Create a test user with a standard inventory - /// - /// - /// - public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) - { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); - return CreateUserWithInventory(commsManager, userId); - } - - /// - /// Create a test user with a standard inventory - /// - /// - /// Explicit user id to use for user creation - /// - public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) - { - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); - userInfo.FetchInventory(); - - return userInfo; - } - } -} -- cgit v1.1 From 52d56288060caca4f92fee9549090390d7053549 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 28 Apr 2009 17:47:09 +0000 Subject: * Add preliminary code for resolving iar profile names * Not yet active --- OpenSim/Framework/Communications/OspResolver.cs | 130 ++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 OpenSim/Framework/Communications/OspResolver.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs new file mode 100644 index 0000000..708bb84 --- /dev/null +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -0,0 +1,130 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Reflection; +using System.Text; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; + +namespace OpenSim.Framework.Communications +{ + /// + /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for + /// identifying user profiles or supplying a simple name if no profile is available. + /// + public class OspResolver + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public const string OSPA_PREFIX = "ospi:"; + public const string OSPA_NAME_KEY = "n"; + public const string OSPA_NAME_VALUE_SEPARATOR = " "; + public const string OSPA_TUPLE_SEPARATOR = "|"; + public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); + public const string OSPA_KEY_VALUE_PAIR_SEPARATOR = "="; + + /// + /// Resolve an osp string into the most suitable internal OpenSim identifier. + /// + /// + /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may + /// just return the same identifier after creating a temporary profile. + /// + /// + /// + /// + /// A suitable internal OpenSim identifier. If the input string wasn't ospi data, then we simply + /// return that same string. If the input string was ospi data but no valid profile information has been found, + /// then returns null. + /// + public static string Resolve(string ospa, CommunicationsManager commsManager) + { + if (!ospa.StartsWith(OSPA_PREFIX)) + return ospa; + + string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); + string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); + + foreach (string tuple in ospaTuples) + { + int tupleSeparatorIndex = tuple.IndexOf(OSPA_TUPLE_SEPARATOR); + + if (tupleSeparatorIndex < 0) + { + m_log.WarnFormat("[OSPA RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); + continue; + } + + string key = tuple.Remove(tupleSeparatorIndex).Trim(); + string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); + + if (OSPA_NAME_KEY == key) + return ResolveOspaName(value, commsManager); + } + + return null; + } + + /// + /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile + /// then a temporary user profile is inserted in the cache. + /// + /// + /// + /// + /// An OpenSim internal identifier for the name given. Returns null if the name was not valid + /// + protected static string ResolveOspaName(string name, CommunicationsManager commsManager) + { + int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); + + if (nameSeparatorIndex < 0) + { + m_log.WarnFormat("[OSPA RESOLVER]: Ignoring unseparated name {0}", name); + return null; + } + + string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); + string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + if (userInfo != null) + return userInfo.UserProfile.ID.ToString(); + + UserProfileData tempUserProfile = new UserProfileData(); + tempUserProfile.FirstName = firstName; + tempUserProfile.SurName = lastName; + tempUserProfile.ID = new UUID(Utils.MD5(Encoding.Unicode.GetBytes(tempUserProfile.Name)), 0); + + commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); + + return tempUserProfile.ID.ToString(); + } + } +} -- cgit v1.1 From c56f928c804de01f523b23c519ada63475961f1c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Apr 2009 17:46:13 +0000 Subject: * Adjust load iar unit test to check load of items with creator names that exist in the system but which are not the loading user --- OpenSim/Framework/Communications/OspResolver.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index 708bb84..f246692 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -47,7 +47,18 @@ namespace OpenSim.Framework.Communications public const string OSPA_NAME_VALUE_SEPARATOR = " "; public const string OSPA_TUPLE_SEPARATOR = "|"; public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); - public const string OSPA_KEY_VALUE_PAIR_SEPARATOR = "="; + public const string OSPA_PAIR_SEPARATOR = "="; + + /// + /// Make an OSPA given an avatar name + /// + /// + /// + public static string MakeOspa(string firstName, string lastName) + { + return + OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; + } /// /// Resolve an osp string into the most suitable internal OpenSim identifier. @@ -73,7 +84,7 @@ namespace OpenSim.Framework.Communications foreach (string tuple in ospaTuples) { - int tupleSeparatorIndex = tuple.IndexOf(OSPA_TUPLE_SEPARATOR); + int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); if (tupleSeparatorIndex < 0) { -- cgit v1.1 From 40c2e2e84f50e9a75f26b326a798a280d36687e9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Apr 2009 19:31:48 +0000 Subject: * Add test to check temp profile creation on iar load --- OpenSim/Framework/Communications/OspResolver.cs | 12 ++++++++---- .../Framework/Communications/TemporaryUserProfilePlugin.cs | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index f246692..4627e30 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public const string OSPA_PREFIX = "ospi:"; + public const string OSPA_PREFIX = "ospa:"; public const string OSPA_NAME_KEY = "n"; public const string OSPA_NAME_VALUE_SEPARATOR = " "; public const string OSPA_TUPLE_SEPARATOR = "|"; @@ -76,6 +76,8 @@ namespace OpenSim.Framework.Communications /// public static string Resolve(string ospa, CommunicationsManager commsManager) { + m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); + if (!ospa.StartsWith(OSPA_PREFIX)) return ospa; @@ -88,7 +90,7 @@ namespace OpenSim.Framework.Communications if (tupleSeparatorIndex < 0) { - m_log.WarnFormat("[OSPA RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); + m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); continue; } @@ -117,7 +119,7 @@ namespace OpenSim.Framework.Communications if (nameSeparatorIndex < 0) { - m_log.WarnFormat("[OSPA RESOLVER]: Ignoring unseparated name {0}", name); + m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); return null; } @@ -127,12 +129,14 @@ namespace OpenSim.Framework.Communications CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (userInfo != null) return userInfo.UserProfile.ID.ToString(); - + UserProfileData tempUserProfile = new UserProfileData(); tempUserProfile.FirstName = firstName; tempUserProfile.SurName = lastName; tempUserProfile.ID = new UUID(Utils.MD5(Encoding.Unicode.GetBytes(tempUserProfile.Name)), 0); + m_log.DebugFormat( + "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); return tempUserProfile.ID.ToString(); diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index 3b78c99..7478cdd 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -27,6 +27,8 @@ using System; using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenMetaverse; using OpenSim.Data; @@ -37,6 +39,8 @@ namespace OpenSim.Framework.Communications /// public class TemporaryUserProfilePlugin : IUserDataPlugin { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Dictionary m_profiles = new Dictionary(); public string Name { get { return "TemporaryUserProfilePlugin"; } } @@ -47,6 +51,8 @@ namespace OpenSim.Framework.Communications public UserProfileData GetUserByUUID(UUID user) { + m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); + lock (m_profiles) { if (m_profiles.ContainsKey(user)) @@ -66,6 +72,8 @@ namespace OpenSim.Framework.Communications public virtual void AddTemporaryUserProfile(UserProfileData userProfile) { + m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); + lock (m_profiles) { m_profiles[userProfile.ID] = userProfile; -- cgit v1.1 From e7078520db1622b4726a1b9e9c312002a48d474b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 30 Apr 2009 19:57:07 +0000 Subject: * refactor: move iar name hashing into a method --- OpenSim/Framework/Communications/OspResolver.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index 4627e30..924a4a9 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -105,6 +105,16 @@ namespace OpenSim.Framework.Communications } /// + /// Hash a profile name into a UUID + /// + /// + /// + public static UUID HashName(string name) + { + return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); + } + + /// /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile /// then a temporary user profile is inserted in the cache. /// @@ -133,7 +143,7 @@ namespace OpenSim.Framework.Communications UserProfileData tempUserProfile = new UserProfileData(); tempUserProfile.FirstName = firstName; tempUserProfile.SurName = lastName; - tempUserProfile.ID = new UUID(Utils.MD5(Encoding.Unicode.GetBytes(tempUserProfile.Name)), 0); + tempUserProfile.ID = HashName(tempUserProfile.Name); m_log.DebugFormat( "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); -- cgit v1.1 From 070cd35f00900079ce941f8f56cd92d25b026808 Mon Sep 17 00:00:00 2001 From: diva Date: Sat, 2 May 2009 15:00:47 +0000 Subject: Added the "out" connector (aka client) for the Grid services. Not used yet. --- .../Framework/Communications/Clients/GridClient.cs | 378 +++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 OpenSim/Framework/Communications/Clients/GridClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs new file mode 100644 index 0000000..48083b7 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/GridClient.cs @@ -0,0 +1,378 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; + +using OpenMetaverse; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Communications.Clients +{ + public class GridClient + { + + public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) + { + forcefulBanLines = true; + + Hashtable GridParams = new Hashtable(); + // Login / Authentication + + GridParams["authkey"] = sendKey; + GridParams["recvkey"] = receiveKey; + GridParams["UUID"] = regionInfo.RegionID.ToString(); + GridParams["sim_ip"] = regionInfo.ExternalHostName; + GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); + GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); + GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); + GridParams["sim_name"] = regionInfo.RegionName; + GridParams["http_port"] = regionInfo.HttpPort.ToString(); + GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); + GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); + GridParams["originUUID"] = regionInfo.originRegionID.ToString(); + GridParams["server_uri"] = regionInfo.ServerURI; + GridParams["region_secret"] = regionInfo.regionSecret; + GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); + + if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) + GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); + else + GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridParams); + + // Send Request + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); + XmlRpcResponse GridResp; + + try + { + // The timeout should always be significantly larger than the timeout for the grid server to request + // the initial status of the region before confirming registration. + GridResp = GridReq.Send(gridServerURL, 90000); + } + catch (Exception e) + { + Exception e2 + = new Exception( + String.Format( + "Unable to register region with grid at {0}. Grid service not running?", + gridServerURL), + e); + + throw e2; + } + + Hashtable GridRespData = (Hashtable)GridResp.Value; + // Hashtable griddatahash = GridRespData; + + // Process Response + if (GridRespData.ContainsKey("error")) + { + string errorstring = (string)GridRespData["error"]; + + Exception e = new Exception( + String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); + + throw e; + } + else + { + // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); + if (GridRespData.ContainsKey("allow_forceful_banlines")) + { + if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") + { + forcefulBanLines = false; + } + } + + } + return true; + } + + public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg) + { + errorMsg = ""; + Hashtable GridParams = new Hashtable(); + + GridParams["UUID"] = regionInfo.RegionID.ToString(); + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridParams); + + // Send Request + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); + XmlRpcResponse GridResp = null; + + try + { + GridResp = GridReq.Send(gridServerURL, 10000); + } + catch (Exception e) + { + Exception e2 + = new Exception( + String.Format( + "Unable to deregister region with grid at {0}. Grid service not running?", + gridServerURL), + e); + + throw e2; + } + + Hashtable GridRespData = (Hashtable)GridResp.Value; + + // Hashtable griddatahash = GridRespData; + + // Process Response + if (GridRespData != null && GridRespData.ContainsKey("error")) + { + errorMsg = (string)GridRespData["error"]; + return false; + } + + return true; + } + + public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg) + { + // didn't find it so far, we have to go the long way + regionInfo = null; + errorMsg = string.Empty; + Hashtable requestData = new Hashtable(); + requestData["region_UUID"] = regionUUID.ToString(); + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse gridResp = null; + + try + { + gridResp = gridReq.Send(gridServerURL, 3000); + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + + Hashtable responseData = (Hashtable)gridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; ; + } + + regionInfo = BuildRegionInfo(responseData, String.Empty); + + return true; + } + + public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg) + { + // didn't find it so far, we have to go the long way + regionInfo = null; + errorMsg = string.Empty; + + try + { + Hashtable requestData = new Hashtable(); + requestData["region_handle"] = regionHandle.ToString(); + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; + } + + uint regX = Convert.ToUInt32((string)responseData["region_locx"]); + uint regY = Convert.ToUInt32((string)responseData["region_locy"]); + string externalHostName = (string)responseData["sim_ip"]; + uint simPort = Convert.ToUInt32(responseData["sim_port"]); + string regionName = (string)responseData["region_name"]; + UUID regionID = new UUID((string)responseData["region_UUID"]); + uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + + uint httpPort = 9000; + if (responseData.ContainsKey("http_port")) + { + httpPort = Convert.ToUInt32((string)responseData["http_port"]); + } + + // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? + + string simURI = "http://" + externalHostName + ":" + simPort; + + // string externalUri = (string) responseData["sim_uri"]; + + //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); + regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + + return true; + } + + public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg) + { + regionInfo = null; + errorMsg = string.Empty; + try + { + Hashtable requestData = new Hashtable(); + requestData["region_name_search"] = regionName; + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; + } + + regionInfo = BuildRegionInfo(responseData, ""); + + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + return true; + } + + /// + /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates + /// + /// REDUNDANT - OGS1 is to be phased out in favour of OGS2 + /// Minimum X value + /// Minimum Y value + /// Maximum X value + /// Maximum Y value + /// Hashtable of hashtables containing map data elements + public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) + { + respData = new Hashtable(); + errorMsg = string.Empty; + + Hashtable param = new Hashtable(); + param["xmin"] = minX; + param["ymin"] = minY; + param["xmax"] = maxX; + param["ymax"] = maxY; + IList parameters = new ArrayList(); + parameters.Add(param); + + try + { + XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); + XmlRpcResponse resp = req.Send(gridServerURL, 10000); + respData = (Hashtable)resp.Value; + return true; + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + } + + public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) + { + respData = null; + errorMsg = string.Empty; + try + { + XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); + XmlRpcResponse resp = request.Send(gridServerURL, 10000); + respData = (Hashtable)resp.Value; + if (respData != null && respData.Contains("faultCode")) + { + errorMsg = (string)respData["faultString"]; + return false; + } + + return true; + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + } + + public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix) + { + uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]); + uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]); + string internalIpStr = (string)responseData[prefix + "sim_ip"]; + uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); + + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port); + + RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); + regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]); + regionInfo.RemotingAddress = internalIpStr; + + if (responseData.ContainsKey(prefix + "http_port")) + { + regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]); + } + + regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]); + regionInfo.RegionName = (string)responseData[prefix + "region_name"]; + + regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]); + return regionInfo; + } + } +} -- cgit v1.1 From 509ec2637bd178c270106725297da7f6a1180096 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 15:02:14 +0000 Subject: * Refactor: Simplify InventoryFolderImpl. No functional change. --- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index a625c7e..bc8437c 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -396,7 +396,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return a copy of the list of child items in this folder + /// Return a copy of the list of child items in this folder. The items themselves are the originals. /// public List RequestListOfItems() { @@ -416,7 +416,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Return a copy of the list of child folders in this folder. + /// Return a copy of the list of child folders in this folder. The folders themselves are the originals. /// public List RequestListOfFolders() { -- cgit v1.1 From a61cbab799886e43749bc4d0803e579fec000f4c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 16:15:30 +0000 Subject: * Insert profile references for creators for items saved into iars --- OpenSim/Framework/Communications/OspResolver.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index 924a4a9..073abf8 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -50,7 +50,22 @@ namespace OpenSim.Framework.Communications public const string OSPA_PAIR_SEPARATOR = "="; /// - /// Make an OSPA given an avatar name + /// Make an OSPA given a user UUID + /// + /// + /// + /// The OSPA. Null if a user with the given UUID could not be found. + public static string MakeOspa(UUID userId, CommunicationsManager commsManager) + { + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + if (userInfo != null) + return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); + + return null; + } + + /// + /// Make an OSPA given a user name /// /// /// @@ -58,7 +73,7 @@ namespace OpenSim.Framework.Communications { return OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - } + } /// /// Resolve an osp string into the most suitable internal OpenSim identifier. @@ -74,7 +89,7 @@ namespace OpenSim.Framework.Communications /// return that same string. If the input string was ospi data but no valid profile information has been found, /// then returns null. /// - public static string Resolve(string ospa, CommunicationsManager commsManager) + public static string ResolveOspa(string ospa, CommunicationsManager commsManager) { m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); -- cgit v1.1 From ee5774208ff3f025eb1f61896d289f62c5a81726 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 17:16:01 +0000 Subject: * Enhance some internal inventory data plugin behaviour to match what was probably intended * (e.g returning combined results of plugin rather than always the first result) * This will not affect any existing functionality --- .../Framework/Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 31 +++++++++++++--------- .../Communications/TemporaryUserProfilePlugin.cs | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index e37b188..3f1e9ef 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -134,4 +134,4 @@ namespace OpenSim.Framework.Communications /// null if no root folder was found InventoryFolderBase RequestRootFolder(UUID userID); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index ff66250..0909a52 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -117,11 +117,15 @@ namespace OpenSim.Framework.Communications // See IInventoryServices public virtual InventoryFolderBase RequestRootFolder(UUID userID) { - // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin + // Retrieve the first root folder we get from the list of plugins. foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.getUserRootFolder(userID); + InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID); + if (rootFolder != null) + return rootFolder; } + + // Return nothing if no plugin was able to supply a root folder return null; } @@ -154,11 +158,13 @@ namespace OpenSim.Framework.Communications public List GetActiveGestures(UUID userId) { + List activeGestures = new List(); foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.fetchActiveGestures(userId); + activeGestures.AddRange(plugin.fetchActiveGestures(userId)); } - return new List(); + + return activeGestures; } #endregion @@ -168,21 +174,24 @@ namespace OpenSim.Framework.Communications public List RequestSubFolders(UUID parentFolderID) { List inventoryList = new List(); + foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.getInventoryFolders(parentFolderID); + inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID)); } + return inventoryList; } public List RequestFolderItems(UUID folderID) { List itemsList = new List(); + foreach (IInventoryDataPlugin plugin in m_plugins) { - itemsList = plugin.getInventoryInFolder(folderID); - return itemsList; + itemsList.AddRange(plugin.getInventoryInFolder(folderID)); } + return itemsList; } @@ -284,9 +293,7 @@ namespace OpenSim.Framework.Communications { InventoryItemBase result = plugin.queryInventoryItem(item.ID); if (result != null) - { return result; - } } return null; @@ -298,9 +305,7 @@ namespace OpenSim.Framework.Communications { InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); if (result != null) - { return result; - } } return null; @@ -353,7 +358,9 @@ namespace OpenSim.Framework.Communications { foreach (IInventoryDataPlugin plugin in m_plugins) { - return plugin.getInventoryItem(itemID); + InventoryItemBase item = plugin.getInventoryItem(itemID); + if (item != null) + return item; } return null; diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index 7478cdd..ba14790 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Communications public virtual void AddTemporaryUserProfile(UserProfileData userProfile) { - m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); + //m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); lock (m_profiles) { -- cgit v1.1 From 3a27a056073afb9f1fb285df136d2800f4f9c1a3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 17:32:20 +0000 Subject: * refactor: move OspResolver to a different namespace --- .../Framework/Communications/Osp/OspResolver.cs | 170 +++++++++++++++++++++ OpenSim/Framework/Communications/OspResolver.cs | 170 --------------------- 2 files changed, 170 insertions(+), 170 deletions(-) create mode 100644 OpenSim/Framework/Communications/Osp/OspResolver.cs delete mode 100644 OpenSim/Framework/Communications/OspResolver.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs new file mode 100644 index 0000000..a62e1c0 --- /dev/null +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -0,0 +1,170 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Reflection; +using System.Text; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; + +namespace OpenSim.Framework.Communications.Osp +{ + /// + /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for + /// identifying user profiles or supplying a simple name if no profile is available. + /// + public class OspResolver + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public const string OSPA_PREFIX = "ospa:"; + public const string OSPA_NAME_KEY = "n"; + public const string OSPA_NAME_VALUE_SEPARATOR = " "; + public const string OSPA_TUPLE_SEPARATOR = "|"; + public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); + public const string OSPA_PAIR_SEPARATOR = "="; + + /// + /// Make an OSPA given a user UUID + /// + /// + /// + /// The OSPA. Null if a user with the given UUID could not be found. + public static string MakeOspa(UUID userId, CommunicationsManager commsManager) + { + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + if (userInfo != null) + return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); + + return null; + } + + /// + /// Make an OSPA given a user name + /// + /// + /// + public static string MakeOspa(string firstName, string lastName) + { + return + OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; + } + + /// + /// Resolve an osp string into the most suitable internal OpenSim identifier. + /// + /// + /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may + /// just return the same identifier after creating a temporary profile. + /// + /// + /// + /// + /// A suitable internal OpenSim identifier. If the input string wasn't ospi data, then we simply + /// return that same string. If the input string was ospi data but no valid profile information has been found, + /// then returns null. + /// + public static string ResolveOspa(string ospa, CommunicationsManager commsManager) + { + m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); + + if (!ospa.StartsWith(OSPA_PREFIX)) + return ospa; + + string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); + string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); + + foreach (string tuple in ospaTuples) + { + int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); + + if (tupleSeparatorIndex < 0) + { + m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); + continue; + } + + string key = tuple.Remove(tupleSeparatorIndex).Trim(); + string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); + + if (OSPA_NAME_KEY == key) + return ResolveOspaName(value, commsManager); + } + + return null; + } + + /// + /// Hash a profile name into a UUID + /// + /// + /// + public static UUID HashName(string name) + { + return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); + } + + /// + /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile + /// then a temporary user profile is inserted in the cache. + /// + /// + /// + /// + /// An OpenSim internal identifier for the name given. Returns null if the name was not valid + /// + protected static string ResolveOspaName(string name, CommunicationsManager commsManager) + { + int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); + + if (nameSeparatorIndex < 0) + { + m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); + return null; + } + + string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); + string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + if (userInfo != null) + return userInfo.UserProfile.ID.ToString(); + + UserProfileData tempUserProfile = new UserProfileData(); + tempUserProfile.FirstName = firstName; + tempUserProfile.SurName = lastName; + tempUserProfile.ID = HashName(tempUserProfile.Name); + + m_log.DebugFormat( + "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); + commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); + + return tempUserProfile.ID.ToString(); + } + } +} diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs deleted file mode 100644 index 073abf8..0000000 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Reflection; -using System.Text; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; - -namespace OpenSim.Framework.Communications -{ - /// - /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for - /// identifying user profiles or supplying a simple name if no profile is available. - /// - public class OspResolver - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public const string OSPA_PREFIX = "ospa:"; - public const string OSPA_NAME_KEY = "n"; - public const string OSPA_NAME_VALUE_SEPARATOR = " "; - public const string OSPA_TUPLE_SEPARATOR = "|"; - public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); - public const string OSPA_PAIR_SEPARATOR = "="; - - /// - /// Make an OSPA given a user UUID - /// - /// - /// - /// The OSPA. Null if a user with the given UUID could not be found. - public static string MakeOspa(UUID userId, CommunicationsManager commsManager) - { - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); - if (userInfo != null) - return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); - - return null; - } - - /// - /// Make an OSPA given a user name - /// - /// - /// - public static string MakeOspa(string firstName, string lastName) - { - return - OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - } - - /// - /// Resolve an osp string into the most suitable internal OpenSim identifier. - /// - /// - /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may - /// just return the same identifier after creating a temporary profile. - /// - /// - /// - /// - /// A suitable internal OpenSim identifier. If the input string wasn't ospi data, then we simply - /// return that same string. If the input string was ospi data but no valid profile information has been found, - /// then returns null. - /// - public static string ResolveOspa(string ospa, CommunicationsManager commsManager) - { - m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); - - if (!ospa.StartsWith(OSPA_PREFIX)) - return ospa; - - string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); - string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); - - foreach (string tuple in ospaTuples) - { - int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); - - if (tupleSeparatorIndex < 0) - { - m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); - continue; - } - - string key = tuple.Remove(tupleSeparatorIndex).Trim(); - string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); - - if (OSPA_NAME_KEY == key) - return ResolveOspaName(value, commsManager); - } - - return null; - } - - /// - /// Hash a profile name into a UUID - /// - /// - /// - public static UUID HashName(string name) - { - return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); - } - - /// - /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile - /// then a temporary user profile is inserted in the cache. - /// - /// - /// - /// - /// An OpenSim internal identifier for the name given. Returns null if the name was not valid - /// - protected static string ResolveOspaName(string name, CommunicationsManager commsManager) - { - int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); - - if (nameSeparatorIndex < 0) - { - m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); - return null; - } - - string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); - string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - if (userInfo != null) - return userInfo.UserProfile.ID.ToString(); - - UserProfileData tempUserProfile = new UserProfileData(); - tempUserProfile.FirstName = firstName; - tempUserProfile.SurName = lastName; - tempUserProfile.ID = HashName(tempUserProfile.Name); - - m_log.DebugFormat( - "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); - commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); - - return tempUserProfile.ID.ToString(); - } - } -} -- cgit v1.1 From 780f57d5514ec27014171bc4b920db9accf2639a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 18:32:01 +0000 Subject: * Initial infrastructure for ospa only uuid hashing of retrieved inventory items --- .../Communications/InventoryServiceBase.cs | 2 +- .../Osp/OspInventoryWrapperPlugin.cs | 95 ++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 0909a52..010429d 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -67,7 +67,7 @@ namespace OpenSim.Framework.Communications public void AddPlugin(string provider, string connect) { m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); - } + } #endregion diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs new file mode 100644 index 0000000..3a692ae --- /dev/null +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using OpenSim.Data; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications.Osp +{ + /// + /// Wrap other inventory data plugins so that we can perform OSP related post processing for items + /// + public class OspInventoryWrapperPlugin : IInventoryDataPlugin + { + protected IInventoryDataPlugin m_wrappedPlugin; + + public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin) + { + m_wrappedPlugin = wrappedPlugin; + } + + public string Name { get { return "OspInventoryWrapperPlugin"; } } + public string Version { get { return "0.1"; } } + public void Initialise() {} + public void Initialise(string connect) {} + public void Dispose() {} + + public InventoryItemBase getInventoryItem(UUID item) + { + return m_wrappedPlugin.getInventoryItem(item); + + // TODO: Need to post process here + } + + // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem? + public InventoryItemBase queryInventoryItem(UUID item) + { + return m_wrappedPlugin.queryInventoryItem(item); + + // TODO: Need to post process here + } + + public List getInventoryInFolder(UUID folderID) + { + return m_wrappedPlugin.getInventoryInFolder(folderID); + + // TODO: Need to post process here + } + + public List fetchActiveGestures(UUID avatarID) + { + return m_wrappedPlugin.fetchActiveGestures(avatarID); + + // Presuming that no post processing is needed here as gestures don't refer to creator information (?) + } + + public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); } + public List getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); } + public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); } + public List getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); } + public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); } + public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); } + public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); } + public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); } + public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); } + public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); } + public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); } + public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); } + public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); } + } +} -- cgit v1.1 From b3178c8079a4f8c0fe57af2fc9040d0667298ef0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 19:15:44 +0000 Subject: * Resolve http://opensimulator.org/mantis/view.php?id=3573 * Override add user for HG user services to hit local services if present --- OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs | 4 ++-- OpenSim/Framework/Communications/UserManagerBase.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index ba14790..2e355cd 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications /// public class TemporaryUserProfilePlugin : IUserDataPlugin { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Dictionary m_profiles = new Dictionary(); @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Communications public UserProfileData GetUserByUUID(UUID user) { - m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); + //m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); lock (m_profiles) { diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 133f810..50f57e1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -623,7 +623,7 @@ namespace OpenSim.Framework.Communications /// location X /// location Y /// The UUID of the created user profile. On failure, returns UUID.Zero - public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) + public virtual UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) { return AddUser(firstName, lastName, password, email, regX, regY, UUID.Random()); } @@ -639,7 +639,7 @@ namespace OpenSim.Framework.Communications /// location Y /// UUID of avatar. /// The UUID of the created user profile. On failure, returns UUID.Zero - public UUID AddUser( + public virtual UUID AddUser( string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) { string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); -- cgit v1.1 From acfb5051cd328ab21aba5bfc2878ce84d496a7f1 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 4 May 2009 20:15:39 +0000 Subject: Intermediate commit. WILL NOT COMPILE! --- OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs | 4 ++-- OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs | 1 + OpenSim/Framework/Communications/Clients/InventoryClient.cs | 1 + OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- OpenSim/Framework/Communications/Services/GridInfoService.cs | 2 +- OpenSim/Framework/Communications/Services/HGInventoryService.cs | 2 +- 9 files changed, 10 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 6e4dd1c..1e2e286 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -38,7 +38,7 @@ using System.Security.Cryptography; using System.Text; using System.Xml.Serialization; using log4net; -using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index c7d4c99..aec039f 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -30,7 +30,7 @@ using System.IO; using System.Reflection; using System.Xml.Serialization; using log4net; -using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications.Cache { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a2e8042..73aa819 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -33,7 +33,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.Interfaces; +using OpenSim.Framework.Servers.HttpServer; // using OpenSim.Region.Framework.Interfaces; diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index b47d014..55778d7 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -28,7 +28,7 @@ using System.Collections; using System.Collections.Generic; using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.Interfaces; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications.Capabilities { @@ -168,4 +168,4 @@ namespace OpenSim.Framework.Communications.Capabilities } } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 906f5d5..4f49fb4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -29,6 +29,7 @@ using System.Collections; using System.IO; using System.Text; using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications.Capabilities { diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs index 8fe4268..e4f5e2a 100644 --- a/OpenSim/Framework/Communications/Clients/InventoryClient.cs +++ b/OpenSim/Framework/Communications/Clients/InventoryClient.cs @@ -28,6 +28,7 @@ using System; using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 1df1f48..b49e7bc 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -29,7 +29,7 @@ using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers.Interfaces; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications { diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index e53400c..f17bb9f 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -33,7 +33,7 @@ using System.Text; using log4net; using Nini.Config; using Nwc.XmlRpc; -using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications.Services { diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index a3234bf..77a6177 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Communications.Cache; using Caps = OpenSim.Framework.Communications.Capabilities.Caps; using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.Interfaces; +using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse.StructuredData; -- cgit v1.1 From c45add5f31405edb3ab22df37879e2b3f14a20b9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 4 May 2009 22:37:38 +0000 Subject: * Attempting to find cause of NotSupportedException in Asset subsystem. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 24cb598..c732d21 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -169,7 +169,7 @@ namespace OpenSim.Framework.Communications.Cache } catch (Exception e) { - m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1}", req.AssetID, e); + m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1} - Stack Trace: {2}", req.AssetID, e, e.StackTrace); if (StatsManager.SimExtraStats != null) StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); -- cgit v1.1 From 6ae88d129a2d85f57202e854f118dff047e65cf1 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 5 May 2009 09:32:30 +0000 Subject: Update svn properties. --- .../Framework/Communications/Clients/GridClient.cs | 756 ++++++++++----------- 1 file changed, 378 insertions(+), 378 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs index 48083b7..28c3e00 100644 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ b/OpenSim/Framework/Communications/Clients/GridClient.cs @@ -1,378 +1,378 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Net; - -using OpenMetaverse; -using Nwc.XmlRpc; - -namespace OpenSim.Framework.Communications.Clients -{ - public class GridClient - { - - public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) - { - forcefulBanLines = true; - - Hashtable GridParams = new Hashtable(); - // Login / Authentication - - GridParams["authkey"] = sendKey; - GridParams["recvkey"] = receiveKey; - GridParams["UUID"] = regionInfo.RegionID.ToString(); - GridParams["sim_ip"] = regionInfo.ExternalHostName; - GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); - GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); - GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); - GridParams["sim_name"] = regionInfo.RegionName; - GridParams["http_port"] = regionInfo.HttpPort.ToString(); - GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); - GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); - GridParams["originUUID"] = regionInfo.originRegionID.ToString(); - GridParams["server_uri"] = regionInfo.ServerURI; - GridParams["region_secret"] = regionInfo.regionSecret; - GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); - - if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) - GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); - else - GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); - XmlRpcResponse GridResp; - - try - { - // The timeout should always be significantly larger than the timeout for the grid server to request - // the initial status of the region before confirming registration. - GridResp = GridReq.Send(gridServerURL, 90000); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to register region with grid at {0}. Grid service not running?", - gridServerURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable)GridResp.Value; - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData.ContainsKey("error")) - { - string errorstring = (string)GridRespData["error"]; - - Exception e = new Exception( - String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); - - throw e; - } - else - { - // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); - if (GridRespData.ContainsKey("allow_forceful_banlines")) - { - if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") - { - forcefulBanLines = false; - } - } - - } - return true; - } - - public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg) - { - errorMsg = ""; - Hashtable GridParams = new Hashtable(); - - GridParams["UUID"] = regionInfo.RegionID.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); - XmlRpcResponse GridResp = null; - - try - { - GridResp = GridReq.Send(gridServerURL, 10000); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to deregister region with grid at {0}. Grid service not running?", - gridServerURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable)GridResp.Value; - - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData != null && GridRespData.ContainsKey("error")) - { - errorMsg = (string)GridRespData["error"]; - return false; - } - - return true; - } - - public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg) - { - // didn't find it so far, we have to go the long way - regionInfo = null; - errorMsg = string.Empty; - Hashtable requestData = new Hashtable(); - requestData["region_UUID"] = regionUUID.ToString(); - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse gridResp = null; - - try - { - gridResp = gridReq.Send(gridServerURL, 3000); - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - - Hashtable responseData = (Hashtable)gridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; ; - } - - regionInfo = BuildRegionInfo(responseData, String.Empty); - - return true; - } - - public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg) - { - // didn't find it so far, we have to go the long way - regionInfo = null; - errorMsg = string.Empty; - - try - { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; - } - - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string externalHostName = (string)responseData["sim_ip"]; - uint simPort = Convert.ToUInt32(responseData["sim_port"]); - string regionName = (string)responseData["region_name"]; - UUID regionID = new UUID((string)responseData["region_UUID"]); - uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - - uint httpPort = 9000; - if (responseData.ContainsKey("http_port")) - { - httpPort = Convert.ToUInt32((string)responseData["http_port"]); - } - - // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? - - string simURI = "http://" + externalHostName + ":" + simPort; - - // string externalUri = (string) responseData["sim_uri"]; - - //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); - regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - - return true; - } - - public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg) - { - regionInfo = null; - errorMsg = string.Empty; - try - { - Hashtable requestData = new Hashtable(); - requestData["region_name_search"] = regionName; - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; - } - - regionInfo = BuildRegionInfo(responseData, ""); - - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - return true; - } - - /// - /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates - /// - /// REDUNDANT - OGS1 is to be phased out in favour of OGS2 - /// Minimum X value - /// Minimum Y value - /// Maximum X value - /// Maximum Y value - /// Hashtable of hashtables containing map data elements - public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) - { - respData = new Hashtable(); - errorMsg = string.Empty; - - Hashtable param = new Hashtable(); - param["xmin"] = minX; - param["ymin"] = minY; - param["xmax"] = maxX; - param["ymax"] = maxY; - IList parameters = new ArrayList(); - parameters.Add(param); - - try - { - XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); - XmlRpcResponse resp = req.Send(gridServerURL, 10000); - respData = (Hashtable)resp.Value; - return true; - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - } - - public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) - { - respData = null; - errorMsg = string.Empty; - try - { - XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); - XmlRpcResponse resp = request.Send(gridServerURL, 10000); - respData = (Hashtable)resp.Value; - if (respData != null && respData.Contains("faultCode")) - { - errorMsg = (string)respData["faultString"]; - return false; - } - - return true; - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - } - - public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix) - { - uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]); - uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]); - string internalIpStr = (string)responseData[prefix + "sim_ip"]; - uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); - - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port); - - RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]); - regionInfo.RemotingAddress = internalIpStr; - - if (responseData.ContainsKey(prefix + "http_port")) - { - regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]); - } - - regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]); - regionInfo.RegionName = (string)responseData[prefix + "region_name"]; - - regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]); - return regionInfo; - } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; + +using OpenMetaverse; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Communications.Clients +{ + public class GridClient + { + + public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) + { + forcefulBanLines = true; + + Hashtable GridParams = new Hashtable(); + // Login / Authentication + + GridParams["authkey"] = sendKey; + GridParams["recvkey"] = receiveKey; + GridParams["UUID"] = regionInfo.RegionID.ToString(); + GridParams["sim_ip"] = regionInfo.ExternalHostName; + GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); + GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); + GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); + GridParams["sim_name"] = regionInfo.RegionName; + GridParams["http_port"] = regionInfo.HttpPort.ToString(); + GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); + GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); + GridParams["originUUID"] = regionInfo.originRegionID.ToString(); + GridParams["server_uri"] = regionInfo.ServerURI; + GridParams["region_secret"] = regionInfo.regionSecret; + GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); + + if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) + GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); + else + GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridParams); + + // Send Request + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); + XmlRpcResponse GridResp; + + try + { + // The timeout should always be significantly larger than the timeout for the grid server to request + // the initial status of the region before confirming registration. + GridResp = GridReq.Send(gridServerURL, 90000); + } + catch (Exception e) + { + Exception e2 + = new Exception( + String.Format( + "Unable to register region with grid at {0}. Grid service not running?", + gridServerURL), + e); + + throw e2; + } + + Hashtable GridRespData = (Hashtable)GridResp.Value; + // Hashtable griddatahash = GridRespData; + + // Process Response + if (GridRespData.ContainsKey("error")) + { + string errorstring = (string)GridRespData["error"]; + + Exception e = new Exception( + String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); + + throw e; + } + else + { + // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); + if (GridRespData.ContainsKey("allow_forceful_banlines")) + { + if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") + { + forcefulBanLines = false; + } + } + + } + return true; + } + + public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg) + { + errorMsg = ""; + Hashtable GridParams = new Hashtable(); + + GridParams["UUID"] = regionInfo.RegionID.ToString(); + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridParams); + + // Send Request + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); + XmlRpcResponse GridResp = null; + + try + { + GridResp = GridReq.Send(gridServerURL, 10000); + } + catch (Exception e) + { + Exception e2 + = new Exception( + String.Format( + "Unable to deregister region with grid at {0}. Grid service not running?", + gridServerURL), + e); + + throw e2; + } + + Hashtable GridRespData = (Hashtable)GridResp.Value; + + // Hashtable griddatahash = GridRespData; + + // Process Response + if (GridRespData != null && GridRespData.ContainsKey("error")) + { + errorMsg = (string)GridRespData["error"]; + return false; + } + + return true; + } + + public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg) + { + // didn't find it so far, we have to go the long way + regionInfo = null; + errorMsg = string.Empty; + Hashtable requestData = new Hashtable(); + requestData["region_UUID"] = regionUUID.ToString(); + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse gridResp = null; + + try + { + gridResp = gridReq.Send(gridServerURL, 3000); + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + + Hashtable responseData = (Hashtable)gridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; ; + } + + regionInfo = BuildRegionInfo(responseData, String.Empty); + + return true; + } + + public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg) + { + // didn't find it so far, we have to go the long way + regionInfo = null; + errorMsg = string.Empty; + + try + { + Hashtable requestData = new Hashtable(); + requestData["region_handle"] = regionHandle.ToString(); + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; + } + + uint regX = Convert.ToUInt32((string)responseData["region_locx"]); + uint regY = Convert.ToUInt32((string)responseData["region_locy"]); + string externalHostName = (string)responseData["sim_ip"]; + uint simPort = Convert.ToUInt32(responseData["sim_port"]); + string regionName = (string)responseData["region_name"]; + UUID regionID = new UUID((string)responseData["region_UUID"]); + uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + + uint httpPort = 9000; + if (responseData.ContainsKey("http_port")) + { + httpPort = Convert.ToUInt32((string)responseData["http_port"]); + } + + // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? + + string simURI = "http://" + externalHostName + ":" + simPort; + + // string externalUri = (string) responseData["sim_uri"]; + + //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); + regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + + return true; + } + + public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg) + { + regionInfo = null; + errorMsg = string.Empty; + try + { + Hashtable requestData = new Hashtable(); + requestData["region_name_search"] = regionName; + requestData["authkey"] = sendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + errorMsg = (string)responseData["error"]; + return false; + } + + regionInfo = BuildRegionInfo(responseData, ""); + + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + return true; + } + + /// + /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates + /// + /// REDUNDANT - OGS1 is to be phased out in favour of OGS2 + /// Minimum X value + /// Minimum Y value + /// Maximum X value + /// Maximum Y value + /// Hashtable of hashtables containing map data elements + public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) + { + respData = new Hashtable(); + errorMsg = string.Empty; + + Hashtable param = new Hashtable(); + param["xmin"] = minX; + param["ymin"] = minY; + param["xmax"] = maxX; + param["ymax"] = maxY; + IList parameters = new ArrayList(); + parameters.Add(param); + + try + { + XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); + XmlRpcResponse resp = req.Send(gridServerURL, 10000); + respData = (Hashtable)resp.Value; + return true; + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + } + + public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) + { + respData = null; + errorMsg = string.Empty; + try + { + XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); + XmlRpcResponse resp = request.Send(gridServerURL, 10000); + respData = (Hashtable)resp.Value; + if (respData != null && respData.Contains("faultCode")) + { + errorMsg = (string)respData["faultString"]; + return false; + } + + return true; + } + catch (Exception e) + { + errorMsg = e.Message; + return false; + } + } + + public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix) + { + uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]); + uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]); + string internalIpStr = (string)responseData[prefix + "sim_ip"]; + uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); + + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port); + + RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); + regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]); + regionInfo.RemotingAddress = internalIpStr; + + if (responseData.ContainsKey(prefix + "http_port")) + { + regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]); + } + + regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]); + regionInfo.RegionName = (string)responseData[prefix + "region_name"]; + + regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]); + return regionInfo; + } + } +} -- cgit v1.1 From e0a06f641668cd5c25a7854af2faf8a61c4053ee Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 5 May 2009 16:17:52 +0000 Subject: - moving banned check and public/private check to Scene.NewUserConnection() - adding reason reporting this enforces estate bans very early on and prevents us from circulating client objects that we'd then have to retract once we realize that the client is not allowed into the region --- .../Communications/Clients/RegionClient.cs | 29 ++++++++++++++++------ .../Communications/Services/LoginResponse.cs | 2 +- .../Communications/Services/LoginService.cs | 6 +++-- .../Communications/Tests/LoginServiceTests.cs | 4 ++- 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index da3f620..6fdacb1 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -43,7 +43,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey) + public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) { // Eventually, we want to use a caps url instead of the agentID string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; @@ -56,6 +56,8 @@ namespace OpenSim.Framework.Communications.Clients //AgentCreateRequest.KeepAlive = false; AgentCreateRequest.Headers.Add("Authorization", authKey); + reason = String.Empty; + // Fill it in OSDMap args = null; try @@ -98,7 +100,7 @@ namespace OpenSim.Framework.Communications.Clients catch { //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - + reason = "cannot contact remote region"; return false; } @@ -112,13 +114,24 @@ namespace OpenSim.Framework.Communications.Clients { m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); } + else + { - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - + StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + string response = sr.ReadToEnd().Trim(); + sr.Close(); + m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); + + if (!String.IsNullOrEmpty(response)) + { + // we assume we got an OSDMap back + OSDMap r = GetOSDMap(response); + bool success = r["success"].AsBoolean(); + reason = r["reason"].AsString(); + + return success; + } + } } catch (WebException ex) { diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index d91bf84..4b5c99d 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications.Services { return GenerateFailureResponseLLSD( "key", - "Error connecting to grid. Could not percieve credentials from login XML.", + "Error connecting to grid. Could not perceive credentials from login XML.", "false"); } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 168f7a6..f55c030 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -946,13 +946,15 @@ namespace OpenSim.Framework.Communications.Services { regionInfo = homeInfo; theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; + response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(), + theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString()); } else if (startLocationRequest == "last") { UUID lastRegion = theUser.CurrentAgent.Region; regionInfo = GetRegionInfo(lastRegion); - response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; + response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(), + theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString()); } else { diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d0c1b3b..965e6b4 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -345,8 +345,9 @@ namespace OpenSim.Framework.Communications.Tests { } - public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) + public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) { + reason = String.Empty; lock (m_regionsList) { foreach (RegionInfo regInfo in m_regionsList) @@ -355,6 +356,7 @@ namespace OpenSim.Framework.Communications.Tests return true; } } + reason = "Region not found"; return false; } -- cgit v1.1 From f8e0653e73932bae20f483e0ce669f1623c6ff1e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 5 May 2009 16:45:21 +0000 Subject: * If an item creator id contains an iar loaded name, create a temporary profile and hashed UUID to represent the user --- .../Osp/OspInventoryWrapperPlugin.cs | 25 ++++++++++++++-------- .../Framework/Communications/Osp/OspResolver.cs | 19 ++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index 3a692ae..95ef484 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -37,10 +37,12 @@ namespace OpenSim.Framework.Communications.Osp public class OspInventoryWrapperPlugin : IInventoryDataPlugin { protected IInventoryDataPlugin m_wrappedPlugin; + protected CommunicationsManager m_commsManager; - public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin) + public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, CommunicationsManager commsManager) { m_wrappedPlugin = wrappedPlugin; + m_commsManager = commsManager; } public string Name { get { return "OspInventoryWrapperPlugin"; } } @@ -51,24 +53,23 @@ namespace OpenSim.Framework.Communications.Osp public InventoryItemBase getInventoryItem(UUID item) { - return m_wrappedPlugin.getInventoryItem(item); - - // TODO: Need to post process here + return PostProcessItem(m_wrappedPlugin.getInventoryItem(item)); } // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem? public InventoryItemBase queryInventoryItem(UUID item) { - return m_wrappedPlugin.queryInventoryItem(item); - - // TODO: Need to post process here + return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item)); } public List getInventoryInFolder(UUID folderID) { - return m_wrappedPlugin.getInventoryInFolder(folderID); + List items = m_wrappedPlugin.getInventoryInFolder(folderID); - // TODO: Need to post process here + foreach (InventoryItemBase item in items) + PostProcessItem(item); + + return items; } public List fetchActiveGestures(UUID avatarID) @@ -77,6 +78,12 @@ namespace OpenSim.Framework.Communications.Osp // Presuming that no post processing is needed here as gestures don't refer to creator information (?) } + + protected InventoryItemBase PostProcessItem(InventoryItemBase item) + { + item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + return item; + } public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); } public List getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); } diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index a62e1c0..579b3df 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -85,16 +85,15 @@ namespace OpenSim.Framework.Communications.Osp /// /// /// - /// A suitable internal OpenSim identifier. If the input string wasn't ospi data, then we simply - /// return that same string. If the input string was ospi data but no valid profile information has been found, - /// then returns null. + /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero + /// is returned. /// - public static string ResolveOspa(string ospa, CommunicationsManager commsManager) + public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) { m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); if (!ospa.StartsWith(OSPA_PREFIX)) - return ospa; + return UUID.Zero; string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); @@ -116,7 +115,7 @@ namespace OpenSim.Framework.Communications.Osp return ResolveOspaName(value, commsManager); } - return null; + return UUID.Zero; } /// @@ -138,14 +137,14 @@ namespace OpenSim.Framework.Communications.Osp /// /// An OpenSim internal identifier for the name given. Returns null if the name was not valid /// - protected static string ResolveOspaName(string name, CommunicationsManager commsManager) + protected static UUID ResolveOspaName(string name, CommunicationsManager commsManager) { int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); if (nameSeparatorIndex < 0) { m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); - return null; + return UUID.Zero; } string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); @@ -153,7 +152,7 @@ namespace OpenSim.Framework.Communications.Osp CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (userInfo != null) - return userInfo.UserProfile.ID.ToString(); + return userInfo.UserProfile.ID; UserProfileData tempUserProfile = new UserProfileData(); tempUserProfile.FirstName = firstName; @@ -164,7 +163,7 @@ namespace OpenSim.Framework.Communications.Osp "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); - return tempUserProfile.ID.ToString(); + return tempUserProfile.ID; } } } -- cgit v1.1 From 48c2e7796f9bdfdfdcd71c33ac209a3ca7847642 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 7 May 2009 14:23:26 +0000 Subject: * minor: Quieten down temporary profile resolver to only log when it's actually dealing with a temporary profile --- OpenSim/Framework/Communications/Osp/OspResolver.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 579b3df..55978b2 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -89,11 +89,11 @@ namespace OpenSim.Framework.Communications.Osp /// is returned. /// public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) - { - m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); - + { if (!ospa.StartsWith(OSPA_PREFIX)) return UUID.Zero; + + m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); -- cgit v1.1 From ce0a84cbc0e277dd5be08a20febf13364a985a3a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 7 May 2009 19:07:08 +0000 Subject: instrument most of the tests with a new InMethod function that may help us figure out where that pesky deadlock is during test runs. --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 14 ++++++++++++++ .../Framework/Communications/Tests/LoginServiceTests.cs | 12 ++++++++++++ 2 files changed, 26 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 2972a0a..75848b7 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -34,6 +34,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Setup; +using OpenSim.Tests.Common; namespace OpenSim.Framework.Communications.Tests { @@ -43,6 +44,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetUserDetails() { + TestHelper.InMethod(); + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); string firstName = "Bill"; string lastName = "Bailey"; @@ -109,6 +112,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestFetchInventory() { + TestHelper.InMethod(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); @@ -118,6 +123,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetChildFolder() { + TestHelper.InMethod(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); @@ -132,6 +139,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestCreateFolder() { + TestHelper.InMethod(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; @@ -159,6 +168,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestUpdateFolder() { + TestHelper.InMethod(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; @@ -213,6 +224,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestMoveFolder() { + TestHelper.InMethod(); + TestCommunicationsManager commsManager = new TestCommunicationsManager(); IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; @@ -244,6 +257,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestPurgeFolder() { + TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); TestCommunicationsManager commsManager = new TestCommunicationsManager(); diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 965e6b4..7d75faa 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Communications.Services; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; using OpenSim.Client.Linden; +using OpenSim.Tests.Common; namespace OpenSim.Framework.Communications.Tests { @@ -45,6 +46,7 @@ namespace OpenSim.Framework.Communications.Tests /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService /// is abstract /// + [TestFixture] public class LoginServiceTests { @@ -83,6 +85,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T010_TestUnauthenticatedLogin() { + TestHelper.InMethod(); // We want to use our own LoginService for this test, one that // doesn't require authentication. LoginService loginService = new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", m_commsManager.InterServiceInventoryService, @@ -119,6 +122,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T011_TestAuthenticatedLoginSuccess() { + TestHelper.InMethod(); // TODO: Not check inventory part of response yet. // TODO: Not checking all of login response thoroughly yet. @@ -168,6 +172,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T012_TestAuthenticatedLoginForBuddies() { + TestHelper.InMethod(); // 1.1) Test for budddies! m_localUserServices.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); m_localUserServices.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); @@ -207,6 +212,7 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T020_TestAuthenticatedLoginBadUsername() { + TestHelper.InMethod(); // 2) Test for negative authentication // @@ -234,6 +240,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T021_TestAuthenticatedLoginBadPassword() { + TestHelper.InMethod(); + string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; // 2.2) Test for wrong password Hashtable loginParams = new Hashtable(); @@ -257,6 +265,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T022_TestAuthenticatedLoginBadXml() { + TestHelper.InMethod(); + string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; // 2.3) Bad XML Hashtable loginParams = new Hashtable(); @@ -280,6 +290,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { + TestHelper.InMethod(); + //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); //log4net.Config.XmlConfigurator.Configure(); -- cgit v1.1 From b333690969a600bd2d3e298bee98ea38c5dd66e9 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 8 May 2009 18:09:41 +0000 Subject: added WebFetchInventoryDescendents CAP From: Robert Smart --- .../Framework/Communications/Capabilities/Caps.cs | 86 ++++++++++++++++++++-- .../Capabilities/LLSDInventoryItem.cs | 6 +- 2 files changed, 84 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 73aa819..858ff1d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Capabilities //private static readonly string m_requestTexture = "0003/"; private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; - // private static readonly string m_fetchInventoryPath = "0006/"; + private static readonly string m_fetchInventoryPath = "0006/"; // The following entries are in a module, however, they are also here so that we don't re-assign // the path to another cap by mistake. @@ -202,6 +202,10 @@ namespace OpenSim.Framework.Communications.Capabilities new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; + + // rob smart + // adding handling for WebFetchInventoryDescendents which appears in RC 1.22.9 + m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires @@ -360,6 +364,76 @@ namespace OpenSim.Framework.Communications.Capabilities return response; } + public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request); + + // nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us + // correctly mark it as a uuid + request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + + // another hack 1 results in a System.ArgumentException: Object type System.Int32 cannot be converted to target type: System.Boolean + request = request.Replace("fetch_folders0", "fetch_folders0"); + request = request.Replace("fetch_folders1", "fetch_folders1"); + Hashtable hash = new Hashtable(); + try + { + hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); + } + catch (LLSD.LLSDParseException pe) + { + m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); + m_log.Error("Request: " + request.ToString()); + } + + ArrayList foldersrequested = (ArrayList)hash["folders"]; + + string response = ""; + for (int i = 0; i < foldersrequested.Count; i++) + { + string inventoryitemstr = ""; + Hashtable inventoryhash = (Hashtable)foldersrequested[i]; + + LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); + + try{ + LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); + } + catch(Exception e) + { + m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); + } + LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); + + inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); + inventoryitemstr = inventoryitemstr.Replace("folders", ""); + inventoryitemstr = inventoryitemstr.Replace("", ""); + + response += inventoryitemstr; + } + + + if (response.Length == 0) + { + // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. + // Therefore, I'm concluding that the client only has so many threads available to do requests + // and when a thread stalls.. is stays stalled. + // Therefore we need to return something valid + response = "folders"; + } + else + { + response = "folders" + response + ""; + } + + m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); + m_log.Debug("[CAPS] "+response); + + return response; + } + + + /// /// Construct an LLSD reply packet to a CAPS inventory request /// @@ -369,9 +443,9 @@ namespace OpenSim.Framework.Communications.Capabilities { LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); - contents.agent___id = m_agentID; - contents.owner___id = invFetch.owner_id; - contents.folder___id = invFetch.folder_id; + contents.agent_id = m_agentID; + contents.owner_id = invFetch.owner_id; + contents.folder_id = invFetch.folder_id; // The version number being sent back was originally 1. // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins @@ -397,6 +471,8 @@ namespace OpenSim.Framework.Communications.Capabilities contents.items.Array.Add(ConvertInventoryItem(invItem)); } } + /* Rob Smart The following block i removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to + find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000.... else { IClientAPI client = GetClient(m_agentID); @@ -416,7 +492,7 @@ namespace OpenSim.Framework.Communications.Capabilities "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", m_agentID); } - } + }*/ contents.descendents = contents.items.Array.Count; return reply; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 3651513..7cc1e38 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -87,11 +87,11 @@ namespace OpenSim.Framework.Communications.Capabilities [OSDMap] public class LLSDInventoryFolderContents { - public UUID agent___id; // the (three "_") "___" so the serialising knows to change this to a "-" + public UUID agent_id; public int descendents; - public UUID folder___id; //as LL can't decide if they are going to use "_" or "-" to separate words in the field names + public UUID folder_id; public OSDArray items = new OSDArray(); - public UUID owner___id; // and of course we can't have field names with "-" in + public UUID owner_id; public int version; } } -- cgit v1.1 From c1a54c02d35863f931c901d7a5421fa9f1095fdd Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 8 May 2009 18:09:48 +0000 Subject: fix up the comments a little From: Sean Dague --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 858ff1d..5809455 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -203,8 +203,7 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; - // rob smart - // adding handling for WebFetchInventoryDescendents which appears in RC 1.22.9 + // As of RC 1.22.9 of the Linden client this is supported m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and @@ -471,7 +470,7 @@ namespace OpenSim.Framework.Communications.Capabilities contents.items.Array.Add(ConvertInventoryItem(invItem)); } } - /* Rob Smart The following block i removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to + /* The following block is removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000.... else { -- cgit v1.1 From 1d234ca83f64b31b559ace3f63ebbba9f4903778 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 9 May 2009 21:11:12 +0000 Subject: Fixed handling of inventory a bit - AssetType isn't InventoryType. Those enums contain different numbers. Use AssetType for the asset type, InventoryType for the inventory type. - The ToString method (or ToLower) of AssetType/InventoryType doesn't necessarily return the correct LLSD string. - Replaced several magic numbers by their corresponding enum. - Fixed the invType for gestures and animations in the library. This should fix Mantis #3610 and the non-terminating inventory loading --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 5809455..6e005b7 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications.Capabilities public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request); + m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + " request is "+request); // nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us // correctly mark it as a uuid @@ -512,8 +512,16 @@ namespace OpenSim.Framework.Communications.Capabilities llsdItem.item_id = invItem.ID; llsdItem.name = invItem.Name; llsdItem.parent_id = invItem.Folder; - llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower(); - llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower(); + try + { + // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. + llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; + llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType]; + } + catch (Exception e) + { + m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e); + } llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; -- cgit v1.1 From 13b2ff83df33fda14d9a8352ed19386913f3c60f Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 10 May 2009 00:30:51 +0000 Subject: Small asset cache addition. Comment a debug output left in CAPS --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6e005b7..d0c1925 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications.Capabilities public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse) { - m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + " request is "+request); + // m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request); // nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us // correctly mark it as a uuid @@ -425,8 +425,8 @@ namespace OpenSim.Framework.Communications.Capabilities response = "folders" + response + ""; } - m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); - m_log.Debug("[CAPS] "+response); + //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); + //m_log.Debug("[CAPS] "+response); return response; } -- cgit v1.1 From 2d4166fecf556acf8866759b263636ca979b14e8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 10 May 2009 20:50:38 +0000 Subject: * Debugging some inventory related NullRefException's. --- .../Communications/Capabilities/LLSDHelpers.cs | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index ae4a3db..ca68e85 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -66,28 +66,37 @@ namespace OpenSim.Framework.Communications.Capabilities 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) + try { - writer.WriteStartElement(String.Empty, "key", String.Empty); - string fieldName = fields[i].Name; - fieldName = fieldName.Replace("___", "-"); - writer.WriteString(fieldName); - writer.WriteEndElement(); - SerializeOSDType(writer, fieldValue); - } - else + 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); + string fieldName = fields[i].Name; + fieldName = fieldName.Replace("___", "-"); + writer.WriteString(fieldName); + writer.WriteEndElement(); + SerializeOSDType(writer, fieldValue); + } + else + { + writer.WriteStartElement(String.Empty, "key", String.Empty); + string fieldName = fields[i].Name; + fieldName = fieldName.Replace("___", "-"); + writer.WriteString(fieldName); + writer.WriteEndElement(); + LLSD.LLSDWriteOne(writer, fieldValue); + // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( + // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); + } + } catch(NullReferenceException e) { - writer.WriteStartElement(String.Empty, "key", String.Empty); - string fieldName = fields[i].Name; - fieldName = fieldName.Replace("___", "-"); - writer.WriteString(fieldName); - writer.WriteEndElement(); - LLSD.LLSDWriteOne(writer, fieldValue); - // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); + System.Console.WriteLine("-----------NRE-------------"); + System.Console.WriteLine("Type: " + fields[i].GetValue(obj).GetType().FullName); + System.Console.WriteLine("-----------NRE-------------"); + throw; } } writer.WriteEndElement(); -- cgit v1.1 From dd8c01d7a730e99a2c454848a476b27640a48e3f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 10 May 2009 21:00:07 +0000 Subject: * Attempting to fix NullRef exception in inventory. --- OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index ca68e85..ba82c75 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Capabilities FieldInfo[] fields = myType.GetFields(); for (int i = 0; i < fields.Length; i++) { - try + if (fields[i] != null && fields[i].GetValue(obj) != null) { object fieldValue = fields[i].GetValue(obj); LLSDType[] fieldAttributes = @@ -91,12 +91,12 @@ namespace OpenSim.Framework.Communications.Capabilities // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); } - } catch(NullReferenceException e) + } + else { - System.Console.WriteLine("-----------NRE-------------"); - System.Console.WriteLine("Type: " + fields[i].GetValue(obj).GetType().FullName); - System.Console.WriteLine("-----------NRE-------------"); - throw; + // TODO from ADAM: There is a nullref being caused by fields[i] being null + // on some computers. Unsure what is causing this, but would appreciate + // if sdague could take a look at this. } } writer.WriteEndElement(); -- cgit v1.1 From 54ab7d7ceb38858346958ad22e07076365966970 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 10 May 2009 21:35:07 +0000 Subject: * Rather than crash the region simulator, declare the teleport a failure if the "success" mapping doesn't exist. (also; I hate LLSD.) --- .../Framework/Communications/Clients/RegionClient.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 6fdacb1..bd71357 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -124,12 +124,19 @@ namespace OpenSim.Framework.Communications.Clients if (!String.IsNullOrEmpty(response)) { - // we assume we got an OSDMap back - OSDMap r = GetOSDMap(response); - bool success = r["success"].AsBoolean(); - reason = r["reason"].AsString(); - - return success; + try + { + // we assume we got an OSDMap back + OSDMap r = GetOSDMap(response); + bool success = r["success"].AsBoolean(); + reason = r["reason"].AsString(); + return success; + } + catch (NullReferenceException e) + { + m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); + return false; + } } } } -- cgit v1.1 From 85bbcf196f208e614922d265615d43713d599351 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 11 May 2009 09:58:36 +0000 Subject: adding code to check for old-style responses ("True") --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index bd71357..fb1dc19 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -135,6 +135,11 @@ namespace OpenSim.Framework.Communications.Clients catch (NullReferenceException e) { m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); + + // check for old style response + if (response.ToLower().StartsWith("true")) + return true; + return false; } } -- cgit v1.1 From b95b7222f904435bef175b8c8f98b47356273b86 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 13 May 2009 16:34:57 +0000 Subject: Disabling WebFetchInventoryDescendents CAPs for the time being as it seems to screw up standalone mode. --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d0c1925..24cf0b6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -203,8 +203,10 @@ namespace OpenSim.Framework.Communications.Capabilities m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; - // As of RC 1.22.9 of the Linden client this is supported - m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); + // As of RC 1.22.9 of the Linden client this is + // supported + + // m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires -- cgit v1.1 From d10b5e29bcef7335d38d4cbb590b60b7b171897b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 14 May 2009 16:33:04 +0000 Subject: * refactor: break some of xml2 serialization out of sog --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index fb1dc19..5c2babc 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -362,10 +362,12 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, bool allowScriptCrossing) + public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) { ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; + string uri + = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); WebRequest ObjectCreateRequest = WebRequest.Create(uri); @@ -374,7 +376,7 @@ namespace OpenSim.Framework.Communications.Clients ObjectCreateRequest.Timeout = 10000; OSDMap args = new OSDMap(2); - args["sog"] = OSD.FromString(sog.ToXmlString2()); + args["sog"] = OSD.FromString(sogXml2); args["extra"] = OSD.FromString(sog.ExtraToXmlString()); if (allowScriptCrossing) { -- cgit v1.1 From 5e4fc6e91e5edffd1dc23af4f583d6294f394a3d Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 15 May 2009 05:00:25 +0000 Subject: Heart surgery on asset service code bits. Affects OpenSim.ini configuration -- please see the example. Affects region servers only. This may break a lot of things, but it needs to go in. It was tested in standalone and the UCI grid, but it needs a lot more testing. Known problems: * HG asset transfers are borked for now * missing texture is missing * 3 unit tests commented out for now --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 7 ++++--- OpenSim/Framework/Communications/Services/HGInventoryService.cs | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 24cf0b6..27395e3 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -34,6 +34,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; // using OpenSim.Region.Framework.Interfaces; @@ -100,7 +101,7 @@ namespace OpenSim.Framework.Communications.Capabilities //private string eventQueue = "0100/"; private IHttpServer m_httpListener; private UUID m_agentID; - private IAssetCache m_assetCache; + private IAssetService m_assetCache; private int m_eventQueueCount = 1; private Queue m_capsEventQueue = new Queue(); private bool m_dumpAssetsToFile; @@ -128,7 +129,7 @@ namespace OpenSim.Framework.Communications.Capabilities public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; public GetClientDelegate GetClient = null; - public Caps(IAssetCache assetCache, IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, + public Caps(IAssetService assetCache, IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, UUID agent, bool dumpAssetsToFile, string regionName) { m_assetCache = assetCache; @@ -870,7 +871,7 @@ namespace OpenSim.Framework.Communications.Capabilities if (AddNewAsset != null) AddNewAsset(asset); else if (m_assetCache != null) - m_assetCache.AddAsset(asset); + m_assetCache.Store(asset); InventoryItemBase item = new InventoryItemBase(); item.Owner = m_agentID; diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index 77a6177..5334a21 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -40,6 +40,7 @@ using Caps = OpenSim.Framework.Communications.Capabilities.Caps; using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; using OpenMetaverse.StructuredData; @@ -58,7 +59,7 @@ namespace OpenSim.Framework.Communications.Services // These two used for local access, standalone mode private UserManagerBase m_userService = null; - IAssetDataPlugin m_assetProvider = null; + IAssetService m_assetProvider = null; // These two used for remote access //string m_UserServerURL = string.Empty; @@ -77,7 +78,7 @@ namespace OpenSim.Framework.Communications.Services } // Constructor for standalone mode - public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) + public HGInventoryService(InventoryServiceBase invService, IAssetService assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) { m_userService = userService; m_assetProvider = assetService; @@ -708,7 +709,7 @@ namespace OpenSim.Framework.Communications.Services return m_AssetClient.SyncGetAsset(assetID, isTexture); // local call else - return m_assetProvider.FetchAsset(assetID); + return m_assetProvider.Get(assetID.ToString()); } void StoreAsset(AssetBase asset) @@ -718,7 +719,7 @@ namespace OpenSim.Framework.Communications.Services m_AssetClient.StoreAsset(asset); // local call else - m_assetProvider.CreateAsset(asset); + m_assetProvider.Store(asset); } #endregion Local vs Remote -- cgit v1.1 From 23d902be42fd6d554a9098936d501609fc6e5315 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 18 May 2009 23:18:04 +0000 Subject: Remove the old asset cache and local services and the configurations for them --- .../Framework/Communications/Cache/AssetCache.cs | 695 --------------------- .../Communications/Cache/SQLAssetServer.cs | 113 ---- .../Communications/CommunicationsManager.cs | 14 - .../Communications/Tests/Cache/AssetCacheTests.cs | 61 +- 4 files changed, 1 insertion(+), 882 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/AssetCache.cs delete mode 100644 OpenSim/Framework/Communications/Cache/SQLAssetServer.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs deleted file mode 100644 index 7d25ca9..0000000 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ /dev/null @@ -1,695 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using GlynnTucker.Cache; -using log4net; -using OpenMetaverse; -using OpenMetaverse.Packets; -using OpenSim.Framework.Statistics; -using System.Text; - -namespace OpenSim.Framework.Communications.Cache -{ - /// - /// Manages local cache of assets and their sending to viewers. - /// - /// - /// This class actually encapsulates two largely separate mechanisms. One mechanism fetches assets either - /// synchronously or async and passes the data back to the requester. The second mechanism fetches assets and - /// sends packetised data directly back to the client. The only point where they meet is AssetReceived() and - /// AssetNotFound(), which means they do share the same asset and texture caches. - public class AssetCache : IAssetCache - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected ICache m_memcache = new SimpleMemoryCache(); - - /// - /// Assets requests which are waiting for asset server data. This includes texture requests - /// - private Dictionary RequestedAssets; - - /// - /// Asset requests with data which are ready to be sent back to requesters. This includes textures. - /// - private List AssetRequests; - - /// - /// Until the asset request is fulfilled, each asset request is associated with a list of requesters - /// - private Dictionary RequestLists; - - #region IPlugin - - /// - /// The methods and properties in this section are needed to - /// support the IPlugin interface. They cann all be overridden - /// as needed by a derived class. - /// - - public virtual string Name - { - get { return "OpenSim.Framework.Communications.Cache.AssetCache"; } - } - - public virtual string Version - { - get { return "1.0"; } - } - - public virtual void Initialise() - { - m_log.Debug("[ASSET CACHE]: Asset cache null initialisation"); - } - - public virtual void Initialise(IAssetServer assetServer) - { - m_log.Debug("[ASSET CACHE]: Asset cache server-specified initialisation"); - m_log.InfoFormat("[ASSET CACHE]: Asset cache initialisation [{0}/{1}]", Name, Version); - - Reset(); - - m_assetServer = assetServer; - m_assetServer.SetReceiver(this); - - Thread assetCacheThread = new Thread(RunAssetManager); - assetCacheThread.Name = "AssetCacheThread"; - assetCacheThread.IsBackground = true; - assetCacheThread.Start(); - ThreadTracker.Add(assetCacheThread); - } - - public virtual void Initialise(ConfigSettings settings, IAssetServer assetServer) - { - m_log.Debug("[ASSET CACHE]: Asset cache configured initialisation"); - Initialise(assetServer); - } - - public void Dispose() - { - } - - #endregion - - public IAssetServer AssetServer - { - get { return m_assetServer; } - } - private IAssetServer m_assetServer; - - public AssetCache() - { - m_log.Debug("[ASSET CACHE]: Asset cache (plugin constructor)"); - } - - /// - /// Constructor. - /// - /// - public AssetCache(IAssetServer assetServer) - { - Initialise(assetServer); - } - - public void ShowState() - { - m_log.InfoFormat("Memcache:{0} RequestLists:{1}", - m_memcache.Count, - // AssetRequests.Count, - // RequestedAssets.Count, - RequestLists.Count); - } - - public void Clear() - { - m_log.Info("[ASSET CACHE]: Clearing Asset cache"); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.ClearAssetCacheStatistics(); - - Reset(); - } - - /// - /// Reset the cache. - /// - private void Reset() - { - AssetRequests = new List(); - RequestedAssets = new Dictionary(); - RequestLists = new Dictionary(); - } - - /// - /// Process the asset queue which holds data which is packeted up and sent - /// directly back to the client. - /// - private void RunAssetManager() - { - while (true) - { - try - { - ProcessAssetQueue(); - Thread.Sleep(500); - } - catch (Exception e) - { - if (e != null) - { - m_log.ErrorFormat("[ASSET CACHE]: {0}", e); - } - else - { - // this looks weird, but we've seen this show up as an issue in unit tests, so leave it here until we know why - m_log.Error("[ASSET CACHE]: an exception was thrown in RunAssetManager, but is now null. Something is very wrong."); - } - } - } - } - - public bool TryGetCachedAsset(UUID assetId, out AssetBase asset) - { - Object tmp; - if (m_memcache.TryGet(assetId, out tmp)) - { - asset = (AssetBase)tmp; - //m_log.Info("Retrieved from cache " + assetId); - return true; - } - - asset = null; - return false; - } - - public void GetAsset(UUID assetId, AssetRequestCallback callback, bool isTexture) - { - //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); - - // Xantor 20080526: - // if a request is made for an asset which is not in the cache yet, but has already been requested by - // something else, queue up the callbacks on that requestor instead of swamping the assetserver - // with multiple requests for the same asset. - - AssetBase asset; - - if (TryGetCachedAsset(assetId, out asset)) - { - callback(assetId, asset); - } - else - { - // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - - NewAssetRequest req = new NewAssetRequest(callback); - AssetRequestsList requestList; - - lock (RequestLists) - { - if (RequestLists.TryGetValue(assetId, out requestList)) // do we already have a request pending? - { - // m_log.DebugFormat("[ASSET CACHE]: Intercepted Duplicate request for {0} {1}", isTexture ? "texture" : "asset", assetId); - // add to callbacks for this assetId - RequestLists[assetId].Requests.Add(req); - } - else - { - // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); - requestList = new AssetRequestsList(); - requestList.TimeRequested = DateTime.Now; - requestList.Requests.Add(req); - - RequestLists.Add(assetId, requestList); - - m_assetServer.RequestAsset(assetId, isTexture); - } - } - } - } - - public AssetBase GetAsset(UUID assetID, bool isTexture) - { - // I'm not going over 3 seconds since this will be blocking processing of all the other inbound - // packets from the client. - const int pollPeriod = 200; - int maxPolls = 15; - - AssetBase asset; - - if (TryGetCachedAsset(assetID, out asset)) - { - return asset; - } - - m_assetServer.RequestAsset(assetID, isTexture); - - do - { - Thread.Sleep(pollPeriod); - - if (TryGetCachedAsset(assetID, out asset)) - { - return asset; - } - } - while (--maxPolls > 0); - - m_log.WarnFormat("[ASSET CACHE]: {0} {1} was not received before the retrieval timeout was reached", - isTexture ? "texture" : "asset", assetID.ToString()); - - return null; - } - - public void AddAsset(AssetBase asset) - { - if (!m_memcache.Contains(asset.FullID)) - { - m_log.Info("[CACHE] Caching " + asset.FullID + " for 24 hours from last access"); - // Use 24 hour rolling asset cache. - m_memcache.AddOrUpdate(asset.FullID, asset, TimeSpan.FromHours(24)); - - // According to http://wiki.secondlife.com/wiki/AssetUploadRequest, Local signifies that the - // information is stored locally. It could disappear, in which case we could send the - // ImageNotInDatabase packet to tell the client this. - // - // However, this doesn't quite appear to work with local textures that are part of an avatar's - // appearance texture set. Whilst sending an ImageNotInDatabase does trigger an automatic rebake - // and reupload by the client, if those assets aren't pushed to the asset server anyway, then - // on crossing onto another region server, other avatars can no longer get the required textures. - // There doesn't appear to be any signal from the sim to the newly region border crossed client - // asking it to reupload its local texture assets to that region server. - // - // One can think of other cunning ways around this. For instance, on a region crossing or teleport, - // the original sim could squirt local assets to the new sim. Or the new sim could have pointers - // to the original sim to fetch the 'local' assets (this is getting more complicated). - // - // But for now, we're going to take the easy way out and store local assets globally. - // - // TODO: Also, Temporary is now deprecated. We should start ignoring it and not passing it out from LLClientView. - if (!asset.Temporary || asset.Local) - { - m_assetServer.StoreAsset(asset); - } - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAsset(asset); - } - } - - public void ExpireAsset(UUID uuid) - { - if (m_memcache.Contains(uuid)) - { - m_memcache.Remove(uuid); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.RemoveAsset(uuid); - } - } - - // See IAssetReceiver - public virtual void AssetReceived(AssetBase asset, bool IsTexture) - { - AssetInfo assetInf = new AssetInfo(asset); - - ProcessReceivedAsset(IsTexture, assetInf, null); - - if (!m_memcache.Contains(assetInf.FullID)) - { - m_memcache.AddOrUpdate(assetInf.FullID, assetInf, TimeSpan.FromHours(24)); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAsset(assetInf); - - if (RequestedAssets.ContainsKey(assetInf.FullID)) - { - AssetRequest req = RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - req.NumPackets = CalculateNumPackets(assetInf.Data); - - RequestedAssets.Remove(assetInf.FullID); - - if (req.AssetRequestSource == 2 && assetInf.Type == 10) - { - // If it's a direct request for a script, drop it - // because it's a hacked client - } - else - { - lock (AssetRequests) - { - AssetRequests.Add(req); - } - } - } - } - - // Notify requesters for this asset - AssetRequestsList reqList; - - lock (RequestLists) - { - if (RequestLists.TryGetValue(asset.FullID, out reqList)) - RequestLists.Remove(asset.FullID); - } - - if (reqList != null) - { - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); - - foreach (NewAssetRequest req in reqList.Requests) - { - // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked - // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); - req.Callback(asset.FullID, asset); - } - } - } - - protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService) - { - // if (!IsTexture && assetInf.ContainsReferences && false) - // { - // assetInf.Data = ProcessAssetData(assetInf.Data, userService); - // } - } - - // See IAssetReceiver - public virtual void AssetNotFound(UUID assetId, bool isTexture) - { -// m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetId); - - // Remember the fact that this asset could not be found to prevent delays from repeated requests - m_memcache.Add(assetId, null, TimeSpan.FromHours(24)); - - // Notify requesters for this asset - AssetRequestsList reqList; - lock (RequestLists) - { - if (RequestLists.TryGetValue(assetId, out reqList)) - RequestLists.Remove(assetId); - } - - if (reqList != null) - { - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAssetRequestTimeAfterCacheMiss(DateTime.Now - reqList.TimeRequested); - - foreach (NewAssetRequest req in reqList.Requests) - { - req.Callback(assetId, null); - } - } - } - - /// - /// Calculate the number of packets required to send the asset to the client. - /// - /// - /// - private static int CalculateNumPackets(byte[] data) - { - const uint m_maxPacketSize = 600; - int numPackets = 1; - - if (data.LongLength > m_maxPacketSize) - { - // over max number of bytes so split up file - long restData = data.LongLength - m_maxPacketSize; - int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); - numPackets += restPackets; - } - - return numPackets; - } - - public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) - { - UUID requestID = UUID.Zero; - byte source = 2; - if (transferRequest.TransferInfo.SourceType == 2) - { - //direct asset request - requestID = new UUID(transferRequest.TransferInfo.Params, 0); - } - else if (transferRequest.TransferInfo.SourceType == 3) - { - //inventory asset request - requestID = new UUID(transferRequest.TransferInfo.Params, 80); - source = 3; - //m_log.Debug("asset request " + requestID); - } - - //check to see if asset is in local cache, if not we need to request it from asset server. - //m_log.Debug("asset request " + requestID); - if (!m_memcache.Contains(requestID)) - { - //not found asset - // so request from asset server - if (!RequestedAssets.ContainsKey(requestID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = requestID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - request.AssetRequestSource = source; - request.Params = transferRequest.TransferInfo.Params; - RequestedAssets.Add(requestID, request); - m_assetServer.RequestAsset(requestID, false); - } - - return; - } - - // It has an entry in our cache - AssetBase asset = (AssetBase)m_memcache[requestID]; - - // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. - if (null == asset) - { - //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); - return; - } - - // Scripts cannot be retrieved by direct request - if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) - return; - - // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; - req.AssetRequestSource = source; - req.Params = transferRequest.TransferInfo.Params; - req.AssetInf = new AssetInfo(asset); - req.NumPackets = CalculateNumPackets(asset.Data); - lock (AssetRequests) - { - AssetRequests.Add(req); - } - } - - /// - /// Process the asset queue which sends packets directly back to the client. - /// - private void ProcessAssetQueue() - { - //should move the asset downloading to a module, like has been done with texture downloading - if (AssetRequests.Count == 0) - { - //no requests waiting - return; - } - - // if less than 5, do all of them - int num = Math.Min(5, AssetRequests.Count); - - AssetRequest req; - AssetRequestToClient req2 = new AssetRequestToClient(); - - lock (AssetRequests) - { - for (int i = 0; i < num; i++) - { - req = AssetRequests[0]; - AssetRequests.RemoveAt(0); - req2.AssetInf = req.AssetInf; - req2.AssetRequestSource = req.AssetRequestSource; - req2.DataPointer = req.DataPointer; - req2.DiscardLevel = req.DiscardLevel; - req2.ImageInfo = req.ImageInfo; - req2.IsTextureRequest = req.IsTextureRequest; - req2.NumPackets = req.NumPackets; - req2.PacketCounter = req.PacketCounter; - req2.Params = req.Params; - req2.RequestAssetID = req.RequestAssetID; - req2.TransferRequestID = req.TransferRequestID; - req.RequestUser.SendAsset(req2); - } - } - } - - public byte[] ProcessAssetData(byte[] assetData, IUserService userService) - { - string data = Encoding.ASCII.GetString(assetData); - - data = ProcessAssetDataString(data, userService); - - return Encoding.ASCII.GetBytes(data); - } - - public string ProcessAssetDataString(string data, IUserService userService) - { - Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); - - data = regex.Replace(data, delegate(Match m) - { - string result = String.Empty; - - string key = m.Groups[1].Captures[0].Value; - - string value = m.Groups[2].Captures[0].Value; - - Uri userUri; - - switch (key) - { - case "creator_url": - userUri = new Uri(value); - result = "creator_id " + ResolveUserUri(userService, userUri); - break; - - case "owner_url": - userUri = new Uri(value); - result = "owner_id " + ResolveUserUri(userService, userUri); - break; - } - - return result; - }); - - return data; - } - - private Guid ResolveUserUri(IUserService userService, Uri userUri) - { - Guid id; - UserProfileData userProfile = userService.GetUserProfile(userUri); - if (userProfile == null) - { - id = Guid.Empty; - } - else - { - id = userProfile.ID.Guid; - } - return id; - } - - - public class AssetRequest - { - public IClientAPI RequestUser; - public UUID RequestAssetID; - public AssetInfo AssetInf; - public TextureImage ImageInfo; - public UUID TransferRequestID; - public long DataPointer = 0; - public int NumPackets = 0; - public int PacketCounter = 0; - public bool IsTextureRequest; - public byte AssetRequestSource = 2; - public byte[] Params = null; - //public bool AssetInCache; - //public int TimeRequested; - public int DiscardLevel = -1; - } - - public class AssetInfo : AssetBase - { - public AssetInfo(AssetBase aBase) - { - Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - Name = aBase.Name; - Description = aBase.Description; - } - - public const string Secret = "secret"; - } - - public class TextureImage : AssetBase - { - public TextureImage(AssetBase aBase) - { - Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - Name = aBase.Name; - Description = aBase.Description; - } - } - - /// - /// A list of requests for a particular asset. - /// - public class AssetRequestsList - { - /// - /// A list of requests for assets - /// - public List Requests = new List(); - - /// - /// Record the time that this request was first made. - /// - public DateTime TimeRequested; - } - - /// - /// Represent a request for an asset that has yet to be fulfilled. - /// - public class NewAssetRequest - { - public AssetRequestCallback Callback; - - public NewAssetRequest(AssetRequestCallback callback) - { - Callback = callback; - } - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs deleted file mode 100644 index 227744d..0000000 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ /dev/null @@ -1,113 +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.Reflection; -using log4net; -using OpenSim.Data; - -namespace OpenSim.Framework.Communications.Cache -{ - public class SQLAssetServer : AssetServerBase - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region IPlugin - - public override string Name - { - get { return "SQL"; } - } - - public override string Version - { - get { return "1.0"; } - } - - public override void Initialise(ConfigSettings p_set) - { - m_log.Debug("[SQLAssetServer]: Plugin configured initialisation"); - Initialise(p_set.StandaloneAssetPlugin,p_set.StandaloneAssetSource); - } - - #endregion - - public SQLAssetServer() {} - - public SQLAssetServer(string pluginName, string connect) - { - m_log.Debug("[SQLAssetServer]: Direct constructor"); - Initialise(pluginName, connect); - } - - public void Initialise(string pluginName, string connect) - { - AddPlugin(pluginName, connect); - } - - public SQLAssetServer(IAssetDataPlugin assetProvider) - { - m_assetProvider = assetProvider; - } - - public void AddPlugin(string FileName, string connect) - { - m_log.Info("[SQLAssetServer]: AssetStorage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetDataPlugin", true); - - if (typeInterface != null) - { - IAssetDataPlugin plug = - (IAssetDataPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - m_assetProvider = plug; - m_assetProvider.Initialise(connect); - - m_log.Info("[AssetStorage]: " + - "Added " + m_assetProvider.Name + " " + - m_assetProvider.Version); - } - } - } - } - - protected override AssetBase GetAsset(AssetRequest req) - { - return m_assetProvider.FetchAsset(req.AssetID); - } - - public override void StoreAsset(AssetBase asset) - { - m_assetProvider.CreateAsset(asset); - } - } -} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index b49e7bc..81fb8e1 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -72,25 +72,12 @@ namespace OpenSim.Framework.Communications } protected UserProfileCacheService m_userProfileCacheService; - // protected AgentAssetTransactionsManager m_transactionsManager; - - // public AgentAssetTransactionsManager TransactionsManager - // { - // get { return m_transactionsManager; } - // } - public IAvatarService AvatarService { get { return m_avatarService; } } protected IAvatarService m_avatarService; - public IAssetCache AssetCache - { - get { return m_assetCache; } - } - protected IAssetCache m_assetCache; - public IInterServiceInventoryServices InterServiceInventoryService { get { return m_interServiceInventoryService; } @@ -132,7 +119,6 @@ namespace OpenSim.Framework.Communications bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; - m_assetCache = assetCache; m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); m_httpServer = httpServer; } diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index a5ee549..a40adf3 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -43,51 +43,6 @@ namespace OpenSim.Framework.Communications.Tests [TestFixture] public class AssetCacheTests { - protected UUID m_assetIdReceived; - protected AssetBase m_assetReceived; - - /// - /// Test the 'asynchronous' get asset mechanism (though this won't be done asynchronously within this test) - /// - [Test] - public void TestGetAsset() - { - UUID assetId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - byte[] assetData = new byte[] { 3, 2, 1 }; - - AssetBase asset = new AssetBase(); - asset.FullID = assetId; - asset.Data = assetData; - - TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); - assetPlugin.CreateAsset(asset); - - SQLAssetServer assetServer = new SQLAssetServer(assetPlugin); - IAssetCache assetCache = new AssetCache(assetServer); - - assetCache.GetAsset(assetId, AssetRequestCallback, false); - - // Manually pump the asset server - while (assetServer.HasWaitingRequests()) - assetServer.ProcessNextRequest(); - - Assert.That( - assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received"); - Assert.That( - assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received"); - } - - private void AssetRequestCallback(UUID assetId, AssetBase asset) - { - m_assetIdReceived = assetId; - m_assetReceived = asset; - - lock (this) - { - Monitor.PulseAll(this); - } - } - private class FakeUserService : IUserService { public void AddTemporaryUserProfile(UserProfileData userProfile) @@ -109,7 +64,7 @@ namespace OpenSim.Framework.Communications.Tests { UserProfileData userProfile = new UserProfileData(); - userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); +// userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); return userProfile; } @@ -189,19 +144,5 @@ namespace OpenSim.Framework.Communications.Tests return true; } } - - [Test] - public void TestProcessAssetData() - { - string url = "http://host/dir/"; - string creatorData = " creator_url " + url + " "; - string ownerData = " owner_url " + url + " "; - - AssetCache assetCache = new AssetCache(); - FakeUserService fakeUserService = new FakeUserService(); - - Assert.AreEqual(" creator_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(creatorData, fakeUserService)); - Assert.AreEqual(" owner_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(ownerData, fakeUserService)); - } } } -- cgit v1.1 From 1d02636c27de64f8acec5bb9a76f8659f0bfdd2b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 22 May 2009 14:57:00 +0000 Subject: cleaning out warnings. NOTE: we currently have a gazillion warnings caused stuff flagged as "obsolete" (OGS1 stuff) --- what's up with that? --- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 27395e3..9c59c89 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Capabilities //private static readonly string m_requestTexture = "0003/"; private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; - private static readonly string m_fetchInventoryPath = "0006/"; + // private static readonly string m_fetchInventoryPath = "0006/"; // The following entries are in a module, however, they are also here so that we don't re-assign // the path to another cap by mistake. -- cgit v1.1 From 31baeef469d72a9dc13cf4f56392b9f740f71cba Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 06:05:20 +0000 Subject: * Pipes requestors IP address through all XmlRpcRequest delegates. This is needed to be able to 'NAT-wrap' the login sequence. * If you have something using XmlRpc that isn't in core, change your method signature from: (XmlRpcRequest request) to: (XmlRpcRequest request, IPEndPoint remoteClient) --- .../Communications/Services/GridInfoService.cs | 3 ++- .../Communications/Services/HGLoginAuthService.cs | 8 ++++---- .../Framework/Communications/Services/LoginService.cs | 5 +++-- .../Communications/Tests/LoginServiceTests.cs | 18 +++++++++--------- 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index f17bb9f..317dba2 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.IO; +using System.Net; using System.Reflection; using System.Text; using log4net; @@ -138,7 +139,7 @@ namespace OpenSim.Framework.Communications.Services } } - public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) + public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index b62e4a2..3756cf5 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -86,10 +86,10 @@ namespace OpenSim.Framework.Communications.Services m_serversInfo = sinfo; } - public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) { m_log.Info("[HGLOGIN]: HGLogin called " + request.MethodName); - XmlRpcResponse response = base.XmlRpcLoginMethod(request); + XmlRpcResponse response = base.XmlRpcLoginMethod(request, remoteClient); Hashtable responseData = (Hashtable)response.Value; responseData["grid_service"] = m_serversInfo.GridURL; @@ -132,7 +132,7 @@ namespace OpenSim.Framework.Communications.Services return response; } - public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) + public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) { // Verify the key of who's calling UUID userID = UUID.Zero; @@ -157,7 +157,7 @@ namespace OpenSim.Framework.Communications.Services return response; } - public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) + public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) { bool success = false; diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index f55c030..6859827 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using System.Net; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; @@ -97,7 +98,7 @@ namespace OpenSim.Framework.Communications.Services /// /// The XMLRPC request /// The response to send - public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) { // Temporary fix m_loginMutex.WaitOne(); @@ -1125,7 +1126,7 @@ namespace OpenSim.Framework.Communications.Services return false; } - public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) + public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 7d75faa..a2a388e 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -103,7 +103,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); @@ -140,7 +140,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; UserAgentData uagent = m_userProfileData.CurrentAgent; @@ -194,7 +194,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; ArrayList friendslist = (ArrayList) responseData["buddy-list"]; @@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -256,7 +256,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -281,7 +281,7 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); @@ -312,20 +312,20 @@ namespace OpenSim.Framework.Communications.Tests // First we log in. XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request); + response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); // Finally the third time we should be able to get right back in. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request); + response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); -- cgit v1.1 From e9ea9592631beb164bfca0765b14ffbfbbaa4fb7 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 06:14:02 +0000 Subject: * Pipes IPEndPoint through all Login methods, including LLSD/OSD login paths. --- .../Communications/Services/HGLoginAuthService.cs | 2 +- OpenSim/Framework/Communications/Services/LoginService.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 3756cf5..1de0d4d 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -259,7 +259,7 @@ namespace OpenSim.Framework.Communications.Services /// /// /// true if the region was successfully contacted, false otherwise - protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) + protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) { IPEndPoint endPoint = regionInfo.ExternalEndPoint; response.SimAddress = endPoint.Address.ToString(); diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 6859827..68a1819 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -256,7 +256,7 @@ namespace OpenSim.Framework.Communications.Services logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; - if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) + if (CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient)) { userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; CommitAgent(ref userProfile); @@ -351,7 +351,7 @@ namespace OpenSim.Framework.Communications.Services /// /// The LLSD request /// The response to send - public OSD LLSDLoginMethod(OSD request) + public OSD LLSDLoginMethod(OSD request, IPEndPoint remoteClient) { // Temporary fix m_loginMutex.WaitOne(); @@ -486,7 +486,7 @@ namespace OpenSim.Framework.Communications.Services try { - CustomiseResponse(logResponse, userProfile, startLocationRequest); + CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient); } catch (Exception ex) { @@ -891,7 +891,7 @@ namespace OpenSim.Framework.Communications.Services /// The user profile /// The requested start location /// true on success, false if the region was not successfully told to expect a user connection - public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest, IPEndPoint client) { // add active gestures to login-response AddActiveGestures(response, theUser); @@ -984,7 +984,7 @@ namespace OpenSim.Framework.Communications.Services response.StartLocation = "url"; } - if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) + if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response, client))) { return true; } @@ -1015,13 +1015,13 @@ namespace OpenSim.Framework.Communications.Services theUser.CurrentAgent.Position = new Vector3(128, 128, 0); response.StartLocation = "safe"; - return PrepareLoginToRegion(regionInfo, theUser, response); + return PrepareLoginToRegion(regionInfo, theUser, response, client); } protected abstract RegionInfo RequestClosestRegion(string region); protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); + protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); /// /// Add active gestures of the user to the login response. -- cgit v1.1 From 6b312d934085caf1add5e6081f55c9944ab01aa9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 06:29:08 +0000 Subject: * Implements automatic loopback handling for standalone regions. * This /should/ make OpenSim behave properly when hosting behind a NAT router and utilizing port forwarding (but the router doesn't support Loopback) --- .../Framework/Communications/Services/HGLoginAuthService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 1de0d4d..0637a1e 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -279,11 +279,17 @@ namespace OpenSim.Framework.Communications.Services if (m_serversInfo.HttpUsesSSL) { - seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; + // For NAT + string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN); + + seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath; } else { - seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; + // For NAT + string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName); + + seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath; } response.SeedCapability = seedcap; -- cgit v1.1 From 70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 07:51:29 +0000 Subject: * Fixes [irritating] edge case in Util.GetLocalHost which could return an IPv6 address if no non-loopback IPv4 address can be found. * Restores internal IPv6 support to NetworkUtil.* * Fixes bad login unit tests. --- .../Communications/Tests/LoginServiceTests.cs | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index a2a388e..7fda38c 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -103,7 +103,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); @@ -113,7 +116,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" - + m_regionExternalName + + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); @@ -140,7 +143,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; UserAgentData uagent = m_userProfileData.CurrentAgent; @@ -163,7 +169,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" - + m_regionExternalName + + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); @@ -194,14 +200,16 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; ArrayList friendslist = (ArrayList) responseData["buddy-list"]; Assert.That(friendslist,Is.Not.Null); - Hashtable buddy1 = (Hashtable) friendslist[0]; Hashtable buddy2 = (Hashtable) friendslist[1]; Assert.That(friendslist.Count, Is.EqualTo(2)); @@ -231,7 +239,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -256,7 +267,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -281,7 +295,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); @@ -312,20 +329,24 @@ namespace OpenSim.Framework.Communications.Tests // First we log in. XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); // Finally the third time we should be able to get right back in. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); -- cgit v1.1 From ba360ede8b876c5c1b99b4f172eb5d254a1c6f5a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 25 May 2009 11:43:56 +0000 Subject: * Upped version number to 0.6.5 --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 3754016..e2ee74a 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.4.*")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 6ff01c774e2d4935964fbe6227785c89288c7eff Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 26 May 2009 01:05:40 +0000 Subject: Addresses mantis #3718. --- OpenSim/Framework/Communications/Clients/AuthClient.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 49ec7ba..5714395 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -124,7 +124,16 @@ namespace OpenSim.Framework.Communications.Clients ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); - XmlRpcResponse UserResp = UserReq.Send(authurl, 3000); + XmlRpcResponse UserResp = null; + try + { + UserResp = UserReq.Send(authurl, 3000); + } + catch (Exception e) + { + System.Console.WriteLine("[Session Auth]: VerifySession XmlRpc: " + e.Message); + return false; + } Hashtable responseData = (Hashtable)UserResp.Value; if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") -- cgit v1.1 From 7ab1986bf022f74dd2dcbb81df60bc2cad47d2cb Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 26 May 2009 22:39:01 +0000 Subject: Catching weirdnesses on resolving External EndPoint in agent transfers. Will probably need to do more aggressively. --- .../Communications/Clients/RegionClient.cs | 39 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 5c2babc..4f5a4cf 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -45,8 +45,21 @@ namespace OpenSim.Framework.Communications.Clients public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) { + reason = String.Empty; + // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + string uri = string.Empty; + try + { + uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); + reason = e.Message; + return false; + } + //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); @@ -56,8 +69,6 @@ namespace OpenSim.Framework.Communications.Clients //AgentCreateRequest.KeepAlive = false; AgentCreateRequest.Headers.Add("Authorization", authKey); - reason = String.Empty; - // Fill it in OSDMap args = null; try @@ -158,7 +169,16 @@ namespace OpenSim.Framework.Communications.Clients public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) { // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + string uri = string.Empty; + try + { + uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); + return false; + } //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); @@ -330,7 +350,16 @@ namespace OpenSim.Framework.Communications.Clients public bool DoCloseAgentCall(RegionInfo region, UUID id) { - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + string uri = string.Empty; + try + { + uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; + } + catch (Exception e) + { + m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); + return false; + } //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); -- cgit v1.1 From 4aad6a07ffbf1190836940b14476f24b7e8cecb1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 29 May 2009 21:01:18 +0000 Subject: * refactor: Remove redundent prim id attribute on Scene.AddSceneObject() --- OpenSim/Framework/Communications/Services/LoginService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 68a1819..2847887 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -91,8 +91,7 @@ namespace OpenSim.Framework.Communications.Services public virtual void LogOffUser(UserProfileData theUser, string message) { } - - + /// /// Called when we receive the client's initial XMLRPC login_to_simulator request message /// -- cgit v1.1 From d0084f08f2d2d591706242227b2825a1e82e902e Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Fri, 29 May 2009 22:38:18 +0000 Subject: * Allows standalone region users to skip the "You must wait 5 minutes to log again" message and allow the region to kick the old user and log the new one without reporting any failure. Default is still to show message and fail login --- .../Framework/Communications/Services/LoginService.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 2847887..34d24cb 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -61,6 +61,8 @@ namespace OpenSim.Framework.Communications.Services protected uint m_defaultHomeX; protected uint m_defaultHomeY; + protected bool m_warn_already_logged = true; + /// /// Used by the login service to make requests to the inventory service. /// @@ -181,11 +183,20 @@ namespace OpenSim.Framework.Communications.Services // Reject the login - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", - firstname, lastname); + if (m_warn_already_logged) + { + m_log.InfoFormat( + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", + firstname, lastname); - return logResponse.CreateAlreadyLoggedInResponse(); + return logResponse.CreateAlreadyLoggedInResponse(); + } + else + { + m_log.InfoFormat( + "[LOGIN]: User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", + firstname, lastname); + } } // Otherwise... -- cgit v1.1 From 840de6c036570d559ec6924cd8405d3f34a99fdd Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Jun 2009 06:37:14 +0000 Subject: Minor: Change OpenSim to OpenSimulator in older copyright headers and LICENSE.txt. --- OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 2 +- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/GridAssetClient.cs | 2 +- OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 2 +- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 2 +- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 2 +- OpenSim/Framework/Communications/Capabilities/Caps.cs | 2 +- OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs | 2 +- OpenSim/Framework/Communications/Capabilities/CapsUtil.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSD.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDArray.cs | 2 +- .../Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs | 2 +- .../Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs | 2 +- .../Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs | 2 +- .../Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs | 2 +- .../Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDTest.cs | 2 +- OpenSim/Framework/Communications/Capabilities/LLSDType.cs | 2 +- .../Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs | 2 +- OpenSim/Framework/Communications/Clients/AuthClient.cs | 2 +- OpenSim/Framework/Communications/Clients/GridClient.cs | 2 +- OpenSim/Framework/Communications/Clients/RegionClient.cs | 2 +- OpenSim/Framework/Communications/CommunicationsManager.cs | 2 +- OpenSim/Framework/Communications/GenericAsyncResult.cs | 2 +- OpenSim/Framework/Communications/IAvatarService.cs | 2 +- OpenSim/Framework/Communications/IGridServices.cs | 2 +- OpenSim/Framework/Communications/IHyperlink.cs | 2 +- OpenSim/Framework/Communications/IInterServiceInventoryServices.cs | 2 +- OpenSim/Framework/Communications/IInventoryServices.cs | 2 +- OpenSim/Framework/Communications/IMessagingService.cs | 2 +- OpenSim/Framework/Communications/ISecureInventoryService.cs | 2 +- OpenSim/Framework/Communications/IUserAdminService.cs | 2 +- OpenSim/Framework/Communications/IUserService.cs | 2 +- OpenSim/Framework/Communications/InventoryServiceBase.cs | 2 +- OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs | 2 +- OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs | 2 +- OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs | 2 +- OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs | 2 +- OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs | 2 +- OpenSim/Framework/Communications/Osp/OspResolver.cs | 2 +- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- OpenSim/Framework/Communications/RestClient.cs | 2 +- OpenSim/Framework/Communications/Services/GridInfoService.cs | 2 +- OpenSim/Framework/Communications/Services/HGInventoryService.cs | 2 +- OpenSim/Framework/Communications/Services/LoginResponse.cs | 2 +- OpenSim/Framework/Communications/Services/LoginService.cs | 2 +- OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs | 2 +- OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | 2 +- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 2 +- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppError.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppSerializer.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppStanza.cs | 2 +- OpenSim/Framework/Communications/XMPP/XmppWriter.cs | 2 +- 72 files changed, 72 insertions(+), 72 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index c732d21..4b2a752 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 52869b1..cf6a798 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs index 1e2e286..4e35f5b 100644 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index aec039f..e070131 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index bc8437c..71f6f1b 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index ec62ed2..7305795 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 8f37f27..b7f209c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 9c59c89..8c14e1d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs index 55778d7..cc44023 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs index f804abb..a90eaa9 100644 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index e754256..c982092 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 668ca79..40e588f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 680dcc8..3a31523 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 16547d5..45c0afb 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index 04e9ed7..36adb93 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index d8a6265..8e5c197 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 4abdb59..d49ee1a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index ba82c75..3316b3f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs index 7cc1e38..b0b463f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 4568732..8ddb492 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 356fa5e..d012b8f 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 26815f9..4acc736 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 317e35d..c528208 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index 55d62ac..0ef4838 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs index c68dd96..68c3d75 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs index 829a2a9..e8d3c21 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -9,7 +9,7 @@ * * 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 +* * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs index 1220089..6ad2db9 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs @@ -9,7 +9,7 @@ * * 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 +* * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 4f49fb4..a55b86d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index bcea657..c359770 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 7401768..4bcf715 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index 91db060..6bed9cf 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 949e119..f3f5158 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs index 3735c77..06812aa 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -9,7 +9,7 @@ * * 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 +* * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 5714395..6b4bfec 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs index 28c3e00..74b78de 100644 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ b/OpenSim/Framework/Communications/Clients/GridClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 4f5a4cf..73e2db0 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 81fb8e1..c78212d 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index 62a921a..efd2f43 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index db583e1..4afc58f 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index fa4d8d0..6365919 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs index b6c4981..5057386 100644 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ b/OpenSim/Framework/Communications/IHyperlink.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs index 661eb91..7f17872 100644 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 3f1e9ef..166b9aa 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IMessagingService.cs b/OpenSim/Framework/Communications/IMessagingService.cs index 5d4cbf8..5d65f19 100644 --- a/OpenSim/Framework/Communications/IMessagingService.cs +++ b/OpenSim/Framework/Communications/IMessagingService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index a405ee5..ef2b40c 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IUserAdminService.cs b/OpenSim/Framework/Communications/IUserAdminService.cs index 3b7ba6e..15b989d 100644 --- a/OpenSim/Framework/Communications/IUserAdminService.cs +++ b/OpenSim/Framework/Communications/IUserAdminService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 9a3e211..c076ac4 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 010429d..a51de2d 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs index 1a9cc24..070d106 100644 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 932f780..7672653 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index bb72029..44dd592 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs index b5b925e..7ac8293 100644 --- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index 95ef484..98d0e0f 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 55978b2..502fee3 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index e2ee74a..2df6ace 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index db5010b..7a73506 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index 317dba2..70e7dce 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index 5334a21..af55236 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index 4b5c99d..c9a3175 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 34d24cb..36ec26e 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index 2e355cd..43f1440 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index a40adf3..8061c8f 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 75848b7..2ea81ef 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 7fda38c..0cce2f0 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 50f57e1..c3aaa4b 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppError.cs b/OpenSim/Framework/Communications/XMPP/XmppError.cs index 8b7e502..3d36e9c 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppError.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppError.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs index 26a98ec..12263f4 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs index d150708..1e8c33e 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs index 95d2ca3..4d45ac0 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs index 888686b..e37ef28 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs index db3c5eb..5312a31 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppStanza.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs index 4937f7a..b52eda7 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs @@ -9,7 +9,7 @@ * * 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 + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * -- cgit v1.1 From eb330f71be3fd1dd6f3c82fb3ad60bfd8be7e894 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Mon, 1 Jun 2009 18:34:40 +0000 Subject: * Making silent logoff of old hung sessions for new connections default for StandAlone users. Not touching grid. --- OpenSim/Framework/Communications/Services/LoginService.cs | 4 ++-- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 36ec26e..900a3d9 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -181,10 +181,9 @@ namespace OpenSim.Framework.Communications.Services // try to tell the region that their user is dead. LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); - // Reject the login - if (m_warn_already_logged) { + // This is behavior for for grid, reject login m_log.InfoFormat( "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", firstname, lastname); @@ -193,6 +192,7 @@ namespace OpenSim.Framework.Communications.Services } else { + // This is behavior for standalone (silent logout of last hung session) m_log.InfoFormat( "[LOGIN]: User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", firstname, lastname); diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 0cce2f0..7a622ad 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -304,7 +304,9 @@ namespace OpenSim.Framework.Communications.Tests } - [Test] + // [Test] + // Commenting out test now that LLStandAloneLoginService no longer replies with message in this case. + // Kept the code for future test with grid mode, which will keep this behavior. public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { TestHelper.InMethod(); -- cgit v1.1 From 1ad237a8a757a0e6074278aff76805d01abf0c0b Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 7 Jun 2009 19:00:55 +0000 Subject: First draft of inventory service connectors, and service implementation. No handlers yet, this is just the OUT part for now. It's not active and nothing in the simulator uses this yet. Just checking it in to start sharing with others. There are a couple of interesting software design points that could use other devs opinions. Hopefully I added all needed files. --- .../Communications/Cache/InventoryFolderImpl.cs | 470 --------------------- 1 file changed, 470 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs deleted file mode 100644 index 71f6f1b..0000000 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -//using System.Reflection; - -//using log4net; - -namespace OpenSim.Framework.Communications.Cache -{ - public class InventoryFolderImpl : InventoryFolderBase - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public static readonly string PATH_DELIMITER = "/"; - - /// - /// Items that are contained in this folder - /// - public Dictionary Items = new Dictionary(); - - /// - /// Child folders that are contained in this folder - /// - protected Dictionary m_childFolders = new Dictionary(); - - // Constructors - public InventoryFolderImpl(InventoryFolderBase folderbase) - { - Owner = folderbase.Owner; - ID = folderbase.ID; - Name = folderbase.Name; - ParentID = folderbase.ParentID; - Type = folderbase.Type; - Version = folderbase.Version; - } - - public InventoryFolderImpl() - { - } - - /// - /// Create a new subfolder. - /// - /// - /// - /// - /// The newly created subfolder. Returns null if the folder already exists - public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) - { - lock (m_childFolders) - { - if (!m_childFolders.ContainsKey(folderID)) - { - InventoryFolderImpl subFold = new InventoryFolderImpl(); - subFold.Name = folderName; - subFold.ID = folderID; - subFold.Type = (short) type; - subFold.ParentID = this.ID; - subFold.Owner = Owner; - m_childFolders.Add(subFold.ID, subFold); - - return subFold; - } - } - - return null; - } - - /// - /// Add a folder that already exists. - /// - /// - public void AddChildFolder(InventoryFolderImpl folder) - { - lock (m_childFolders) - { - folder.ParentID = ID; - m_childFolders[folder.ID] = folder; - } - } - - /// - /// Does this folder contain the given child folder? - /// - /// - /// - public bool ContainsChildFolder(UUID folderID) - { - return m_childFolders.ContainsKey(folderID); - } - - /// - /// Get a child folder - /// - /// - /// The folder if it exists, null if it doesn't - public InventoryFolderImpl GetChildFolder(UUID folderID) - { - InventoryFolderImpl folder = null; - - lock (m_childFolders) - { - m_childFolders.TryGetValue(folderID, out folder); - } - - return folder; - } - - /// - /// Removes the given child subfolder. - /// - /// - /// - /// The folder removed, or null if the folder was not present. - /// - public InventoryFolderImpl RemoveChildFolder(UUID folderID) - { - InventoryFolderImpl removedFolder = null; - - lock (m_childFolders) - { - if (m_childFolders.ContainsKey(folderID)) - { - removedFolder = m_childFolders[folderID]; - m_childFolders.Remove(folderID); - } - } - - return removedFolder; - } - - /// - /// Delete all the folders and items in this folder. - /// - public void Purge() - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - folder.Purge(); - } - - m_childFolders.Clear(); - Items.Clear(); - } - - /// - /// Returns the item if it exists in this folder or in any of this folder's descendant folders - /// - /// - /// null if the item is not found - public InventoryItemBase FindItem(UUID itemID) - { - lock (Items) - { - if (Items.ContainsKey(itemID)) - { - return Items[itemID]; - } - } - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - InventoryItemBase item = folder.FindItem(itemID); - - if (item != null) - { - return item; - } - } - } - - return null; - } - - public InventoryItemBase FindAsset(UUID assetID) - { - lock (Items) - { - foreach (InventoryItemBase item in Items.Values) - { - if (item.AssetID == assetID) - return item; - } - } - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - InventoryItemBase item = folder.FindAsset(assetID); - - if (item != null) - { - return item; - } - } - } - - return null; - } - - /// - /// Deletes an item if it exists in this folder or any children - /// - /// - /// - public bool DeleteItem(UUID itemID) - { - bool found = false; - - lock (Items) - { - if (Items.ContainsKey(itemID)) - { - Items.Remove(itemID); - return true; - } - } - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - found = folder.DeleteItem(itemID); - - if (found == true) - { - break; - } - } - } - - return found; - } - - /// - /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth - /// first. - /// - /// The requested folder if it exists, null if it does not. - public InventoryFolderImpl FindFolder(UUID folderID) - { - if (folderID == ID) - return this; - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - InventoryFolderImpl returnFolder = folder.FindFolder(folderID); - - if (returnFolder != null) - return returnFolder; - } - } - - return null; - } - - /// - /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it. - /// - /// - /// Returns null if no such folder is found - public InventoryFolderImpl FindFolderForType(int type) - { - lock (m_childFolders) - { - foreach (InventoryFolderImpl f in m_childFolders.Values) - { - if (f.Type == type) - return f; - } - } - - return null; - } - - /// - /// Find a folder given a PATH_DELIMITER delimited path starting from this folder - /// - /// - /// This method does not handle paths that contain multiple delimitors - /// - /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some - /// XPath like expression - /// - /// FIXME: Delimitors which occur in names themselves are not currently escapable. - /// - /// - /// The path to the required folder. - /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. - /// - /// null if the folder is not found - public InventoryFolderImpl FindFolderByPath(string path) - { - if (path == string.Empty) - return this; - - path = path.Trim(); - - if (path == PATH_DELIMITER) - return this; - - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - if (folder.Name == components[0]) - if (components.Length > 1) - return folder.FindFolderByPath(components[1]); - else - return folder; - } - } - - // We didn't find a folder with the given name - return null; - } - - /// - /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. - /// - /// This method does not handle paths that contain multiple delimitors - /// - /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some - /// XPath like expression - /// - /// FIXME: Delimitors which occur in names themselves are not currently escapable. - /// - /// - /// The path to the required item. - /// - /// null if the item is not found - public InventoryItemBase FindItemByPath(string path) - { - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - - if (components.Length == 1) - { - lock (Items) - { - foreach (InventoryItemBase item in Items.Values) - { - if (item.Name == components[0]) - return item; - } - } - } - else - { - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - if (folder.Name == components[0]) - return folder.FindItemByPath(components[1]); - } - } - } - - // We didn't find an item or intermediate folder with the given name - return null; - } - - /// - /// Return a copy of the list of child items in this folder. The items themselves are the originals. - /// - public List RequestListOfItems() - { - List itemList = new List(); - - lock (Items) - { - foreach (InventoryItemBase item in Items.Values) - { - itemList.Add(item); - } - } - - //m_log.DebugFormat("[INVENTORY FOLDER IMPL]: Found {0} items", itemList.Count); - - return itemList; - } - - /// - /// Return a copy of the list of child folders in this folder. The folders themselves are the originals. - /// - public List RequestListOfFolders() - { - List folderList = new List(); - - lock (m_childFolders) - { - foreach (InventoryFolderBase folder in m_childFolders.Values) - { - folderList.Add(folder); - } - } - - return folderList; - } - - public List RequestListOfFolderImpls() - { - List folderList = new List(); - - lock (m_childFolders) - { - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - folderList.Add(folder); - } - } - - return folderList; - } - - /// - /// The total number of items in this folder and in the immediate child folders (though not from other - /// descendants). - /// - public int TotalCount - { - get - { - int total = Items.Count; - - foreach (InventoryFolderImpl folder in m_childFolders.Values) - { - total = total + folder.TotalCount; - } - - return total; - } - } - } -} -- cgit v1.1 From a23d64dec1cbf88abc3c7e84664a683dee534e4a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 10 Jun 2009 04:28:56 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index cf6a798..5181bdaea 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications.Cache // Take all ther received items and put them into the folder tree heirarchy foreach (InventoryItemBase item in items) { InventoryFolderImpl folder = resolvedFolders.ContainsKey(item.Folder) ? resolvedFolders[item.Folder] : null; - ItemReceive(item, folder ); + ItemReceive(item, folder); } } catch (Exception e) diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 8061c8f..f30d28b 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Tests { UserProfileData userProfile = new UserProfileData(); -// userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); +// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); return userProfile; } -- cgit v1.1 From 0f367bd7bbc5d22d4834e1eb0f1671381485143e Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 10 Jun 2009 13:18:32 +0000 Subject: Heart surgery no.2: the inventory service hooks. Several improvements in the connectors themselves. Several improvements in configurations. Needed to add a hack in IUserService and UserManagerBase, to be removed when that service is refactored. --- .../Communications/Cache/CachedUserInfo.cs | 99 ++++------------------ .../Cache/UserProfileCacheService.cs | 10 ++- OpenSim/Framework/Communications/IUserService.cs | 6 ++ .../Communications/Tests/Cache/AssetCacheTests.cs | 6 ++ .../Framework/Communications/UserManagerBase.cs | 26 +++++- 5 files changed, 61 insertions(+), 86 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 5181bdaea..10aff42 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Reflection; using log4net; using OpenMetaverse; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Cache { @@ -62,7 +63,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// The comms manager holds references to services (user, grid, inventory, etc.) /// - private readonly CommunicationsManager m_commsManager; + private readonly IInventoryService m_InventoryService; public UserProfileData UserProfile { get { return m_userProfile; } } private UserProfileData m_userProfile; @@ -96,10 +97,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// - public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile) + public CachedUserInfo(IInventoryService invService, UserProfileData userProfile) { - m_commsManager = commsManager; m_userProfile = userProfile; + m_InventoryService = invService; } /// @@ -213,15 +214,7 @@ namespace OpenSim.Framework.Communications.Cache /// asynchronously otherwise. public void FetchInventory() { - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.RequestInventoryForUser( - UserProfile.ID, SessionID, InventoryReceive); - } - else - { - m_commsManager.InventoryService.RequestInventoryForUser(UserProfile.ID, InventoryReceive); - } + m_InventoryService.GetUserInventory(UserProfile.ID, InventoryReceive); } /// @@ -383,14 +376,8 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.AddFolder(createdBaseFolder, m_session_id); - } - else - { - m_commsManager.InventoryService.AddFolder(createdBaseFolder); - } + m_InventoryService.AddFolder(createdBaseFolder); + return true; } else @@ -449,14 +436,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Type = (short)type; baseFolder.Version = RootFolder.Version; - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.UpdateFolder(baseFolder, m_session_id); - } - else - { - m_commsManager.InventoryService.UpdateFolder(baseFolder); - } + m_InventoryService.UpdateFolder(baseFolder); folder.Name = name; folder.Type = (short)type; @@ -498,14 +478,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ID = folderID; baseFolder.ParentID = parentID; - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.MoveFolder(baseFolder, m_session_id); - } - else - { - m_commsManager.InventoryService.MoveFolder(baseFolder); - } + m_InventoryService.MoveFolder(baseFolder); InventoryFolderImpl folder = RootFolder.FindFolder(folderID); InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); @@ -568,14 +541,7 @@ namespace OpenSim.Framework.Communications.Cache purgedBaseFolder.Type = purgedFolder.Type; purgedBaseFolder.Version = purgedFolder.Version; - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.PurgeFolder(purgedBaseFolder, m_session_id); - } - else - { - m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder); - } + m_InventoryService.PurgeFolder(purgedBaseFolder); purgedFolder.Purge(); @@ -615,14 +581,7 @@ namespace OpenSim.Framework.Communications.Cache } ItemReceive(item, null); - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.AddItem(item, m_session_id); - } - else - { - m_commsManager.InventoryService.AddItem(item); - } + m_InventoryService.AddItem(item); } else { @@ -642,14 +601,7 @@ namespace OpenSim.Framework.Communications.Cache { if (m_hasReceivedInventory) { - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.UpdateItem(item, m_session_id); - } - else - { - m_commsManager.InventoryService.UpdateItem(item); - } + m_InventoryService.UpdateItem(item); } else { @@ -688,14 +640,7 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - if (m_commsManager.SecureInventoryService != null) - { - return m_commsManager.SecureInventoryService.DeleteItem(item, m_session_id); - } - else - { - return m_commsManager.InventoryService.DeleteItem(item); - } + return m_InventoryService.DeleteItem(item); } } else @@ -789,14 +734,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase itemInfo = null; - if (m_commsManager.SecureInventoryService != null) - { - itemInfo = m_commsManager.SecureInventoryService.QueryItem(item, m_session_id); - } - else - { - itemInfo = m_commsManager.InventoryService.QueryItem(item); - } + itemInfo = m_InventoryService.QueryItem(item); if (itemInfo != null) { @@ -833,14 +771,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderBase folderInfo = null; - if (m_commsManager.SecureInventoryService != null) - { - folderInfo = m_commsManager.SecureInventoryService.QueryFolder(folder, m_session_id); - } - else - { - folderInfo = m_commsManager.InventoryService.QueryFolder(folder); - } + folderInfo = m_InventoryService.QueryFolder(folder); if (folderInfo != null) { diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b7f209c..c9f5236 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Reflection; using log4net; using OpenMetaverse; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Cache { @@ -66,6 +67,8 @@ namespace OpenSim.Framework.Communications.Cache /// public readonly InventoryFolderImpl LibraryRoot; + private IInventoryService m_InventoryService; + /// /// Constructor /// @@ -77,6 +80,11 @@ namespace OpenSim.Framework.Communications.Cache LibraryRoot = libraryRootFolder; } + public void SetInventoryService(IInventoryService invService) + { + m_InventoryService = invService; + } + /// /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// @@ -200,7 +208,7 @@ namespace OpenSim.Framework.Communications.Cache /// protected CachedUserInfo AddToCaches(UserProfileData userProfile) { - CachedUserInfo createdUserInfo = new CachedUserInfo(m_commsManager, userProfile); + CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); lock (m_userProfilesById) { diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index c076ac4..725225d 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using OpenMetaverse; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications { @@ -135,5 +136,10 @@ namespace OpenSim.Framework.Communications // This probably shouldn't be here, it belongs to IAuthentication // But since Scenes only have IUserService references, I'm placing it here for now. bool VerifySession(UUID userID, UUID sessionID); + + + // Temporary Hack until we move everything to the new service model + void SetInventoryService(IInventoryService invService); + } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index f30d28b..ac0dc6d 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -33,6 +33,7 @@ using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common.Mock; namespace OpenSim.Framework.Communications.Tests @@ -143,6 +144,11 @@ namespace OpenSim.Framework.Communications.Tests { return true; } + + public void SetInventoryService(IInventoryService inv) + { + throw new NotImplementedException(); + } } } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index c3aaa4b..898239d 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -37,6 +37,7 @@ using OpenMetaverse.StructuredData; using OpenSim.Data; using OpenSim.Framework.Communications; using OpenSim.Framework.Statistics; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications { @@ -54,6 +55,7 @@ namespace OpenSim.Framework.Communications private List m_plugins = new List(); protected CommunicationsManager m_commsManager; + protected IInventoryService m_InventoryService; /// /// Constructor @@ -64,6 +66,11 @@ namespace OpenSim.Framework.Communications m_commsManager = commsManager; } + public virtual void SetInventoryService(IInventoryService invService) + { + m_InventoryService = invService; + } + /// /// Add a new user data plugin - plugins will be requested in the order they were added. /// @@ -676,7 +683,24 @@ namespace OpenSim.Framework.Communications } else { - m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID); + // + // WARNING: This is a horrible hack + // The purpose here is to avoid touching the user server at this point. + // There are dragons there that I can't deal with right now. + // diva 06/09/09 + // + if (m_InventoryService != null) + { + // local service (standalone) + m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); + m_InventoryService.CreateUserInventory(userProf.ID); + } + else + { + // used by the user server + m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); + m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID); + } return userProf.ID; } -- cgit v1.1 From f6c6e3e5f2f82f59e9abaf62e6b7cfec058123f2 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 10 Jun 2009 13:33:26 +0000 Subject: Attempt at disabling the inventory unit tests, so I can figure out how to fix them. The test setup is broken. --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 2ea81ef..55893ab 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -109,7 +109,7 @@ namespace OpenSim.Framework.Communications.Tests } */ - [Test] + //[Test] public void TestFetchInventory() { TestHelper.InMethod(); @@ -120,7 +120,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.HasReceivedInventory, Is.True); } - [Test] + //[Test] public void TestGetChildFolder() { TestHelper.InMethod(); @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); } - [Test] + //[Test] public void TestCreateFolder() { TestHelper.InMethod(); @@ -165,7 +165,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } - [Test] + //[Test] public void TestUpdateFolder() { TestHelper.InMethod(); @@ -221,7 +221,7 @@ namespace OpenSim.Framework.Communications.Tests } - [Test] + //[Test] public void TestMoveFolder() { TestHelper.InMethod(); @@ -254,7 +254,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } - [Test] + //[Test] public void TestPurgeFolder() { TestHelper.InMethod(); -- cgit v1.1 From 6ddf70b1284a1f5096a49abc77936a5f813e9f56 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 10 Jun 2009 20:31:02 +0000 Subject: Bug fix for creating users in standalone: the newly-created root folder was not being set in the cached profile. I suspect this bug has been around for a while. --- OpenSim/Framework/Communications/UserManagerBase.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 898239d..b9044eb 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -694,6 +694,9 @@ namespace OpenSim.Framework.Communications // local service (standalone) m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); m_InventoryService.CreateUserInventory(userProf.ID); + InventoryFolderBase rootfolder = m_InventoryService.RequestRootFolder(userProf.ID); + if (rootfolder != null) + userProf.RootInventoryFolderID = rootfolder.ID; } else { -- cgit v1.1 From 156604e28e51d0a7e0c8018ce10eb517a9123ce4 Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 11 Jun 2009 03:00:25 +0000 Subject: InterServiceInventoryService references *almost* completely removed from the simulator. Only a couple left, not important. Also updated the login tests -- Justin, this time I was able to fix this by myself :) --- .../Communications/Services/HGLoginAuthService.cs | 2 +- .../Communications/Services/LoginService.cs | 27 ++++- .../Communications/Tests/LoginServiceTests.cs | 125 ++++++++++++++++++++- 3 files changed, 146 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 0637a1e..8e0205c 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Services m_interServiceInventoryService = interServiceInventoryService; m_regionsConnector = regionsConnector; - m_inventoryService = interServiceInventoryService; + m_interInventoryService = interServiceInventoryService; } public void SetServersInfo(NetworkServersInfo sinfo) diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 900a3d9..7eb98d7 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -41,6 +41,7 @@ using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Services { @@ -66,7 +67,9 @@ namespace OpenSim.Framework.Communications.Services /// /// Used by the login service to make requests to the inventory service. /// - protected IInterServiceInventoryServices m_inventoryService; + protected IInterServiceInventoryServices m_interInventoryService; + // Hack + protected IInventoryService m_InventoryService; /// /// Constructor @@ -1047,7 +1050,10 @@ namespace OpenSim.Framework.Communications.Services List gestures = null; try { - gestures = m_inventoryService.GetActiveGestures(theUser.ID); + if (m_InventoryService != null) + gestures = m_InventoryService.GetActiveGestures(theUser.ID); + else + gestures = m_interInventoryService.GetActiveGestures(theUser.ID); } catch (Exception e) { @@ -1076,7 +1082,15 @@ namespace OpenSim.Framework.Communications.Services /// This will be thrown if there is a problem with the inventory service protected InventoryData GetInventorySkeleton(UUID userID) { - List folders = m_inventoryService.GetInventorySkeleton(userID); + List folders = null; + if (m_InventoryService != null) + { + folders = m_InventoryService.GetInventorySkeleton(userID); + } + else + { + folders = m_interInventoryService.GetInventorySkeleton(userID); + } // If we have user auth but no inventory folders for some reason, create a new set of folders. if (folders == null || folders.Count == 0) @@ -1088,7 +1102,7 @@ namespace OpenSim.Framework.Communications.Services // tools are creating the user profile directly in the database without creating the inventory. At // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already // exist. - if (!m_inventoryService.CreateNewUserInventory(userID)) + if ((m_interInventoryService != null) && !m_interInventoryService.CreateNewUserInventory(userID)) { throw new Exception( String.Format( @@ -1099,7 +1113,10 @@ namespace OpenSim.Framework.Communications.Services m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); - folders = m_inventoryService.GetInventorySkeleton(userID); + if (m_InventoryService != null) + folders = m_InventoryService.GetInventorySkeleton(userID); + else + folders = m_interInventoryService.GetInventorySkeleton(userID); if (folders == null || folders.Count == 0) { diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 7a622ad..d637ef0 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -39,6 +39,8 @@ using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; using OpenSim.Client.Linden; using OpenSim.Tests.Common; +using OpenSim.Services.Interfaces; +using OpenMetaverse; namespace OpenSim.Framework.Communications.Tests { @@ -73,7 +75,7 @@ namespace OpenSim.Framework.Communications.Tests m_localUserServices = (LocalUserServices) m_commsManager.UserService; m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); - m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_commsManager.InterServiceInventoryService, + m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", new TestInventoryService(), m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector); m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); @@ -88,7 +90,7 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); // We want to use our own LoginService for this test, one that // doesn't require authentication. - LoginService loginService = new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", m_commsManager.InterServiceInventoryService, + LoginService loginService = new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); Hashtable loginParams = new Hashtable(); @@ -440,4 +442,123 @@ namespace OpenSim.Framework.Communications.Tests #endregion } } + + class TestInventoryService : IInventoryService + { + public TestInventoryService() + { + } + + /// + /// + /// + /// + /// + public bool CreateUserInventory(UUID userId) + { + return false; + } + + /// + /// + /// + /// + /// + public List GetInventorySkeleton(UUID userId) + { + List folders = new List(); + InventoryFolderBase folder = new InventoryFolderBase(); + folder.ID = UUID.Random(); + folder.Owner = userId; + folders.Add(folder); + return folders; + } + + /// + /// Returns a list of all the active gestures in a user's inventory. + /// + /// + /// The of the user + /// + /// + /// A flat list of the gesture items. + /// + public List GetActiveGestures(UUID userId) + { + return null; + } + + public InventoryCollection GetUserInventory(UUID userID) + { + return null; + } + + public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) + { + } + + public List GetFolderItems(UUID folderID) + { + return null; + } + + public bool AddFolder(InventoryFolderBase folder) + { + return false; + } + + public bool UpdateFolder(InventoryFolderBase folder) + { + return false; + } + + public bool MoveFolder(InventoryFolderBase folder) + { + return false; + } + + public bool PurgeFolder(InventoryFolderBase folder) + { + return false; + } + + public bool AddItem(InventoryItemBase item) + { + return false; + } + + public bool UpdateItem(InventoryItemBase item) + { + return false; + } + + public bool DeleteItem(InventoryItemBase item) + { + return false; + } + + public InventoryItemBase QueryItem(InventoryItemBase item) + { + return null; + } + + public InventoryFolderBase QueryFolder(InventoryFolderBase folder) + { + return null; + } + + public bool HasInventoryForUser(UUID userID) + { + return false; + } + + public InventoryFolderBase RequestRootFolder(UUID userID) + { + InventoryFolderBase root = new InventoryFolderBase(); + root.ID = UUID.Random(); + root.Owner = userID; + root.ParentID = UUID.Zero; + return root; + } + } } -- cgit v1.1 From c13f3649d279bc6a55d8b1d268574577029f7c33 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Thu, 11 Jun 2009 18:27:12 +0000 Subject: * Reinstating UserProfileCacheServiceTests. One test still fails (TestUpdateFolder) --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 152 +++++++++++++-------- 1 file changed, 98 insertions(+), 54 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 55893ab..fdc20dd 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -27,10 +27,12 @@ using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; +using System.Threading; using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Setup; @@ -48,33 +50,33 @@ namespace OpenSim.Framework.Communications.Tests UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); string firstName = "Bill"; - string lastName = "Bailey"; + string lastName = "Bailey"; CachedUserInfo nonExistingUserInfo; - + TestCommunicationsManager commsManager = new TestCommunicationsManager(); - + // Check we can't retrieve info before it exists by uuid nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); - + // Check we can't retrieve info before it exists by name nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); + Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; + LocalUserServices lus = (LocalUserServices)commsManager.UserService; lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); - + CachedUserInfo existingUserInfo; - + // Check we can retrieve info by uuid existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); - - // Check we can retrieve info by name + + // Check we can retrieve info by name existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); + Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); } - + /** * Disabled as not fully implemented [Test] @@ -82,26 +84,26 @@ namespace OpenSim.Framework.Communications.Tests { UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); string firstName = "Inspector"; - string originalLastName = "Morse"; + string originalLastName = "Morse"; string newLastName = "Gadget"; - + UserProfileData newProfile = new UserProfileData(); newProfile.ID = userId; newProfile.FirstName = firstName; newProfile.SurName = newLastName; - + TestCommunicationsManager commsManager = new TestCommunicationsManager(); UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; - + // Check that we can't update info before it exists Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); - + // Check that we can update a profile once it exists - LocalUserServices lus = (LocalUserServices)commsManager.UserService; + LocalUserServices lus = (LocalUserServices)commsManager.UserService; lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); - + Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); @@ -109,59 +111,77 @@ namespace OpenSim.Framework.Communications.Tests } */ - //[Test] + [Test] public void TestFetchInventory() { TestHelper.InMethod(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - - Assert.That(userInfo.HasReceivedInventory, Is.True); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); } - //[Test] + [Test] public void TestGetChildFolder() { TestHelper.InMethod(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); } - //[Test] + [Test] public void TestCreateFolder() { TestHelper.InMethod(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); // 1: Try a folder create that should fail because the parent id given does not exist UUID missingFolderId = UUID.Random(); + InventoryFolderBase myFolder = new InventoryFolderBase(); + myFolder.ID = folderId; Assert.That( userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); - Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Null); + Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); // 2: Try a folder create that should work Assert.That( userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); - Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); + Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } @@ -170,13 +190,20 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); InventoryFolderImpl rootFolder = userInfo.RootFolder; + InventoryFolderBase myFolder = new InventoryFolderBase(); + myFolder.ID = folder1Id; userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); @@ -190,7 +217,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); - InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); + InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder); Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); } @@ -201,6 +228,9 @@ namespace OpenSim.Framework.Communications.Tests userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); + InventoryFolderBase myFolder2 = new InventoryFolderBase(); + myFolder2.ID = folder2Id; + string newFolderName2 = "newFolderName2"; ushort folderType2 = (ushort)AssetType.Bodypart; userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); @@ -213,7 +243,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); - InventoryFolderBase dataFolder1 = inventoryDataPlugin.getInventoryFolder(folder1Id); + InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder2); Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); @@ -221,15 +251,20 @@ namespace OpenSim.Framework.Communications.Tests } - //[Test] + [Test] public void TestMoveFolder() { TestHelper.InMethod(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); @@ -248,34 +283,43 @@ namespace OpenSim.Framework.Communications.Tests userInfo.MoveFolder(folderToMoveId, folder2Id); // Check folder is now in folder2 and no trace remains in folder1 + InventoryFolderBase myFolder = new InventoryFolderBase(); + myFolder.ID = folderToMoveId; Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); - Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id)); + Assert.That(myScene.InventoryService.QueryFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } - //[Test] + [Test] public void TestPurgeFolder() { TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; - - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); + Scene myScene = SceneSetupHelpers.SetupScene(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); + for (int i = 0 ; i < 50 ; i++) + { + if (userInfo.HasReceivedInventory == true) + break; + Thread.Sleep(200); + } + Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); InventoryFolderImpl rootFolder = userInfo.RootFolder; + InventoryFolderBase myFolder = new InventoryFolderBase(); + myFolder.ID = folder1Id; userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Not.Null); + Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null); // Test purge userInfo.PurgeFolder(rootFolder.ID); Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); - Assert.That(inventoryDataPlugin.getInventoryFolder(folder1Id), Is.Null); + Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); } } } -- cgit v1.1 From 2afd733229627b9ec59eb9a41e865a8d83d5d4c3 Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 11 Jun 2009 20:27:13 +0000 Subject: Fixes mantis #3803. Thanks jhurliman. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d637ef0..4070b49 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -497,7 +497,7 @@ namespace OpenSim.Framework.Communications.Tests { } - public List GetFolderItems(UUID folderID) + public List GetFolderItems(UUID userID, UUID folderID) { return null; } -- cgit v1.1 From ce7de3581cd678dd09227bdfde94fefb779f5a86 Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 17 Jun 2009 03:52:39 +0000 Subject: Implementation of a simple authentication service + in connector in route to making HGInventory (client access) work in standalone again. This is the refactoring of what was/is there, but done in the new model. Not complete yet, but key authentication works. It should be enough to make HGInventory work again soon. --- OpenSim/Framework/Communications/Services/HGLoginAuthService.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 8e0205c..f496082 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -128,6 +128,8 @@ namespace OpenSim.Framework.Communications.Services userProfile.WebLoginKey = token; m_userManager.CommitAgent(ref userProfile); } + m_log.Warn("[HGLOGIN]: Auth token: " + token); + return response; } -- cgit v1.1 From 913bc3bdb380cebebd11b657966486448962ab47 Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 18 Jun 2009 00:48:39 +0000 Subject: Moved OpenSim/Framework/Communications/Capabilities up to OpenSim/Framework/Capabilities. Didn't change the namespace because VC# is not helping, and this would imply manually changing more than 50 files. So the namespace is still OpenSim.Framework.Communications.Capabilities, to be cleaned up later by someone with more energy. --- .../Framework/Communications/Capabilities/Caps.cs | 1212 -------------------- .../Communications/Capabilities/CapsHandlers.cs | 171 --- .../Communications/Capabilities/CapsUtil.cs | 62 - .../Framework/Communications/Capabilities/LLSD.cs | 679 ----------- .../Communications/Capabilities/LLSDArray.cs | 41 - .../Capabilities/LLSDAssetUploadComplete.cs | 45 - .../Capabilities/LLSDAssetUploadRequest.cs | 46 - .../Capabilities/LLSDAssetUploadResponse.cs | 42 - .../Communications/Capabilities/LLSDCapEvent.cs | 40 - .../Communications/Capabilities/LLSDEmpty.cs | 37 - .../Communications/Capabilities/LLSDHelpers.cs | 172 --- .../Capabilities/LLSDInventoryItem.cs | 97 -- .../Communications/Capabilities/LLSDItemUpdate.cs | 41 - .../Communications/Capabilities/LLSDMapLayer.cs | 45 - .../Capabilities/LLSDMapLayerResponse.cs | 40 - .../Communications/Capabilities/LLSDMapRequest.cs | 39 - .../Communications/Capabilities/LLSDMethod.cs | 31 - .../Capabilities/LLSDMethodString.cs | 31 - .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 51 - .../Capabilities/LLSDRemoteParcelResponse.cs | 42 - .../Capabilities/LLSDStreamHandler.cs | 70 -- .../LLSDTaskInventoryUploadComplete.cs | 50 - .../Capabilities/LLSDTaskScriptUpdate.cs | 50 - .../Communications/Capabilities/LLSDTest.cs | 40 - .../Communications/Capabilities/LLSDType.cs | 55 - .../Capabilities/LLSDVoiceAccountResponse.cs | 57 - 26 files changed, 3286 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Capabilities/Caps.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/CapsUtil.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSD.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDArray.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTest.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDType.cs delete mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs deleted file mode 100644 index 8c14e1d..0000000 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ /dev/null @@ -1,1212 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Services.Interfaces; - -// using OpenSim.Region.Framework.Interfaces; - -namespace OpenSim.Framework.Communications.Capabilities -{ - public delegate void UpLoadedAsset( - string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType); - - public delegate UUID UpdateItem(UUID itemID, byte[] data); - - public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data); - - public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); - - public delegate void NewAsset(AssetBase asset); - - public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); - - public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, - bool isScriptRunning, byte[] data); - - public delegate List FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder); - - /// - /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that - /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want - /// to just pass the whole Scene into CAPS. - /// - public delegate IClientAPI GetClientDelegate(UUID agentID); - - public class Caps - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string m_httpListenerHostName; - private uint m_httpListenPort; - - /// - /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. - /// - private string m_capsObjectPath; - public string CapsObjectPath { get { return m_capsObjectPath; } } - - private CapsHandlers m_capsHandlers; - - private static readonly string m_requestPath = "0000/"; - // private static readonly string m_mapLayerPath = "0001/"; - private static readonly string m_newInventory = "0002/"; - //private static readonly string m_requestTexture = "0003/"; - private static readonly string m_notecardUpdatePath = "0004/"; - private static readonly string m_notecardTaskUpdatePath = "0005/"; - // private static readonly string m_fetchInventoryPath = "0006/"; - - // The following entries are in a module, however, they are also here so that we don't re-assign - // the path to another cap by mistake. - // private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; // This is in a module. - // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. - - // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. - - //private string eventQueue = "0100/"; - private IHttpServer m_httpListener; - private UUID m_agentID; - private IAssetService m_assetCache; - private int m_eventQueueCount = 1; - private Queue m_capsEventQueue = new Queue(); - private bool m_dumpAssetsToFile; - private string m_regionName; - - public bool SSLCaps - { - get { return m_httpListener.UseSSL; } - } - public string SSLCommonName - { - get { return m_httpListener.SSLCommonName; } - } - public CapsHandlers CapsHandlers - { - get { return m_capsHandlers; } - } - - // These are callbacks which will be setup by the scene so that we can update scene data when we - // receive capability calls - public NewInventoryItem AddNewInventoryItem = null; - public NewAsset AddNewAsset = null; - public ItemUpdatedCallback ItemUpdatedCall = null; - public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; - public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; - public GetClientDelegate GetClient = null; - - public Caps(IAssetService assetCache, IHttpServer httpServer, string httpListen, uint httpPort, string capsPath, - UUID agent, bool dumpAssetsToFile, string regionName) - { - m_assetCache = assetCache; - m_capsObjectPath = capsPath; - m_httpListener = httpServer; - m_httpListenerHostName = httpListen; - - m_httpListenPort = httpPort; - - if (httpServer.UseSSL) - { - m_httpListenPort = httpServer.SSLPort; - httpListen = httpServer.SSLCommonName; - httpPort = httpServer.SSLPort; - } - - m_agentID = agent; - m_dumpAssetsToFile = dumpAssetsToFile; - m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL); - m_regionName = regionName; - } - - /// - /// Register all CAPS http service handlers - /// - public void RegisterHandlers() - { - DeregisterHandlers(); - - string capsBase = "/CAPS/" + m_capsObjectPath; - - RegisterRegionServiceHandlers(capsBase); - RegisterInventoryServiceHandlers(capsBase); - - } - - public void RegisterRegionServiceHandlers(string capsBase) - { - try - { - // the root of all evil - m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); - m_log.DebugFormat( - "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); - - //m_capsHandlers["MapLayer"] = - // new LLSDStreamhandler("POST", - // capsBase + m_mapLayerPath, - // GetMapLayer); - m_capsHandlers["UpdateScriptTaskInventory"] = - new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); - m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; - - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - } - - public void RegisterInventoryServiceHandlers(string capsBase) - { - try - { - // I don't think this one works... - m_capsHandlers["NewFileAgentInventory"] = - new LLSDStreamhandler("POST", - capsBase + m_newInventory, - NewAgentInventoryRequest); - m_capsHandlers["UpdateNotecardAgentInventory"] = - new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); - m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; - m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; - - // As of RC 1.22.9 of the Linden client this is - // supported - - // m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); - - // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and - // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires - // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, - // but when I went on the Linden grid, the - // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, - // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP - // - // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid - // we will be - // able to get the data we need to implement the necessary part of the protocol to fix the issue above. - // m_capsHandlers["FetchInventoryDescendents"] = - // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); - - // m_capsHandlers["FetchInventoryDescendents"] = - // new LLSDStreamhandler("POST", - // capsBase + m_fetchInventory, - // FetchInventory)); - // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", - // capsBase + m_requestTexture, - // RequestTexture); - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - } - - /// - /// Register a handler. This allows modules to register handlers. - /// - /// - /// - public void RegisterHandler(string capName, IRequestHandler handler) - { - m_capsHandlers[capName] = handler; - //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); - } - - /// - /// Remove all CAPS service handlers. - /// - /// - /// - /// - /// - public void DeregisterHandlers() - { - if (m_capsHandlers != null) - { - foreach (string capsName in m_capsHandlers.Caps) - { - m_capsHandlers.Remove(capsName); - } - } - } - - /// - /// Construct a client response detailing all the capabilities this server can provide. - /// - /// - /// - /// - /// HTTP request header object - /// HTTP response header object - /// - public string CapsRequest(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - //m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); - - string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); - - //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); - - return result; - } - - // FIXME: these all should probably go into the respective region - // modules - - /// - /// Processes a fetch inventory request and sends the reply - - /// - /// - /// - /// - /// - // Request is like: - // - // folders - // - // - // fetch-folders1fetch-items1folder-id8e1e3a30-b9bf-11dc-95ff-0800200c9a66owner-id11111111-1111-0000-0000-000100bba000sort-order1 - // - // - // - // - // - // multiple fetch-folder maps are allowed within the larger folders map. - public string FetchInventoryRequest(string request, string path, string param) - { - // string unmodifiedRequest = request.ToString(); - - //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); - m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName); - - Hashtable hash = new Hashtable(); - try - { - hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); - } - catch (LLSD.LLSDParseException pe) - { - m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); - m_log.Error("Request: " + request.ToString()); - } - - ArrayList foldersrequested = (ArrayList)hash["folders"]; - - string response = ""; - - for (int i = 0; i < foldersrequested.Count; i++) - { - string inventoryitemstr = ""; - Hashtable inventoryhash = (Hashtable)foldersrequested[i]; - - LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); - LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); - - inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); - inventoryitemstr = inventoryitemstr.Replace("folders", ""); - inventoryitemstr = inventoryitemstr.Replace("", ""); - - response += inventoryitemstr; - } - - if (response.Length == 0) - { - // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. - // Therefore, I'm concluding that the client only has so many threads available to do requests - // and when a thread stalls.. is stays stalled. - // Therefore we need to return something valid - response = "folders"; - } - else - { - response = "folders" + response + ""; - } - - //m_log.DebugFormat("[AGENT INVENTORY]: Replying to CAPS fetch inventory request with following xml"); - //m_log.Debug(Util.GetFormattedXml(response)); - - return response; - } - - public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - // m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request); - - // nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us - // correctly mark it as a uuid - request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); - - // another hack 1 results in a System.ArgumentException: Object type System.Int32 cannot be converted to target type: System.Boolean - request = request.Replace("fetch_folders0", "fetch_folders0"); - request = request.Replace("fetch_folders1", "fetch_folders1"); - Hashtable hash = new Hashtable(); - try - { - hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); - } - catch (LLSD.LLSDParseException pe) - { - m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); - m_log.Error("Request: " + request.ToString()); - } - - ArrayList foldersrequested = (ArrayList)hash["folders"]; - - string response = ""; - for (int i = 0; i < foldersrequested.Count; i++) - { - string inventoryitemstr = ""; - Hashtable inventoryhash = (Hashtable)foldersrequested[i]; - - LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); - - try{ - LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); - } - catch(Exception e) - { - m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); - } - LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); - - inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); - inventoryitemstr = inventoryitemstr.Replace("folders", ""); - inventoryitemstr = inventoryitemstr.Replace("", ""); - - response += inventoryitemstr; - } - - - if (response.Length == 0) - { - // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. - // Therefore, I'm concluding that the client only has so many threads available to do requests - // and when a thread stalls.. is stays stalled. - // Therefore we need to return something valid - response = "folders"; - } - else - { - response = "folders" + response + ""; - } - - //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); - //m_log.Debug("[CAPS] "+response); - - return response; - } - - - - /// - /// Construct an LLSD reply packet to a CAPS inventory request - /// - /// - /// - private LLSDInventoryDescendents FetchInventoryReply(LLSDFetchInventoryDescendents invFetch) - { - LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); - LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); - contents.agent_id = m_agentID; - contents.owner_id = invFetch.owner_id; - contents.folder_id = invFetch.folder_id; - - // The version number being sent back was originally 1. - // Unfortunately, on 1.19.1.4, this means that we see a problem where on subsequent logins - // without clearing client cache, objects in the root folder disappear until the cache is cleared, - // at which point they reappear. - // - // Seeing the version to something other than 0 may be the right thing to do, but there is - // a greater subtlety of the second life protocol that needs to be understood first. - contents.version = 0; - - contents.descendents = 0; - reply.folders.Array.Add(contents); - List itemList = null; - if (CAPSFetchInventoryDescendents != null) - { - itemList = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order); - } - - if (itemList != null) - { - foreach (InventoryItemBase invItem in itemList) - { - contents.items.Array.Add(ConvertInventoryItem(invItem)); - } - } - /* The following block is removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to - find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000.... - else - { - IClientAPI client = GetClient(m_agentID); - - // We're going to both notify the client of inventory service failure and send back a 'no folder contents' response. - // If we don't send back the response, - // the client becomes unhappy (see Teravus' comment in FetchInventoryRequest()) - if (client != null) - { - client.SendAgentAlertMessage( - "AGIN0001E: The inventory service has either failed or is not responding. Your inventory will not function properly for the rest of this session. Please clear your cache and relog.", - true); - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure", - m_agentID); - } - }*/ - - contents.descendents = contents.items.Array.Count; - return reply; - } - - /// - /// Convert an internal inventory item object into an LLSD object. - /// - /// - /// - private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) - { - LLSDInventoryItem llsdItem = new LLSDInventoryItem(); - llsdItem.asset_id = invItem.AssetID; - llsdItem.created_at = invItem.CreationDate; - llsdItem.desc = invItem.Description; - llsdItem.flags = 0; - llsdItem.item_id = invItem.ID; - llsdItem.name = invItem.Name; - llsdItem.parent_id = invItem.Folder; - try - { - // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions. - llsdItem.type = TaskInventoryItem.Types[invItem.AssetType]; - llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType]; - } - catch (Exception e) - { - m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e); - } - llsdItem.permissions = new LLSDPermissions(); - llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; - llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; - llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; - llsdItem.permissions.group_id = UUID.Zero; - llsdItem.permissions.group_mask = 0; - llsdItem.permissions.is_owner_group = false; - llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; - llsdItem.permissions.owner_id = m_agentID; // FixMe - llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; - llsdItem.sale_info = new LLSDSaleInfo(); - llsdItem.sale_info.sale_price = 10; - llsdItem.sale_info.sale_type = "not"; - - return llsdItem; - } - - /// - /// - /// - /// - /// - public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) - { - m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName); - LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); - return mapResponse; - } - - /// - /// - /// - /// - protected static OSDMapLayer GetOSDMapLayerResponse() - { - OSDMapLayer mapLayer = new OSDMapLayer(); - mapLayer.Right = 5000; - mapLayer.Top = 5000; - mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); - - return mapLayer; - } - - /// - /// - /// - /// - /// - /// - /// - public string RequestTexture(string request, string path, string param) - { - m_log.Debug("texture request " + request); - // Needs implementing (added to remove compiler warning) - return String.Empty; - } - - #region EventQueue (Currently not enabled) - - /// - /// - /// - /// - /// - /// - /// - public string ProcessEventQueue(string request, string path, string param) - { - string res = String.Empty; - - if (m_capsEventQueue.Count > 0) - { - lock (m_capsEventQueue) - { - string item = m_capsEventQueue.Dequeue(); - res = item; - } - } - else - { - res = CreateEmptyEventResponse(); - } - return res; - } - - /// - /// - /// - /// - /// - /// - public string CreateEstablishAgentComms(string caps, string ipAddressPort) - { - LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = m_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); - m_eventQueueCount++; - - m_capsEventQueue.Enqueue(res); - return res; - } - - /// - /// - /// - /// - public string CreateEmptyEventResponse() - { - LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = m_eventQueueCount; - eventItem.events.Array.Add(new LLSDEmpty()); - string res = LLSDHelpers.SerialiseLLSDReply(eventItem); - m_eventQueueCount++; - return res; - } - - #endregion - - /// - /// Called by the script task update handler. Provides a URL to which the client can upload a new asset. - /// - /// - /// - /// - /// HTTP request header object - /// HTTP response header object - /// - public string ScriptTaskInventory(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - try - { - m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName); - //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); - LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest); - - string capsBase = "/CAPS/" + m_capsObjectPath; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - TaskInventoryScriptUpdater uploader = - new TaskInventoryScriptUpdater( - llsdUpdateRequest.item_id, - llsdUpdateRequest.task_id, - llsdUpdateRequest.is_script_running, - capsBase + uploaderPath, - m_httpListener, - m_dumpAssetsToFile); - uploader.OnUpLoad += TaskScriptUpdated; - - m_httpListener.AddStreamHandler( - new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - - string protocol = "http://"; - - if (m_httpListener.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + - uploaderPath; - - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; - uploadResponse.state = "upload"; - -// m_log.InfoFormat("[CAPS]: " + -// "ScriptTaskInventory response: {0}", -// LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply(uploadResponse); - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - - return null; - } - - /// - /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. - /// - /// - /// - /// - /// - public string NoteCardAgentInventory(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); - //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); - - //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request)); - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Utils.StringToBytes(request)); - LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); - LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest); - - string capsBase = "/CAPS/" + m_capsObjectPath; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - ItemUpdater uploader = - new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); - uploader.OnUpLoad += ItemUpdated; - - m_httpListener.AddStreamHandler( - new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - - string protocol = "http://"; - - if (m_httpListener.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + - uploaderPath; - - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; - uploadResponse.state = "upload"; - -// m_log.InfoFormat("[CAPS]: " + -// "NoteCardAgentInventory response: {0}", -// LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply(uploadResponse); - } - - /// - /// - /// - /// - /// - public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) - { - //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); - //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); - - if (llsdRequest.asset_type == "texture" || - llsdRequest.asset_type == "animation" || - llsdRequest.asset_type == "sound") - { - IClientAPI client = null; - IScene scene = null; - if (GetClient != null) - { - client = GetClient(m_agentID); - scene = client.Scene; - - IMoneyModule mm = scene.RequestModuleInterface(); - - if (mm != null) - { - if (!mm.UploadCovered(client)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - } - } - - - string assetName = llsdRequest.name; - string assetDes = llsdRequest.description; - string capsBase = "/CAPS/" + m_capsObjectPath; - UUID newAsset = UUID.Random(); - UUID newInvItem = UUID.Random(); - UUID parentFolder = llsdRequest.folder_id; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - AssetUploader uploader = - new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); - m_httpListener.AddStreamHandler( - new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - - string protocol = "http://"; - - if (m_httpListener.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + - uploaderPath; - - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; - uploadResponse.state = "upload"; - uploader.OnUpLoad += UploadCompleteHandler; - return uploadResponse; - } - - /// - /// - /// - /// - /// - /// - public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) - { - sbyte assType = 0; - sbyte inType = 0; - - if (inventoryType == "sound") - { - inType = 1; - assType = 1; - } - else if (inventoryType == "animation") - { - inType = 19; - assType = 20; - } - else if (inventoryType == "wearable") - { - inType = 18; - switch (assetType) - { - case "bodypart": - assType = 13; - break; - case "clothing": - assType = 5; - break; - } - } - - AssetBase asset; - asset = new AssetBase(); - asset.FullID = assetID; - asset.Type = assType; - asset.Name = assetName; - asset.Data = data; - if (AddNewAsset != null) - AddNewAsset(asset); - else if (m_assetCache != null) - m_assetCache.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Owner = m_agentID; - item.CreatorId = m_agentID.ToString(); - item.ID = inventoryItem; - item.AssetID = asset.FullID; - item.Description = assetDescription; - item.Name = assetName; - item.AssetType = assType; - item.InvType = inType; - item.Folder = parentFolder; - item.CurrentPermissions = 2147483647; - item.BasePermissions = 2147483647; - item.EveryOnePermissions = 0; - item.NextPermissions = 2147483647; - item.CreationDate = Util.UnixTimeSinceEpoch(); - - if (AddNewInventoryItem != null) - { - AddNewInventoryItem(m_agentID, item); - } - } - - /// - /// Called when new asset data for an agent inventory item update has been uploaded. - /// - /// Item to update - /// New asset data - /// - public UUID ItemUpdated(UUID itemID, byte[] data) - { - if (ItemUpdatedCall != null) - { - return ItemUpdatedCall(m_agentID, itemID, data); - } - - return UUID.Zero; - } - - /// - /// Called when new asset data for an agent inventory item update has been uploaded. - /// - /// Item to update - /// Prim containing item to update - /// Signals whether the script to update is currently running - /// New asset data - public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data) - { - if (TaskScriptUpdatedCall != null) - { - TaskScriptUpdatedCall(m_agentID, itemID, primID, isScriptRunning, data); - } - } - - public class AssetUploader - { - public event UpLoadedAsset OnUpLoad; - private UpLoadedAsset handlerUpLoad = null; - - private string uploaderPath = String.Empty; - private UUID newAssetID; - private UUID inventoryItemID; - private UUID parentFolder; - private IHttpServer httpListener; - private bool m_dumpAssetsToFile; - private string m_assetName = String.Empty; - private string m_assetDes = String.Empty; - - private string m_invType = String.Empty; - private string m_assetType = String.Empty; - - public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, - UUID parentFolderID, string invType, string assetType, string path, - IHttpServer httpServer, bool dumpAssetsToFile) - { - m_assetName = assetName; - m_assetDes = description; - newAssetID = assetID; - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - parentFolder = parentFolderID; - m_assetType = assetType; - m_invType = invType; - m_dumpAssetsToFile = dumpAssetsToFile; - } - - /// - /// - /// - /// - /// - /// - /// - public string uploaderCaps(byte[] data, string path, string param) - { - UUID inv = inventoryItemID; - string res = String.Empty; - LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); - uploadComplete.new_asset = newAssetID.ToString(); - uploadComplete.new_inventory_item = inv; - uploadComplete.state = "complete"; - - res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - - httpListener.RemoveStreamHandler("POST", uploaderPath); - - // TODO: probably make this a better set of extensions here - string extension = ".jp2"; - if (m_invType != "image") - { - extension = ".dat"; - } - - if (m_dumpAssetsToFile) - { - SaveAssetToFile(m_assetName + extension, data); - } - handlerUpLoad = OnUpLoad; - if (handlerUpLoad != null) - { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); - } - - return res; - } - ///Left this in and commented in case there are unforseen issues - //private void SaveAssetToFile(string filename, byte[] data) - //{ - // FileStream fs = File.Create(filename); - // BinaryWriter bw = new BinaryWriter(fs); - // bw.Write(data); - // bw.Close(); - // fs.Close(); - //} - private static void SaveAssetToFile(string filename, byte[] data) - { - string assetPath = "UserAssets"; - if (!Directory.Exists(assetPath)) - { - Directory.CreateDirectory(assetPath); - } - FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename))); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); - } - } - - /// - /// This class is a callback invoked when a client sends asset data to - /// an agent inventory notecard update url - /// - public class ItemUpdater - { - public event UpdateItem OnUpLoad; - - private UpdateItem handlerUpdateItem = null; - - private string uploaderPath = String.Empty; - private UUID inventoryItemID; - private IHttpServer httpListener; - private bool m_dumpAssetToFile; - - public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile) - { - m_dumpAssetToFile = dumpAssetToFile; - - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - } - - /// - /// - /// - /// - /// - /// - /// - public string uploaderCaps(byte[] data, string path, string param) - { - UUID inv = inventoryItemID; - string res = String.Empty; - LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); - UUID assetID = UUID.Zero; - handlerUpdateItem = OnUpLoad; - if (handlerUpdateItem != null) - { - assetID = handlerUpdateItem(inv, data); - } - - uploadComplete.new_asset = assetID.ToString(); - uploadComplete.new_inventory_item = inv; - uploadComplete.state = "complete"; - - res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - - httpListener.RemoveStreamHandler("POST", uploaderPath); - - if (m_dumpAssetToFile) - { - SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); - } - - return res; - } - ///Left this in and commented in case there are unforseen issues - //private void SaveAssetToFile(string filename, byte[] data) - //{ - // FileStream fs = File.Create(filename); - // BinaryWriter bw = new BinaryWriter(fs); - // bw.Write(data); - // bw.Close(); - // fs.Close(); - //} - private static void SaveAssetToFile(string filename, byte[] data) - { - string assetPath = "UserAssets"; - if (!Directory.Exists(assetPath)) - { - Directory.CreateDirectory(assetPath); - } - FileStream fs = File.Create(Path.Combine(assetPath, filename)); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); - } - } - - /// - /// This class is a callback invoked when a client sends asset data to - /// a task inventory script update url - /// - public class TaskInventoryScriptUpdater - { - public event UpdateTaskScript OnUpLoad; - - private UpdateTaskScript handlerUpdateTaskScript = null; - - private string uploaderPath = String.Empty; - private UUID inventoryItemID; - private UUID primID; - private bool isScriptRunning; - private IHttpServer httpListener; - private bool m_dumpAssetToFile; - - public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, - string path, IHttpServer httpServer, bool dumpAssetToFile) - { - m_dumpAssetToFile = dumpAssetToFile; - - this.inventoryItemID = inventoryItemID; - this.primID = primID; - - // This comes in over the packet as an integer, but actually appears to be treated as a bool - this.isScriptRunning = (0 == isScriptRunning ? false : true); - - uploaderPath = path; - httpListener = httpServer; - } - - /// - /// - /// - /// - /// - /// - /// - public string uploaderCaps(byte[] data, string path, string param) - { - try - { -// m_log.InfoFormat("[CAPS]: " + -// "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", -// data, path, param)); - - string res = String.Empty; - LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); - - handlerUpdateTaskScript = OnUpLoad; - if (handlerUpdateTaskScript != null) - { - handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data); - } - - uploadComplete.item_id = inventoryItemID; - uploadComplete.task_id = primID; - uploadComplete.state = "complete"; - - res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - - httpListener.RemoveStreamHandler("POST", uploaderPath); - - if (m_dumpAssetToFile) - { - SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); - } - -// m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); - - return res; - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - - // XXX Maybe this should be some meaningful error packet - return null; - } - ///Left this in and commented in case there are unforseen issues - //private void SaveAssetToFile(string filename, byte[] data) - //{ - // FileStream fs = File.Create(filename); - // BinaryWriter bw = new BinaryWriter(fs); - // bw.Write(data); - // bw.Close(); - // fs.Close(); - //} - private static void SaveAssetToFile(string filename, byte[] data) - { - string assetPath = "UserAssets"; - if (!Directory.Exists(assetPath)) - { - Directory.CreateDirectory(assetPath); - } - FileStream fs = File.Create(Path.Combine(assetPath, filename)); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); - } - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs deleted file mode 100644 index cc44023..0000000 --- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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; -using System.Collections.Generic; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework.Communications.Capabilities -{ - /// - /// CapsHandlers is a cap handler container but also takes - /// care of adding and removing cap handlers to and from the - /// supplied BaseHttpServer. - /// - public class CapsHandlers - { - private Dictionary m_capsHandlers = new Dictionary(); - private IHttpServer m_httpListener; - private string m_httpListenerHostName; - private uint m_httpListenerPort; - private bool m_useSSL = false; - - /// - /// CapsHandlers is a cap handler container but also takes - /// care of adding and removing cap handlers to and from the - /// supplied BaseHttpServer. - /// - /// base HTTP server - /// host name of the HTTP - /// server - /// HTTP port - public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) - : this (httpListener,httpListenerHostname,httpListenerPort, false) - { - } - - /// - /// CapsHandlers is a cap handler container but also takes - /// care of adding and removing cap handlers to and from the - /// supplied BaseHttpServer. - /// - /// base HTTP server - /// host name of the HTTP - /// server - /// HTTP port - public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) - { - m_httpListener = httpListener; - m_httpListenerHostName = httpListenerHostname; - m_httpListenerPort = httpListenerPort; - m_useSSL = https; - if (m_useSSL) - { - m_httpListenerHostName = httpListener.SSLCommonName; - m_httpListenerPort = httpListener.SSLPort; - } - } - - /// - /// Remove the cap handler for a capability. - /// - /// name of the capability of the cap - /// handler to be removed - public void Remove(string capsName) - { - // This line must be here, or caps will break! - m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); - m_capsHandlers.Remove(capsName); - } - - public bool ContainsCap(string cap) - { - return m_capsHandlers.ContainsKey(cap); - } - - /// - /// The indexer allows us to treat the CapsHandlers object - /// in an intuitive dictionary like way. - /// - /// - /// The indexer will throw an exception when you try to - /// retrieve a cap handler for a cap that is not contained in - /// CapsHandlers. - /// - public IRequestHandler this[string idx] - { - get - { - return m_capsHandlers[idx]; - } - - set - { - if (m_capsHandlers.ContainsKey(idx)) - { - m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); - m_capsHandlers.Remove(idx); - } - - if (null == value) return; - - m_capsHandlers[idx] = value; - m_httpListener.AddStreamHandler(value); - } - } - - /// - /// Return the list of cap names for which this CapsHandlers - /// object contains cap handlers. - /// - public string[] Caps - { - get - { - string[] __keys = new string[m_capsHandlers.Keys.Count]; - m_capsHandlers.Keys.CopyTo(__keys, 0); - return __keys; - } - } - - /// - /// Return an LLSD-serializable Hashtable describing the - /// capabilities and their handler details. - /// - public Hashtable CapsDetails - { - get - { - Hashtable caps = new Hashtable(); - string protocol = "http://"; - - if (m_useSSL) - protocol = "https://"; - - string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); - foreach (string capsName in m_capsHandlers.Keys) - { - // skip SEED cap - if ("SEED" == capsName) continue; - caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; - } - return caps; - } - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs b/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs deleted file mode 100644 index a90eaa9..0000000 --- a/OpenSim/Framework/Communications/Capabilities/CapsUtil.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - /// - /// Capabilities utility methods - /// - public class CapsUtil - { - /// - /// Generate a CAPS seed path using a previously generated CAPS object path component - /// - /// - /// - public static string GetCapsSeedPath(string capsObjectPath) - { - return "/CAPS/" + capsObjectPath + "0000/"; - } - - /// - /// Get a random CAPS object path component that will be used as the identifying part of all future CAPS requests - /// - /// - public static string GetRandomCapsObjectPath() - { - UUID caps = UUID.Random(); - string capsPath = caps.ToString(); - // I'm commenting this, rather than delete, to keep as historical record. - // The caps seed is now a full UUID string that gets added four more digits - // for producing certain CAPs URLs in OpenSim - //capsPath = capsPath.Remove(capsPath.Length - 4, 4); - return capsPath; - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs deleted file mode 100644 index c982092..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ /dev/null @@ -1,679 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Globalization; -using System.IO; -using System.Security.Cryptography; -using System.Text; -using System.Xml; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - /// - /// Borrowed from (a older version of) libsl for now, as their new llsd code doesn't work we our decoding code. - /// - public static class LLSD - { - /// - /// - /// - public class LLSDParseException : Exception - { - public LLSDParseException(string message) : base(message) - { - } - } - - /// - /// - /// - public class LLSDSerializeException : Exception - { - public LLSDSerializeException(string message) : base(message) - { - } - } - - /// - /// - /// - /// - /// - public static object LLSDDeserialize(byte[] b) - { - return LLSDDeserialize(new MemoryStream(b, false)); - } - - /// - /// - /// - /// - /// - public static object LLSDDeserialize(Stream st) - { - XmlTextReader reader = new XmlTextReader(st); - reader.Read(); - SkipWS(reader); - - if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd") - throw new LLSDParseException("Expected "); - - reader.Read(); - object ret = LLSDParseOne(reader); - SkipWS(reader); - - if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd") - throw new LLSDParseException("Expected "); - - return ret; - } - - /// - /// - /// - /// - /// - public static byte[] LLSDSerialize(object obj) - { - StringWriter sw = new StringWriter(); - XmlTextWriter writer = new XmlTextWriter(sw); - writer.Formatting = Formatting.None; - - writer.WriteStartElement(String.Empty, "llsd", String.Empty); - LLSDWriteOne(writer, obj); - writer.WriteEndElement(); - - writer.Close(); - - return Encoding.UTF8.GetBytes(sw.ToString()); - } - - /// - /// - /// - /// - /// - public static void LLSDWriteOne(XmlTextWriter writer, object obj) - { - if (obj == null) - { - writer.WriteStartElement(String.Empty, "undef", String.Empty); - writer.WriteEndElement(); - return; - } - - if (obj is string) - { - writer.WriteStartElement(String.Empty, "string", String.Empty); - writer.WriteString((string) obj); - writer.WriteEndElement(); - } - else if (obj is int) - { - writer.WriteStartElement(String.Empty, "integer", String.Empty); - writer.WriteString(obj.ToString()); - writer.WriteEndElement(); - } - else if (obj is double) - { - writer.WriteStartElement(String.Empty, "real", String.Empty); - writer.WriteString(obj.ToString()); - writer.WriteEndElement(); - } - else if (obj is bool) - { - bool b = (bool) obj; - writer.WriteStartElement(String.Empty, "boolean", String.Empty); - writer.WriteString(b ? "1" : "0"); - writer.WriteEndElement(); - } - else if (obj is ulong) - { - throw new Exception("ulong in LLSD is currently not implemented, fix me!"); - } - else if (obj is UUID) - { - UUID u = (UUID) obj; - writer.WriteStartElement(String.Empty, "uuid", String.Empty); - writer.WriteString(u.ToString()); - writer.WriteEndElement(); - } - else if (obj is Hashtable) - { - Hashtable h = obj as Hashtable; - writer.WriteStartElement(String.Empty, "map", String.Empty); - foreach (string key in h.Keys) - { - writer.WriteStartElement(String.Empty, "key", String.Empty); - writer.WriteString(key); - writer.WriteEndElement(); - LLSDWriteOne(writer, h[key]); - } - writer.WriteEndElement(); - } - else if (obj is ArrayList) - { - ArrayList a = obj as ArrayList; - writer.WriteStartElement(String.Empty, "array", String.Empty); - foreach (object item in a) - { - LLSDWriteOne(writer, item); - } - writer.WriteEndElement(); - } - else if (obj is byte[]) - { - byte[] b = obj as byte[]; - writer.WriteStartElement(String.Empty, "binary", String.Empty); - - writer.WriteStartAttribute(String.Empty, "encoding", String.Empty); - writer.WriteString("base64"); - writer.WriteEndAttribute(); - - //// Calculate the length of the base64 output - //long length = (long)(4.0d * b.Length / 3.0d); - //if (length % 4 != 0) length += 4 - (length % 4); - - //// Create the char[] for base64 output and fill it - //char[] tmp = new char[length]; - //int i = Convert.ToBase64CharArray(b, 0, b.Length, tmp, 0); - - //writer.WriteString(new String(tmp)); - - writer.WriteString(Convert.ToBase64String(b)); - writer.WriteEndElement(); - } - else - { - throw new LLSDSerializeException("Unknown type " + obj.GetType().Name); - } - } - - /// - /// - /// - /// - /// - public static object LLSDParseOne(XmlTextReader reader) - { - SkipWS(reader); - if (reader.NodeType != XmlNodeType.Element) - throw new LLSDParseException("Expected an element"); - - string dtype = reader.LocalName; - object ret = null; - - switch (dtype) - { - case "undef": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return null; - } - - reader.Read(); - SkipWS(reader); - ret = null; - break; - } - case "boolean": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return false; - } - - reader.Read(); - string s = reader.ReadString().Trim(); - - if (s == String.Empty || s == "false" || s == "0") - ret = false; - else if (s == "true" || s == "1") - ret = true; - else - throw new LLSDParseException("Bad boolean value " + s); - - break; - } - case "integer": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return 0; - } - - reader.Read(); - ret = Convert.ToInt32(reader.ReadString().Trim()); - break; - } - case "real": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return 0.0f; - } - - reader.Read(); - ret = Convert.ToDouble(reader.ReadString().Trim()); - break; - } - case "uuid": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return UUID.Zero; - } - - reader.Read(); - ret = new UUID(reader.ReadString().Trim()); - break; - } - case "string": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return String.Empty; - } - - reader.Read(); - ret = reader.ReadString(); - break; - } - case "binary": - { - if (reader.IsEmptyElement) - { - reader.Read(); - return new byte[0]; - } - - if (reader.GetAttribute("encoding") != null && - reader.GetAttribute("encoding") != "base64") - { - throw new LLSDParseException("Unknown encoding: " + reader.GetAttribute("encoding")); - } - - reader.Read(); - FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); - byte[] inp = Encoding.UTF8.GetBytes(reader.ReadString()); - ret = b64.TransformFinalBlock(inp, 0, inp.Length); - break; - } - case "date": - { - reader.Read(); - throw new Exception("LLSD TODO: date"); - } - case "map": - { - return LLSDParseMap(reader); - } - case "array": - { - return LLSDParseArray(reader); - } - default: - throw new LLSDParseException("Unknown element <" + dtype + ">"); - } - - if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != dtype) - { - throw new LLSDParseException("Expected "); - } - - reader.Read(); - return ret; - } - - /// - /// - /// - /// - /// - public static Hashtable LLSDParseMap(XmlTextReader reader) - { - Hashtable ret = new Hashtable(); - - if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "map") - throw new LLSDParseException("Expected "); - - if (reader.IsEmptyElement) - { - reader.Read(); - return ret; - } - - reader.Read(); - - while (true) - { - SkipWS(reader); - if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "map") - { - reader.Read(); - break; - } - - if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "key") - throw new LLSDParseException("Expected "); - - string key = reader.ReadString(); - - if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "key") - throw new LLSDParseException("Expected "); - - reader.Read(); - object val = LLSDParseOne(reader); - ret[key] = val; - } - - return ret; // TODO - } - - /// - /// - /// - /// - /// - public static ArrayList LLSDParseArray(XmlTextReader reader) - { - ArrayList ret = new ArrayList(); - - if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "array") - throw new LLSDParseException("Expected "); - - if (reader.IsEmptyElement) - { - reader.Read(); - return ret; - } - - reader.Read(); - - while (true) - { - SkipWS(reader); - - if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "array") - { - reader.Read(); - break; - } - - ret.Insert(ret.Count, LLSDParseOne(reader)); - } - - return ret; // TODO - } - - /// - /// - /// - /// - /// - private static string GetSpaces(int count) - { - StringBuilder b = new StringBuilder(); - for (int i = 0; i < count; i++) b.Append(" "); - return b.ToString(); - } - - /// - /// - /// - /// - /// - /// - public static String LLSDDump(object obj, int indent) - { - if (obj == null) - { - return GetSpaces(indent) + "- undef\n"; - } - else if (obj is string) - { - return GetSpaces(indent) + "- string \"" + (string) obj + "\"\n"; - } - else if (obj is int) - { - return GetSpaces(indent) + "- integer " + obj.ToString() + "\n"; - } - else if (obj is double) - { - return GetSpaces(indent) + "- float " + obj.ToString() + "\n"; - } - else if (obj is UUID) - { - return GetSpaces(indent) + "- uuid " + ((UUID) obj).ToString() + Environment.NewLine; - } - else if (obj is Hashtable) - { - StringBuilder ret = new StringBuilder(); - ret.Append(GetSpaces(indent) + "- map" + Environment.NewLine); - Hashtable map = (Hashtable) obj; - - foreach (string key in map.Keys) - { - ret.Append(GetSpaces(indent + 2) + "- key \"" + key + "\"" + Environment.NewLine); - ret.Append(LLSDDump(map[key], indent + 3)); - } - - return ret.ToString(); - } - else if (obj is ArrayList) - { - StringBuilder ret = new StringBuilder(); - ret.Append(GetSpaces(indent) + "- array\n"); - ArrayList list = (ArrayList) obj; - - foreach (object item in list) - { - ret.Append(LLSDDump(item, indent + 2)); - } - - return ret.ToString(); - } - else if (obj is byte[]) - { - return GetSpaces(indent) + "- binary\n" + Utils.BytesToHexString((byte[]) obj, GetSpaces(indent)) + - Environment.NewLine; - } - else - { - return GetSpaces(indent) + "- unknown type " + obj.GetType().Name + Environment.NewLine; - } - } - - public static object ParseTerseLLSD(string llsd) - { - int notused; - return ParseTerseLLSD(llsd, out notused); - } - - public static object ParseTerseLLSD(string llsd, out int endPos) - { - if (llsd.Length == 0) - { - endPos = 0; - return null; - } - - // Identify what type of object this is - switch (llsd[0]) - { - case '!': - throw new LLSDParseException("Undefined value type encountered"); - case '1': - endPos = 1; - return true; - case '0': - endPos = 1; - return false; - case 'i': - { - if (llsd.Length < 2) throw new LLSDParseException("Integer value type with no value"); - int value; - endPos = FindEnd(llsd, 1); - - if (Int32.TryParse(llsd.Substring(1, endPos - 1), out value)) - return value; - else - throw new LLSDParseException("Failed to parse integer value type"); - } - case 'r': - { - if (llsd.Length < 2) throw new LLSDParseException("Real value type with no value"); - double value; - endPos = FindEnd(llsd, 1); - - if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, - Utils.EnUsCulture.NumberFormat, out value)) - return value; - else - throw new LLSDParseException("Failed to parse double value type"); - } - case 'u': - { - if (llsd.Length < 17) throw new LLSDParseException("UUID value type with no value"); - UUID value; - endPos = FindEnd(llsd, 1); - - if (UUID.TryParse(llsd.Substring(1, endPos - 1), out value)) - return value; - else - throw new LLSDParseException("Failed to parse UUID value type"); - } - case 'b': - //byte[] value = new byte[llsd.Length - 1]; - // This isn't the actual binary LLSD format, just the terse format sent - // at login so I don't even know if there is a binary type - throw new LLSDParseException("Binary value type is unimplemented"); - case 's': - case 'l': - if (llsd.Length < 2) throw new LLSDParseException("String value type with no value"); - endPos = FindEnd(llsd, 1); - return llsd.Substring(1, endPos - 1); - case 'd': - // Never seen one before, don't know what the format is - throw new LLSDParseException("Date value type is unimplemented"); - case '[': - { - if (llsd.IndexOf(']') == -1) throw new LLSDParseException("Invalid array"); - - int pos = 0; - ArrayList array = new ArrayList(); - - while (llsd[pos] != ']') - { - ++pos; - - // Advance past comma if need be - if (llsd[pos] == ',') ++pos; - - // Allow a single whitespace character - if (pos < llsd.Length && llsd[pos] == ' ') ++pos; - - int end; - array.Add(ParseTerseLLSD(llsd.Substring(pos), out end)); - pos += end; - } - - endPos = pos + 1; - return array; - } - case '{': - { - if (llsd.IndexOf('}') == -1) throw new LLSDParseException("Invalid map"); - - int pos = 0; - Hashtable hashtable = new Hashtable(); - - while (llsd[pos] != '}') - { - ++pos; - - // Advance past comma if need be - if (llsd[pos] == ',') ++pos; - - // Allow a single whitespace character - if (pos < llsd.Length && llsd[pos] == ' ') ++pos; - - if (llsd[pos] != '\'') throw new LLSDParseException("Expected a map key"); - int endquote = llsd.IndexOf('\'', pos + 1); - if (endquote == -1 || (endquote + 1) >= llsd.Length || llsd[endquote + 1] != ':') - throw new LLSDParseException("Invalid map format"); - string key = llsd.Substring(pos, endquote - pos); - key = key.Replace("'", String.Empty); - pos += (endquote - pos) + 2; - - int end; - hashtable.Add(key, ParseTerseLLSD(llsd.Substring(pos), out end)); - pos += end; - } - - endPos = pos + 1; - return hashtable; - } - default: - throw new Exception("Unknown value type"); - } - } - - private static int FindEnd(string llsd, int start) - { - int end = llsd.IndexOfAny(new char[] {',', ']', '}'}); - if (end == -1) end = llsd.Length - 1; - return end; - } - - /// - /// - /// - /// - private static void SkipWS(XmlTextReader reader) - { - while ( - reader.NodeType == XmlNodeType.Comment || - reader.NodeType == XmlNodeType.Whitespace || - reader.NodeType == XmlNodeType.SignificantWhitespace || - reader.NodeType == XmlNodeType.XmlDeclaration) - { - reader.Read(); - } - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs deleted file mode 100644 index 40e588f..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("ARRAY")] - public class OSDArray - { - public ArrayList Array = new ArrayList(); - - public OSDArray() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs deleted file mode 100644 index 3a31523..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDAssetUploadComplete - { - public string new_asset = String.Empty; - public UUID new_inventory_item = UUID.Zero; - public string state = String.Empty; - //public bool success = false; - - public LLSDAssetUploadComplete() - { - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs deleted file mode 100644 index 45c0afb..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDAssetUploadRequest - { - public string asset_type = String.Empty; - public string description = String.Empty; - public UUID folder_id = UUID.Zero; - public string inventory_type = String.Empty; - public string name = String.Empty; - - public LLSDAssetUploadRequest() - { - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs deleted file mode 100644 index 36adb93..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDAssetUploadResponse - { - public string uploader = String.Empty; - public string state = String.Empty; - - public LLSDAssetUploadResponse() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs deleted file mode 100644 index 8e5c197..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDCapEvent - { - public int id = 0; - public OSDArray events = new OSDArray(); - - public LLSDCapEvent() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs deleted file mode 100644 index d49ee1a..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDEmpty - { - public LLSDEmpty() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs deleted file mode 100644 index 3316b3f..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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; - -namespace OpenSim.Framework.Communications.Capabilities -{ - public class LLSDHelpers - { -// private static readonly log4net.ILog m_log -// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - 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); - SerializeOSDType(writer, obj); - writer.WriteEndElement(); - writer.Close(); - - //m_log.DebugFormat("[LLSD Helpers]: Generated serialized LLSD reply {0}", sw.ToString()); - - return sw.ToString(); - } - - private static void SerializeOSDType(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++) - { - if (fields[i] != null && fields[i].GetValue(obj) != null) - { - 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); - string fieldName = fields[i].Name; - fieldName = fieldName.Replace("___", "-"); - writer.WriteString(fieldName); - writer.WriteEndElement(); - SerializeOSDType(writer, fieldValue); - } - else - { - writer.WriteStartElement(String.Empty, "key", String.Empty); - string fieldName = fields[i].Name; - fieldName = fieldName.Replace("___", "-"); - writer.WriteString(fieldName); - writer.WriteEndElement(); - LLSD.LLSDWriteOne(writer, fieldValue); - // OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue)); - } - } - else - { - // TODO from ADAM: There is a nullref being caused by fields[i] being null - // on some computers. Unsure what is causing this, but would appreciate - // if sdague could take a look at this. - } - } - writer.WriteEndElement(); - break; - case "ARRAY": - // OSDArray arrayObject = obj as OSDArray; - // 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) - { - SerializeOSDType(writer, item); - } - writer.WriteEndElement(); - } - break; - } - } - else - { - LLSD.LLSDWriteOne(writer, obj); - //OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement( - // writer, OpenMetaverse.StructuredData.OSD.FromObject(obj)); - } - } - - public static object DeserialiseOSDMap(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()) - { - string keyName = (string)enumerator.Key; - keyName = keyName.Replace("-","_"); - FieldInfo field = myType.GetField(keyName); - if (field != null) - { - // if (enumerator.Value is OpenMetaverse.StructuredData.OSDMap) - if (enumerator.Value is Hashtable) - { - object fieldValue = field.GetValue(obj); - DeserialiseOSDMap((Hashtable) enumerator.Value, fieldValue); - // DeserialiseOSDMap((OpenMetaverse.StructuredData.OSDMap) 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/LLSDInventoryItem.cs b/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs deleted file mode 100644 index b0b463f..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDInventoryItem.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDInventoryItem - { - public UUID parent_id; - - public UUID asset_id; - public UUID item_id; - public LLSDPermissions permissions; - public string type; - public string inv_type; - public int flags; - - public LLSDSaleInfo sale_info; - public string name; - public string desc; - public int created_at; - } - - [OSDMap] - public class LLSDPermissions - { - public UUID creator_id; - public UUID owner_id; - public UUID group_id; - public int base_mask; - public int owner_mask; - public int group_mask; - public int everyone_mask; - public int next_owner_mask; - public bool is_owner_group; - } - - [OSDMap] - public class LLSDSaleInfo - { - public int sale_price; - public string sale_type; - } - - [OSDMap] - public class LLSDInventoryDescendents - { - public OSDArray folders = new OSDArray(); - } - - [OSDMap] - public class LLSDFetchInventoryDescendents - { - public UUID folder_id; - public UUID owner_id; - public int sort_order; - public bool fetch_folders; - public bool fetch_items; - } - - [OSDMap] - public class LLSDInventoryFolderContents - { - public UUID agent_id; - public int descendents; - public UUID folder_id; - public OSDArray items = new OSDArray(); - public UUID owner_id; - public int version; - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs deleted file mode 100644 index 8ddb492..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDItemUpdate - { - public UUID item_id; - - public LLSDItemUpdate() - { - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs deleted file mode 100644 index d012b8f..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class OSDMapLayer - { - public int Left = 0; - public int Right = 0; - public int Top = 0; - public int Bottom = 0; - public UUID ImageID = UUID.Zero; - - public OSDMapLayer() - { - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs deleted file mode 100644 index 4acc736..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapLayerResponse - { - public LLSDMapRequest AgentData = new LLSDMapRequest(); - public OSDArray LayerData = new OSDArray(); - - public LLSDMapLayerResponse() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs deleted file mode 100644 index c528208..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapRequest - { - public int Flags = 0; - - public LLSDMapRequest() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs deleted file mode 100644 index 0ef4838..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - public delegate TResponse LLSDMethod(TRequest request); -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs deleted file mode 100644 index 68c3d75..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - public delegate TResponse LLSDMethodString(TRequest request, string path); -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs deleted file mode 100644 index e8d3c21..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDParcelVoiceInfoResponse - { - public int parcel_local_id; - public string region_name; - public Hashtable voice_credentials; - - public LLSDParcelVoiceInfoResponse() - { - } - - public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) - { - region_name = region; - parcel_local_id = localID; - voice_credentials = creds; - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs deleted file mode 100644 index 6ad2db9..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDRemoteParcelResponse.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDRemoteParcelResponse - { - public UUID parcel_id; - - public LLSDRemoteParcelResponse() - { - } - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs deleted file mode 100644 index a55b86d..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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; -using System.IO; -using System.Text; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework.Communications.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, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - //Encoding encoding = Encoding.UTF8; - //StreamReader streamReader = new StreamReader(request, false); - - //string requestBody = streamReader.ReadToEnd(); - //streamReader.Close(); - - // OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap) - // OpenMetaverse.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); - - Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); - TRequest llsdRequest = new TRequest(); - LLSDHelpers.DeserialiseOSDMap(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/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs deleted file mode 100644 index c359770..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDTaskInventoryUploadComplete - { - /// - /// The task inventory item that was updated - /// - public UUID item_id; - - /// - /// The task that was updated - /// - public UUID task_id; - - /// - /// State of the upload. So far have only even seen this set to "complete" - /// - public string state; - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs deleted file mode 100644 index 4bcf715..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDTaskScriptUpdate - { - /// - /// The item containing the script to update - /// - public UUID item_id; - - /// - /// The task containing the script - /// - public UUID task_id; - - /// - /// Signals whether the script is currently active - /// - public int is_script_running; - } -} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs deleted file mode 100644 index 6bed9cf..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [LLSDType("MAP")] - public class LLSDTest - { - public int Test1 = 20; - public int Test2 = 10; - - public LLSDTest() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs deleted file mode 100644 index f3f5158..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications.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 OSDMap : LLSDType - { - public OSDMap() : base("MAP") - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs deleted file mode 100644 index 06812aa..0000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator 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.Framework.Communications.Capabilities -{ - [OSDMap] - public class LLSDVoiceAccountResponse - { - public string username; - public string password; - public string voice_sip_uri_hostname; - public string voice_account_server_name; - - public LLSDVoiceAccountResponse() - { - } - - public LLSDVoiceAccountResponse(string user, string pass) - { - username = user; - password = pass; - } - - public LLSDVoiceAccountResponse(string user, string pass, string sipUriHost, string accountServer) - { - username = user; - password = pass; - voice_sip_uri_hostname = sipUriHost; - voice_account_server_name = accountServer; - } - } -} \ No newline at end of file -- cgit v1.1 From f243dddc04a16a175e52e88fb34d38fb6fb643e5 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Thu, 18 Jun 2009 14:33:35 +0000 Subject: * Corrected CAPS namespaces * "luke, use the sed" --- OpenSim/Framework/Communications/Services/HGInventoryService.cs | 4 ++-- OpenSim/Framework/Communications/Services/HGLoginAuthService.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index af55236..e253474 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -36,8 +36,8 @@ using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications.Clients; using OpenSim.Framework.Communications.Cache; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; -using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; +using Caps = OpenSim.Framework.Capabilities.Caps; +using LLSDHelpers = OpenSim.Framework.Capabilities.LLSDHelpers; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index f496082..3ab9b38 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -33,7 +33,7 @@ using System.Reflection; using System.Text.RegularExpressions; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenMetaverse; -- cgit v1.1 From 147c9bcd453fde74c13a83a323a40ec0bb571c01 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sat, 27 Jun 2009 07:49:10 +0000 Subject: Make cleartext authentication case sensitive. Thanks jhurliman for spotting this. --- OpenSim/Framework/Communications/Services/HGLoginAuthService.cs | 2 +- OpenSim/Framework/Communications/Services/LoginService.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 3ab9b38..d3f813e 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications.Services string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); return loginresult; } } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 7eb98d7..897c763 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -769,8 +769,8 @@ namespace OpenSim.Framework.Communications.Services //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); - + || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); + return passwordSuccess; } -- cgit v1.1 From 23c7d6b818d8435562d85be6a4cedb015ed9937c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 4 Jul 2009 18:15:01 +0000 Subject: Add the new field agent_access_max. Without it being set to "A", viewers from 1.23 prevent the removal of underwear. --- OpenSim/Framework/Communications/Services/LoginResponse.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index c9a3175..b48fb76 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -144,6 +144,7 @@ namespace OpenSim.Framework.Communications.Services firstname = "Test"; lastname = "User"; agentAccess = "M"; + agentAccessMax = "A"; startLocation = "last"; allowFirstLife = "Y"; @@ -342,6 +343,7 @@ namespace OpenSim.Framework.Communications.Services responseData["first_name"] = Firstname; responseData["last_name"] = Lastname; responseData["agent_access"] = agentAccess; + responseData["agent_access_max"] = agentAccessMax; globalTexturesHash = new Hashtable(); globalTexturesHash["sun_texture_id"] = SunTexture; @@ -416,6 +418,7 @@ namespace OpenSim.Framework.Communications.Services map["first_name"] = OSD.FromString(Firstname); map["last_name"] = OSD.FromString(Lastname); map["agent_access"] = OSD.FromString(agentAccess); + map["agent_access_max"] = OSD.FromString(agentAccessMax); map["sim_port"] = OSD.FromInteger(SimPort); map["sim_ip"] = OSD.FromString(SimAddress); @@ -666,6 +669,12 @@ namespace OpenSim.Framework.Communications.Services set { agentAccess = value; } } + public string AgentAccessMax + { + get { return agentAccessMax; } + set { agentAccessMax = value; } + } + public string StartLocation { get { return startLocation; } -- cgit v1.1 From 5df21f9dcbd6573eb5c4618a8ddcf4cecf61fcdc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 4 Jul 2009 18:20:18 +0000 Subject: Fix previous commit --- OpenSim/Framework/Communications/Services/LoginResponse.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs index b48fb76..ec5f428 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs @@ -78,6 +78,7 @@ namespace OpenSim.Framework.Communications.Services private uint simHttpPort; private string simAddress; private string agentAccess; + private string agentAccessMax; private Int32 circuitCode; private uint regionX; private uint regionY; -- cgit v1.1 From 7e8bfc461878b33fb85f99c2a751e3f66278f26e Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Tue, 7 Jul 2009 23:07:57 +0000 Subject: * Allowing LLSD logins to do silent logout of last hung session on standalone only, following the already implemented XMLRPC behavior --- .../Communications/Services/LoginService.cs | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 897c763..a9be197 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -197,7 +197,7 @@ namespace OpenSim.Framework.Communications.Services { // This is behavior for standalone (silent logout of last hung session) m_log.InfoFormat( - "[LOGIN]: User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", + "[LOGIN]: XMLRPC User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", firstname, lastname); } } @@ -422,14 +422,23 @@ namespace OpenSim.Framework.Communications.Services // try to tell the region that their user is dead. LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); - // Reject the login - - m_log.InfoFormat( - "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", - userProfile.FirstName, userProfile.SurName); + if (m_warn_already_logged) + { + // This is behavior for for grid, reject login + m_log.InfoFormat( + "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", + userProfile.FirstName, userProfile.SurName); - userProfile.CurrentAgent = null; - return logResponse.CreateAlreadyLoggedInResponseLLSD(); + userProfile.CurrentAgent = null; + return logResponse.CreateAlreadyLoggedInResponseLLSD(); + } + else + { + // This is behavior for standalone (silent logout of last hung session) + m_log.InfoFormat( + "[LOGIN]: LLSD User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", + userProfile.FirstName, userProfile.SurName); + } } // Otherwise... -- cgit v1.1 From c310fb11f492419de60b4bf8e5bb234e4589b336 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 10 Jul 2009 02:22:26 +0000 Subject: Remove all references to HttpServer from CommsManager (all incarnations) Change all uses of the HttpServer properties to use the new singleton --- .../Communications/CommunicationsManager.cs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index c78212d..e1a70e5 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -29,12 +29,11 @@ using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Framework.Communications { /// - /// This class manages references to OpenSim non-region services (asset, inventory, user, etc.) + /// This class manages references to OpenSim non-region services (inventory, user, etc.) /// /// /// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region @@ -99,28 +98,15 @@ namespace OpenSim.Framework.Communications } protected IUserAdminService m_userAdminService; - /// - /// OpenSimulator's built in HTTP server - /// - public IHttpServer HttpServer - { - get { return m_httpServer; } - } - protected IHttpServer m_httpServer; - /// /// Constructor /// /// - /// - /// - /// - public CommunicationsManager(NetworkServersInfo serversInfo, IHttpServer httpServer, IAssetCache assetCache, - bool dumpAssetsToFile, LibraryRootFolder libraryRootFolder) + public CommunicationsManager(NetworkServersInfo serversInfo, + LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); - m_httpServer = httpServer; } #region Inventory -- cgit v1.1 From 148e2d55fa4dcf6e87ffce5c67f2ca2ea9e88a08 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 10 Jul 2009 18:40:37 +0000 Subject: * minor: Make GridCommon.ini.example refer to inventory service rather than asset where appropriate * Send debug level notice to console if a user fails authentication --- .../Communications/Services/LoginService.cs | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index a9be197..9709975 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -311,37 +311,55 @@ namespace OpenSim.Framework.Communications.Services { Hashtable requestData = (Hashtable)request.Params[0]; - bool GoodLogin = false; - userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { - m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); + m_log.Debug("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); + return false; } else { if (requestData.Contains("passwd")) { string passwd = (string)requestData["passwd"]; - GoodLogin = AuthenticateUser(userProfile, passwd); + bool authenticated = AuthenticateUser(userProfile, passwd); + + if (!authenticated) + m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed password authentication", + firstname, lastname); + + return authenticated; } - if (!GoodLogin && (requestData.Contains("web_login_key"))) + + if (requestData.Contains("web_login_key")) { try { UUID webloginkey = new UUID((string)requestData["web_login_key"]); - GoodLogin = AuthenticateUser(userProfile, webloginkey); + bool authenticated = AuthenticateUser(userProfile, webloginkey); + + if (!authenticated) + m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed web login key authentication", + firstname, lastname); + + return authenticated; } catch (Exception e) { - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", + m_log.DebugFormat( + "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", requestData["web_login_key"], firstname, lastname, e); + + return false; } } + + m_log.DebugFormat( + "[LOGIN END]: XMLRPC login request for {0} {1} contained neither a password nor a web login key", + firstname, lastname); } - return GoodLogin; + return false; } protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) -- cgit v1.1 From d7d2de3a08141a2a445119b5b26b7f766b2be44c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 10 Jul 2009 18:57:16 +0000 Subject: * minor: standardize some logging messages --- .../Communications/Services/GridInfoService.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs index 70e7dce..cd2a152 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs @@ -72,7 +72,8 @@ namespace OpenSim.Framework.Communications.Services } catch (FileNotFoundException) { - _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); + _log.Warn( + "[GRID INFO SERVICE]: No OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); } } @@ -123,19 +124,21 @@ namespace OpenSim.Framework.Communications.Services } catch (Exception) { - _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); + _log.Debug("[GRID INFO SERVICE]: Cannot get grid info from config source, using minimal defaults"); } - _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); + + _log.DebugFormat("[GRID INFO SERVICE]: Grid info service initialized with {0} keys", _info.Count); } private void IssueWarning() { - _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); - _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); + _log.Warn("[GRID INFO SERVICE]: found no [GridInfo] section in your OpenSim.ini"); + _log.Warn("[GRID INFO SERVICE]: trying to guess sensible defaults, you might want to provide better ones:"); + foreach (string k in _info.Keys) { - _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); + _log.WarnFormat("[GRID INFO SERVICE]: {0}: {1}", k, _info[k]); } } @@ -144,7 +147,7 @@ namespace OpenSim.Framework.Communications.Services XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - _log.Info("[GridInfo]: Request for grid info"); + _log.Info("[GRID INFO SERVICE]: Request for grid info"); foreach (string k in _info.Keys) { -- cgit v1.1 From 18ffbf63420b3fdb3e6a4cf87425be2c9063795c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 10 Jul 2009 19:18:05 +0000 Subject: * minor format changes and message additions --- .../Framework/Communications/Clients/GridClient.cs | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs index 74b78de..4836556 100644 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ b/OpenSim/Framework/Communications/Clients/GridClient.cs @@ -29,7 +29,9 @@ using System; using System.Collections; using System.Collections.Generic; using System.Net; +using System.Reflection; +using log4net; using OpenMetaverse; using Nwc.XmlRpc; @@ -37,9 +39,14 @@ namespace OpenSim.Framework.Communications.Clients { public class GridClient { - - public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public bool RegisterRegion( + string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) { + m_log.InfoFormat( + "[GRID CLIENT]: Registering region {0} with grid at {1}", regionInfo.RegionName, gridServerURL); + forcefulBanLines = true; Hashtable GridParams = new Hashtable(); @@ -165,7 +172,9 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg) + public bool RequestNeighborInfo( + string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, + out RegionInfo regionInfo, out string errorMsg) { // didn't find it so far, we have to go the long way regionInfo = null; @@ -201,7 +210,9 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg) + public bool RequestNeighborInfo( + string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, + out RegionInfo regionInfo, out string errorMsg) { // didn't find it so far, we have to go the long way regionInfo = null; @@ -257,7 +268,9 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg) + public bool RequestClosestRegion( + string gridServerURL, string sendKey, string receiveKey, string regionName, + out RegionInfo regionInfo, out string errorMsg) { regionInfo = null; errorMsg = string.Empty; @@ -299,7 +312,8 @@ namespace OpenSim.Framework.Communications.Clients /// Maximum X value /// Maximum Y value /// Hashtable of hashtables containing map data elements - public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) + public bool MapBlockQuery( + string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) { respData = new Hashtable(); errorMsg = string.Empty; -- cgit v1.1 From 190bdc8a2e8fa842759087749592769f951834ab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Wed, 5 Aug 2009 17:33:23 +0100 Subject: * Remove some mono compiler warnings --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 4070b49..47e0293 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -90,8 +90,8 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); // We want to use our own LoginService for this test, one that // doesn't require authentication. - LoginService loginService = new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), - m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); + new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), + m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); Hashtable loginParams = new Hashtable(); loginParams["first"] = m_firstName; -- cgit v1.1 From 04aca663300bcf823ae25d9cc82e727e58e24c21 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 Aug 2009 13:59:26 -0700 Subject: Removed HGInventory out of core. This is part of HG2, which it now being developed outside. --- .../Communications/Services/HGInventoryService.cs | 744 --------------------- 1 file changed, 744 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Services/HGInventoryService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs deleted file mode 100644 index e253474..0000000 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Clients; -using OpenSim.Framework.Communications.Cache; -using Caps = OpenSim.Framework.Capabilities.Caps; -using LLSDHelpers = OpenSim.Framework.Capabilities.LLSDHelpers; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Services.Interfaces; - -using OpenMetaverse.StructuredData; - -namespace OpenSim.Framework.Communications.Services -{ - public class HGInventoryService - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private InventoryServiceBase m_inventoryService; - IHttpServer httpServer; - private string m_thisInventoryUrl = "http://localhost:9000"; - private string m_thisHostname = "127.0.0.1"; - private uint m_thisPort = 9000; - - // These two used for local access, standalone mode - private UserManagerBase m_userService = null; - IAssetService m_assetProvider = null; - - // These two used for remote access - //string m_UserServerURL = string.Empty; - string m_AssetServerURL = string.Empty; - SynchronousGridAssetClient m_AssetClient = null; - - // Constructor for grid inventory server - public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) - { - //m_UserServerURL = userServiceURL; - m_AssetServerURL = assetServiceURL; - - m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); - - Init(invService, thisurl, httpserver); - } - - // Constructor for standalone mode - public HGInventoryService(InventoryServiceBase invService, IAssetService assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) - { - m_userService = userService; - m_assetProvider = assetService; - - Init(invService, thisurl, httpserver); - } - - private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) - { - m_inventoryService = invService; - m_thisInventoryUrl = thisurl; - if (!m_thisInventoryUrl.EndsWith("/")) - m_thisInventoryUrl += "/"; - - Uri uri = new Uri(m_thisInventoryUrl); - if (uri != null) - { - m_thisHostname = uri.Host; - m_thisPort = (uint)uri.Port; - } - - httpServer = httpserver; - - AddHttpHandlers(); - } - - public virtual void AddHttpHandlers() - { - httpServer.AddHTTPHandler("/InvCap/", CapHandler); - - // Un-cap'ed for now - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", "/GetItem/", GetInventoryItem, CheckAuthSession)); - - } - - public InventoryItemBase GetInventoryItem(Guid id) - { - UUID itemID = new UUID(id); - return m_inventoryService.GetInventoryItem(itemID); - } - - public bool CheckAuthSession(string session_id, string avatar_id) - { - return true; - } - - - // In truth, this is not called from the outside, for standalones. I'm just making it - // a handler already so that this can be reused for the InventoryServer. - public string CreateCapUrl(Guid _userid) - { - UUID userID = new UUID(_userid); - UUID random = UUID.Random(); - string url = m_thisInventoryUrl + random.ToString() + "/"; - m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); - return url; - } - - /// - /// Return a user's entire inventory - /// - /// - /// The user's inventory. If an inventory cannot be found then an empty collection is returned. - public InventoryCollection GetUserInventory(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List allFolders = m_inventoryService.GetInventorySkeleton(userID); - - if (null == allFolders) - { - m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); - - return invCollection; - } - - List allItems = new List(); - - foreach (InventoryFolderBase folder in allFolders) - { - List items = m_inventoryService.RequestFolderItems(folder.ID); - - if (items != null) - { - allItems.InsertRange(0, items); - } - } - - invCollection.UserID = userID; - invCollection.Folders = allFolders; - invCollection.Items = allItems; - - // foreach (InventoryFolderBase folder in invCollection.Folders) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); - // } - // - // foreach (InventoryItemBase item in invCollection.Items) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); - // } - - m_log.InfoFormat( - "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", - invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); - - return invCollection; - } - - public InventoryCollection FetchDescendants(InventoryFolderBase fb) - { - m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List items = m_inventoryService.RequestFolderItems(fb.ID); - List folders = m_inventoryService.RequestSubFolders(fb.ID); - - invCollection.UserID = fb.Owner; - invCollection.Folders = folders; - invCollection.Items = items; - - m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); - - return invCollection; - } - - public bool RemoveFolder(InventoryFolderBase folder) - { - m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); - return false; - } - - public InventoryItemBase GetInventoryItem(InventoryItemBase item) - { - m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); - - item = m_inventoryService.GetInventoryItem(item.ID); - if (item == null) - m_log.Debug("[HGStandaloneInvService]: null item"); - return item; - } - - public InventoryItemBase AddItem(InventoryItemBase item) - { - m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); - if (m_inventoryService.AddItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) - { - AddItem(item); - } - - public InventoryItemBase UpdateItem(InventoryItemBase item) - { - m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); - InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); - item.CurrentPermissions = it.CurrentPermissions; - item.AssetID = it.AssetID; - if (m_inventoryService.UpdateItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public InventoryItemBase MoveItem(InventoryItemBase newitem) - { - m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); - InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); - if (Item != null) - { - if (newitem.Name != String.Empty) - { - Item.Name = newitem.Name; - } - Item.Folder = newitem.Folder; - m_inventoryService.UpdateItem(Item); - return Item; - } - else - { - m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); - newitem.ID = UUID.Zero; - return newitem; - } - - } - - public InventoryItemBase DeleteItem(InventoryItemBase item) - { - item = m_inventoryService.GetInventoryItem(item.ID); - if (m_inventoryService.DeleteItem(item)) - return item; - else - { - item.ID = UUID.Zero; - return item; - } - } - - public InventoryItemBase CopyItem(InventoryItemBase olditem) - { - m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); - InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id - // BIG HACK here - UUID newID = olditem.AssetID; - if (Item != null) - { - if (olditem.Name != String.Empty) - { - Item.Name = olditem.Name; - } - Item.ID = newID; - Item.Folder = olditem.Folder; - Item.Owner = olditem.Owner; - // There should be some tests here about the owner, etc but I'm going to ignore that - // because I'm not sure it makes any sense - // Also I should probably clone the asset... - m_inventoryService.AddItem(Item); - return Item; - } - else - { - m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); - olditem.ID = UUID.Zero; - return olditem; - } - - } - - /// - /// Guid to UUID wrapper for same name IInventoryServices method - /// - /// - /// - public List GetInventorySkeleton(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - return m_inventoryService.GetInventorySkeleton(userID); - } - - public List GetActiveGestures(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); - - return m_inventoryService.GetActiveGestures(userID); - } - - public AssetBase GetAsset(InventoryItemBase item) - { - m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); - AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data - InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); - if (item2 == null) - { - m_log.Debug("[HGStandaloneInvService]: null item"); - return asset; - } - if (item2.Owner != item.Owner) - { - m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); - return asset; - } - UUID assetID = item2.AssetID; - if (assetID != item.AssetID) - { - m_log.WarnFormat("[HGStandaloneInvService]: asset IDs don't match {0}, {1}", item.AssetID, item2.AssetID); - } - - // All good, get the asset - //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); - AssetBase theasset = FetchAsset(assetID, (item.InvType == (int)InventoryType.Texture)); - - m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); - if (theasset != null) - { - asset = theasset; - //m_log.Debug(" >> Sending assetID " + item.AssetID); - } - return asset; - } - - public bool PostAsset(AssetBase asset) - { - m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); - //m_assetProvider.CreateAsset(asset); - StoreAsset(asset); - - return true; - } - - public void PostAnAsset(AssetBase asset) - { - PostAsset(asset); - } - - /// - /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) - /// - public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) - { - m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); - InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); - - if (item != null) - { - // We're still not dealing with permissions - //if ((InventoryType)item.InvType == InventoryType.Notecard) - //{ - // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) - // { - // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); - // return UUID.Zero; - // } - - // //remoteClient.SendAgentAlertMessage("Notecard saved", false); - //} - //else if ((InventoryType)item.InvType == InventoryType.LSL) - //{ - // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) - // { - // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); - // return UUID.Zero; - // } - - // //remoteClient.SendAgentAlertMessage("Script saved", false); - //} - - AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); - PostAsset(asset); - - item.AssetID = asset.FullID; - item.Owner = userID; - m_inventoryService.UpdateItem(item); - - return (asset.FullID); - } - return UUID.Zero; - } - - private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) - { - AssetBase asset = new AssetBase(); - asset.Name = name; - asset.Description = description; - asset.Type = assetType; - asset.FullID = UUID.Random(); - asset.Data = (data == null) ? new byte[1] : data; - - return asset; - } - - #region Caps - - Dictionary invCaps = new Dictionary(); - - public Hashtable CapHandler(Hashtable request) - { - m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); - - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); - - // these are requests if the type - // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ - - Hashtable responsedata = new Hashtable(); - responsedata["content_type"] = "text/plain"; - - UUID userID; - string authToken = string.Empty; - string authority = string.Empty; - if (!GetParams(request, out userID, out authority, out authToken)) - { - m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "Not found"; - - return responsedata; - } - - // Next, let's parse the verb - string method = (string)request["http-method"]; - if (method.Equals("GET")) - { - DoInvCapPost(request, responsedata, userID, authority, authToken); - return responsedata; - } - //else if (method.Equals("DELETE")) - //{ - // DoAgentDelete(request, responsedata, agentID, action, regionHandle); - - // return responsedata; - //} - else - { - m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); - responsedata["int_response_code"] = 405; - responsedata["str_response_string"] = "Method not allowed"; - - return responsedata; - } - - } - - public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authority, string authToken) - { - - // This is the meaning of POST agent - - // Check Auth Token - if ((m_userService != null) && !(m_userService is IAuthentication)) - { - m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); - responsedata["int_response_code"] = 501; - responsedata["str_response_string"] = "Not implemented"; - return; - } - - bool success = VerifyKey(userID, authority, authToken); - - if (success) - { - - m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); - - // Then establish secret service handlers - - Hashtable usercaps = RegisterCaps(userID, authToken); - - responsedata["int_response_code"] = 200; - //responsedata["str_response_string"] = "OK"; - responsedata["str_response_string"] = SerializeHashtable(usercaps); - } - else - { - m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); - responsedata["int_response_code"] = 403; - responsedata["str_response_string"] = "Forbidden"; - } - } - - - /// - /// Extract the params from a request. - /// - public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) - { - uuid = UUID.Zero; - authority = string.Empty; - authKey = string.Empty; - - string uri = (string)request["uri"]; - uri = uri.Trim(new char[] { '/' }); - string[] parts = uri.Split('/'); - if (parts.Length <= 1) - { - return false; - } - else - { - if (!UUID.TryParse(parts[1], out uuid)) - return false; - - if (parts.Length >= 3) - { - authKey = parts[2]; - return true; - } - } - - Uri authUri; - Hashtable headers = (Hashtable)request["headers"]; - - // Authorization keys look like this: - // http://orgrid.org:8002/ - if (headers.ContainsKey("authorization")) - { - if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) - { - authority = authUri.Authority; - authKey = authUri.PathAndQuery.Trim('/'); - m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); - return true; - } - else - m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); - } - else - m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); - - return false; - } - - string SerializeHashtable(Hashtable hash) - { - string result = string.Empty; - foreach (object key in hash.Keys) - { - result += key.ToString() + "," + hash[key].ToString() + ";"; - } - return result; - } - - Hashtable RegisterCaps(UUID userID, string authToken) - { - lock (invCaps) - { - if (invCaps.ContainsKey(userID)) - { - // Remove the old ones - DeregisterCaps(httpServer, invCaps[userID]); - invCaps.Remove(userID); - } - } - - Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); - caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); - caps.ItemUpdatedCall = UpdateInventoryItemAsset; - caps.AddNewInventoryItem = AddUploadedInventoryItem; - caps.AddNewAsset = PostAnAsset; - //caps.GetClient = - - Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); - - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); - httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( - "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); - - lock (invCaps) - invCaps.Add(userID, capsHandlers); - - return capsHandlers; - } - - string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) - { - string capUrl = "/" + authToken + "/" + capType + "/"; - - m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); - caps.Add(capType, capUrl); - return capUrl; - } - - void DeregisterCaps(IHttpServer httpServer, Hashtable caps) - { - foreach (string capUrl in caps.Values) - { - m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); - httpServer.RemoveStreamHandler("POST", capUrl); - } - } - - #endregion Caps - - #region Local vs Remote - - bool VerifyKey(UUID userID, string authority, string key) - { - // Remote call to the Authorization server - if (m_userService == null) - return AuthClient.VerifyKey("http://" + authority, userID, key); - // local call - else - return ((IAuthentication)m_userService).VerifyKey(userID, key); - } - - AssetBase FetchAsset(UUID assetID, bool isTexture) - { - // Remote call to the Asset server - if (m_assetProvider == null) - return m_AssetClient.SyncGetAsset(assetID, isTexture); - // local call - else - return m_assetProvider.Get(assetID.ToString()); - } - - void StoreAsset(AssetBase asset) - { - // Remote call to the Asset server - if (m_assetProvider == null) - m_AssetClient.StoreAsset(asset); - // local call - else - m_assetProvider.Store(asset); - } - - #endregion Local vs Remote - } - - class SynchronousGridAssetClient : GridAssetClient - { - public SynchronousGridAssetClient(string url) - : base(url) - { - } - - public AssetBase SyncGetAsset(UUID assetID, bool isTexture) - { - AssetRequest assReq = new AssetRequest(); - assReq.AssetID = assetID; - assReq.IsTexture = isTexture; - return base.GetAsset(assReq); - } - - } -} -- cgit v1.1 From a50904a68bdc215d4ccc312627d44c736a1bceb5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 06:41:03 -0700 Subject: More clean up from asset cache legacy. None of these classes are used anymore. --- .../Communications/Cache/AssetServerBase.cs | 246 --------- .../Communications/Cache/CryptoGridAssetClient.cs | 559 --------------------- .../Communications/Cache/FileAssetClient.cs | 121 ----- .../Communications/Cache/GridAssetClient.cs | 140 ------ 4 files changed, 1066 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/AssetServerBase.cs delete mode 100644 OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs delete mode 100644 OpenSim/Framework/Communications/Cache/FileAssetClient.cs delete mode 100644 OpenSim/Framework/Communications/Cache/GridAssetClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs deleted file mode 100644 index 4b2a752..0000000 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Reflection; -using System.Threading; -using log4net; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework.AssetLoader.Filesystem; -using OpenSim.Framework.Statistics; - -namespace OpenSim.Framework.Communications.Cache -{ - public abstract class AssetServerBase : IAssetServer - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected IAssetReceiver m_receiver; - protected BlockingQueue m_assetRequests = new BlockingQueue(); - protected Thread m_localAssetServerThread; - protected IAssetDataPlugin m_assetProvider; - - #region IPlugin - - /// - /// The methods and properties in this region are needed to implement - /// the IPlugin interface and its local extensions. - /// These can all be overridden as appropriate by a derived class. - /// These methods are only applicable when a class is loaded by the - /// IPlugin mechanism. - /// - /// Note that in the case of AssetServerBase, all initialization is - /// performed by the default constructor, so nothing additional is - /// required here. A derived class may wish to do more. - /// - - public virtual string Name - { - // get { return "OpenSim.Framework.Communications.Cache.AssetServerBase"; } - get { return "AssetServerBase"; } - } - - public virtual string Version - { - get { return "1.0"; } - } - - public virtual void Initialise() - { - m_log.Debug("[ASSET SERVER]: IPlugin null initialization"); - } - - public virtual void Initialise(ConfigSettings settings) - { - m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(1)"); - m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); - } - - public virtual void Initialise(ConfigSettings settings, string p_url) - { - m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(2)"); - m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); - } - - public virtual void Initialise(ConfigSettings settings, string p_url, string p_dir, bool p_t) - { - m_log.Debug("[ASSET SERVER]: IPlugin null configured initialization(3)"); - m_log.InfoFormat("[ASSET SERVER]: Initializing client [{0}/{1}", Name, Version); - } - - public virtual void Dispose() - { - m_log.Debug("[ASSET SERVER]: dispose"); - } - - #endregion - - public IAssetDataPlugin AssetProviderPlugin - { - get { return m_assetProvider; } - } - - // Temporarily hardcoded - should be a plugin - protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); - - public virtual void Start() - { - m_log.Debug("[ASSET SERVER]: Starting asset server"); - - m_localAssetServerThread = new Thread(RunRequests); - m_localAssetServerThread.Name = "LocalAssetServerThread"; - m_localAssetServerThread.IsBackground = true; - m_localAssetServerThread.Start(); - ThreadTracker.Add(m_localAssetServerThread); - } - - public virtual void Stop() - { - m_localAssetServerThread.Abort(); - } - - public abstract void StoreAsset(AssetBase asset); - - /// - /// This method must be implemented by a subclass to retrieve the asset named in the - /// AssetRequest. If the asset is not found, null should be returned. - /// - /// - /// - /// - /// Thrown if the request failed for some other reason than that the - /// asset cannot be found. - /// - protected abstract AssetBase GetAsset(AssetRequest req); - - /// - /// Does the asset server have any waiting requests? - /// - /// - /// This does include any request that is currently being handled. This information is not reliable where - /// another thread may be processing requests. - /// - /// - /// True if there are waiting requests. False if there are no waiting requests. - /// - public virtual bool HasWaitingRequests() - { - return m_assetRequests.Count() != 0; - } - - /// - /// Process an asset request. This method will call GetAsset(AssetRequest req) - /// on the subclass. - /// - public virtual void ProcessNextRequest() - { - AssetRequest req = m_assetRequests.Dequeue(); - AssetBase asset; - - try - { - asset = GetAsset(req); - } - catch (Exception e) - { - m_log.ErrorFormat("[ASSET]: Asset request for {0} threw exception {1} - Stack Trace: {2}", req.AssetID, e, e.StackTrace); - - if (StatsManager.SimExtraStats != null) - StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); - - m_receiver.AssetNotFound(req.AssetID, req.IsTexture); - - return; - } - - if (asset != null) - { - //m_log.DebugFormat("[ASSET]: Asset {0} received from asset server", req.AssetID); - - m_receiver.AssetReceived(asset, req.IsTexture); - } - else - { - //m_log.WarnFormat("[ASSET]: Asset {0} not found by asset server", req.AssetID); - - m_receiver.AssetNotFound(req.AssetID, req.IsTexture); - } - } - - public virtual void LoadDefaultAssets(string pAssetSetsXml) - { - m_log.Info("[ASSET SERVER]: Setting up asset database"); - - assetLoader.ForEachDefaultXmlAsset(pAssetSetsXml, StoreAsset); - } - - private void RunRequests() - { - while (true) // Since it's a 'blocking queue' - { - try - { - ProcessNextRequest(); - } - catch (Exception e) - { - m_log.Error("[ASSET SERVER]: " + e.ToString()); - } - } - } - - /// - /// The receiver will be called back with asset data once it comes in. - /// - /// - public void SetReceiver(IAssetReceiver receiver) - { - m_receiver = receiver; - } - - public void RequestAsset(UUID assetID, bool isTexture) - { - AssetRequest req = new AssetRequest(); - req.AssetID = assetID; - req.IsTexture = isTexture; - m_assetRequests.Enqueue(req); - - //m_log.DebugFormat("[ASSET SERVER]: Added {0} to request queue", assetID); - } - - public virtual void UpdateAsset(AssetBase asset) - { - m_assetProvider.UpdateAsset(asset); - } - - public void SetServerInfo(string ServerUrl, string ServerKey) - { - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs deleted file mode 100644 index 4e35f5b..0000000 --- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs +++ /dev/null @@ -1,559 +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 OpenSimulator 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. - */ -/* - * This file includes content derived from Obviex. - * Copyright (C) 2002 Obviex(TM). All rights reserved. - * http://www.obviex.com/samples/Encryption.aspx - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Security.Cryptography; -using System.Text; -using System.Xml.Serialization; -using log4net; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework.Communications.Cache -{ - public class CryptoGridAssetClient : AssetServerBase - { - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string _assetServerUrl; - private bool m_encryptOnUpload; - private RjinKeyfile m_encryptKey; - private readonly Dictionary m_keyfiles = new Dictionary(); - - #region IPlugin - - public override string Name - { - get { return "Crypto"; } - } - - public override string Version - { - get { return "1.0"; } - } - - public override void Initialise(ConfigSettings p_set, string p_url, string p_dir, bool p_t) - { - m_log.Debug("[CRYPTOGRID] Plugin configured initialisation"); - Initialise(p_url, p_dir, p_t); - } - - #endregion - - #region Keyfile Classes - [Serializable] - public class RjinKeyfile - { - public string Secret; - public string AlsoKnownAs; - public int Keysize; - public string IVBytes; - public string Description = "OpenSim Key"; - - private static string SHA1Hash(byte[] bytes) - { - SHA1 sha1 = SHA1CryptoServiceProvider.Create(); - byte[] dataMd5 = sha1.ComputeHash(bytes); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < dataMd5.Length; i++) - sb.AppendFormat("{0:x2}", dataMd5[i]); - return sb.ToString(); - } - - public void GenerateRandom() - { - RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider(); - - byte[] genSec = new byte[32]; - byte[] genAKA = new byte[32]; - byte[] genIV = new byte[32]; - - Gen.GetBytes(genSec); - Gen.GetBytes(genAKA); - Gen.GetBytes(genIV); - - Secret = SHA1Hash(genSec); - AlsoKnownAs = SHA1Hash(genAKA); - IVBytes = SHA1Hash(genIV).Substring(0, 16); - Keysize = 256; - } - } - #endregion - - #region Rjindael - /// - /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and - /// decrypt data. As long as encryption and decryption routines use the same - /// parameters to generate the keys, the keys are guaranteed to be the same. - /// The class uses static functions with duplicate code to make it easier to - /// demonstrate encryption and decryption logic. In a real-life application, - /// this may not be the most efficient way of handling encryption, so - as - /// soon as you feel comfortable with it - you may want to redesign this class. - /// - public class UtilRijndael - { - /// - /// Encrypts specified plaintext using Rijndael symmetric key algorithm - /// and returns a base64-encoded result. - /// - /// - /// Plaintext value to be encrypted. - /// - /// - /// Passphrase from which a pseudo-random password will be derived. The - /// derived password will be used to generate the encryption key. - /// Passphrase can be any string. In this example we assume that this - /// passphrase is an ASCII string. - /// - /// - /// Salt value used along with passphrase to generate password. Salt can - /// be any string. In this example we assume that salt is an ASCII string. - /// - /// - /// Hash algorithm used to generate password. Allowed values are: "MD5" and - /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. - /// - /// - /// Number of iterations used to generate password. One or two iterations - /// should be enough. - /// - /// - /// Initialization vector (or IV). This value is required to encrypt the - /// first block of plaintext data. For RijndaelManaged class IV must be - /// exactly 16 ASCII characters long. - /// - /// - /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. - /// Longer keys are more secure than shorter keys. - /// - /// - /// Encrypted value formatted as a base64-encoded string. - /// - public static byte[] Encrypt(byte[] plainText, - string passPhrase, - string saltValue, - string hashAlgorithm, - int passwordIterations, - string initVector, - int keySize) - { - // Convert strings into byte arrays. - // Let us assume that strings only contain ASCII codes. - // If strings include Unicode characters, use Unicode, UTF7, or UTF8 - // encoding. - byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); - byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); - - // Convert our plaintext into a byte array. - // Let us assume that plaintext contains UTF8-encoded characters. - byte[] plainTextBytes = plainText; - - // First, we must create a password, from which the key will be derived. - // This password will be generated from the specified passphrase and - // salt value. The password will be created using the specified hash - // algorithm. Password creation can be done in several iterations. - PasswordDeriveBytes password = new PasswordDeriveBytes( - passPhrase, - saltValueBytes, - hashAlgorithm, - passwordIterations); - - // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead - // of bits). - #pragma warning disable 0618 - byte[] keyBytes = password.GetBytes(keySize / 8); - #pragma warning restore 0618 - - // Create uninitialized Rijndael encryption object. - RijndaelManaged symmetricKey = new RijndaelManaged(); - - // It is reasonable to set encryption mode to Cipher Block Chaining - // (CBC). Use default options for other symmetric key parameters. - symmetricKey.Mode = CipherMode.CBC; - - // Generate encryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key - // bytes. - ICryptoTransform encryptor = symmetricKey.CreateEncryptor( - keyBytes, - initVectorBytes); - - // Define memory stream which will be used to hold encrypted data. - MemoryStream memoryStream = new MemoryStream(); - - // Define cryptographic stream (always use Write mode for encryption). - CryptoStream cryptoStream = new CryptoStream(memoryStream, - encryptor, - CryptoStreamMode.Write); - // Start encrypting. - cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); - - // Finish encrypting. - cryptoStream.FlushFinalBlock(); - - // Convert our encrypted data from a memory stream into a byte array. - byte[] cipherTextBytes = memoryStream.ToArray(); - - // Close both streams. - memoryStream.Close(); - cryptoStream.Close(); - - // Return encrypted string. - return cipherTextBytes; - } - - /// - /// Decrypts specified ciphertext using Rijndael symmetric key algorithm. - /// - /// - /// Base64-formatted ciphertext value. - /// - /// - /// Passphrase from which a pseudo-random password will be derived. The - /// derived password will be used to generate the encryption key. - /// Passphrase can be any string. In this example we assume that this - /// passphrase is an ASCII string. - /// - /// - /// Salt value used along with passphrase to generate password. Salt can - /// be any string. In this example we assume that salt is an ASCII string. - /// - /// - /// Hash algorithm used to generate password. Allowed values are: "MD5" and - /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. - /// - /// - /// Number of iterations used to generate password. One or two iterations - /// should be enough. - /// - /// - /// Initialization vector (or IV). This value is required to encrypt the - /// first block of plaintext data. For RijndaelManaged class IV must be - /// exactly 16 ASCII characters long. - /// - /// - /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. - /// Longer keys are more secure than shorter keys. - /// - /// - /// Decrypted string value. - /// - /// - /// Most of the logic in this function is similar to the Encrypt - /// logic. In order for decryption to work, all parameters of this function - /// - except cipherText value - must match the corresponding parameters of - /// the Encrypt function which was called to generate the - /// ciphertext. - /// - public static byte[] Decrypt(byte[] cipherText, - string passPhrase, - string saltValue, - string hashAlgorithm, - int passwordIterations, - string initVector, - int keySize) - { - // Convert strings defining encryption key characteristics into byte - // arrays. Let us assume that strings only contain ASCII codes. - // If strings include Unicode characters, use Unicode, UTF7, or UTF8 - // encoding. - byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); - byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); - - // Convert our ciphertext into a byte array. - byte[] cipherTextBytes = cipherText; - - // First, we must create a password, from which the key will be - // derived. This password will be generated from the specified - // passphrase and salt value. The password will be created using - // the specified hash algorithm. Password creation can be done in - // several iterations. - PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, - saltValueBytes, - hashAlgorithm, - passwordIterations); - - // Use the password to generate pseudo-random bytes for the encryption - // key. Specify the size of the key in bytes (instead - // of bits). - #pragma warning disable 0618 - byte[] keyBytes = password.GetBytes(keySize / 8); - #pragma warning restore 0618 - - // Create uninitialized Rijndael encryption object. - RijndaelManaged symmetricKey = new RijndaelManaged(); - - // It is reasonable to set encryption mode to Cipher Block Chaining - // (CBC). Use default options for other symmetric key parameters. - symmetricKey.Mode = CipherMode.CBC; - - // Generate decryptor from the existing key bytes and initialization - // vector. Key size will be defined based on the number of the key - // bytes. - ICryptoTransform decryptor = symmetricKey.CreateDecryptor( - keyBytes, - initVectorBytes); - - // Define memory stream which will be used to hold encrypted data. - MemoryStream memoryStream = new MemoryStream(cipherTextBytes); - - // Define cryptographic stream (always use Read mode for encryption). - CryptoStream cryptoStream = new CryptoStream(memoryStream, - decryptor, - CryptoStreamMode.Read); - - // Since at this point we don't know what the size of decrypted data - // will be, allocate the buffer long enough to hold ciphertext; - // plaintext is never longer than ciphertext. - byte[] plainTextBytes = new byte[cipherTextBytes.Length]; - - // Start decrypting. - int decryptedByteCount = cryptoStream.Read(plainTextBytes, - 0, - plainTextBytes.Length); - - // Close both streams. - memoryStream.Close(); - cryptoStream.Close(); - - byte[] plainText = new byte[decryptedByteCount]; - int i; - for (i = 0; i < decryptedByteCount; i++) - plainText[i] = plainTextBytes[i]; - - // Return decrypted string. - return plainText; - } - } - #endregion - - public CryptoGridAssetClient() {} - - public CryptoGridAssetClient(string serverUrl, string keydir, bool decOnly) - { - m_log.Debug("[CRYPTOGRID] Direct constructor"); - Initialise(serverUrl, keydir, decOnly); - } - - public void Initialise(string serverUrl, string keydir, bool decOnly) - { - - m_log.Debug("[CRYPTOGRID] Common constructor"); - - _assetServerUrl = serverUrl; - - string[] keys = Directory.GetFiles(keydir, "*.deckey"); - foreach (string key in keys) - { - XmlSerializer xs = new XmlSerializer(typeof (RjinKeyfile)); - FileStream file = new FileStream(key, FileMode.Open, FileAccess.Read); - - RjinKeyfile rjkey = (RjinKeyfile) xs.Deserialize(file); - - file.Close(); - - m_keyfiles.Add(rjkey.AlsoKnownAs, rjkey); - } - - - keys = Directory.GetFiles(keydir, "*.enckey"); - if (keys.Length == 1) - { - string Ekey = keys[0]; - XmlSerializer Exs = new XmlSerializer(typeof (RjinKeyfile)); - FileStream Efile = new FileStream(Ekey, FileMode.Open, FileAccess.Read); - - RjinKeyfile Erjkey = (RjinKeyfile) Exs.Deserialize(Efile); - - Efile.Close(); - - m_keyfiles.Add(Erjkey.AlsoKnownAs, Erjkey); - - m_encryptKey = Erjkey; - } else - { - if (keys.Length > 1) - throw new Exception( - "You have more than one asset *encryption* key. (You should never have more than one)," + - "If you downloaded this key from someone, rename it to .deckey to convert it to" + - "a decryption-only key."); - - m_log.Warn("No encryption key found, generating a new one for you..."); - RjinKeyfile encKey = new RjinKeyfile(); - encKey.GenerateRandom(); - - m_encryptKey = encKey; - - FileStream encExportFile = new FileStream("mysecretkey_rename_me.enckey",FileMode.CreateNew); - XmlSerializer xs = new XmlSerializer(typeof(RjinKeyfile)); - xs.Serialize(encExportFile, encKey); - encExportFile.Flush(); - encExportFile.Close(); - - m_log.Info( - "Encryption file generated, please rename 'mysecretkey_rename_me.enckey' to something more appropriate (however preserve the file extension)."); - } - - // If Decrypt-Only, dont encrypt on upload - m_encryptOnUpload = !decOnly; - } - - private static void EncryptAssetBase(AssetBase x, RjinKeyfile file) - { - // Make a salt - RNGCryptoServiceProvider RandomGen = new RNGCryptoServiceProvider(); - byte[] rand = new byte[32]; - RandomGen.GetBytes(rand); - - string salt = Convert.ToBase64String(rand); - - x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); - x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", - "OPENSIM_AES_AF1", - file.AlsoKnownAs, - salt, - x.Description); - } - - private bool DecryptAssetBase(AssetBase x) - { - // Check it's encrypted first. - if (!x.Description.Contains("ENCASS")) - return true; - - // ENCASS:ALG:AKA:SALT:Description - // 0 1 2 3 4 - string[] splitchars = new string[1]; - splitchars[0] = "#:~:#"; - - string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); - if (meta.Length < 5) - { - m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); - return false; - } - - // Check if we have a matching key - if (m_keyfiles.ContainsKey(meta[2])) - { - RjinKeyfile deckey = m_keyfiles[meta[2]]; - x.Description = meta[4]; - switch (meta[1]) - { - case "OPENSIM_AES_AF1": - x.Data = UtilRijndael.Decrypt(x.Data, - deckey.Secret, - meta[3], - "SHA1", - 2, - deckey.IVBytes, - deckey.Keysize); - // Decrypted Successfully - return true; - default: - m_log.Warn( - "[ENCASSETS] Recieved Encrypted Asset, but we dont know how to decrypt '" + meta[1] + "'."); - // We dont understand this encryption scheme - return false; - } - } - - m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but we do not have the decryption key."); - return false; - } - - #region IAssetServer Members - - protected override AssetBase GetAsset(AssetRequest req) - { -#if DEBUG - //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); -#endif - - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(req.AssetID.ToString()); - if (req.IsTexture) - rc.AddQueryParameter("texture"); - - rc.RequestMethod = "GET"; - - Stream s = rc.Request(); - - if (s == null) - return null; - - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - - AssetBase encAsset = (AssetBase)xs.Deserialize(s); - - // Try decrypt it - if (DecryptAssetBase(encAsset)) - return encAsset; - } - - return null; - } - - public override void UpdateAsset(AssetBase asset) - { - throw new Exception("The method or operation is not implemented."); - } - - public override void StoreAsset(AssetBase asset) - { - if (m_encryptOnUpload) - EncryptAssetBase(asset, m_encryptKey); - - try - { - string assetUrl = _assetServerUrl + "/assets/"; - - m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); - - RestObjectPoster.BeginPostObject(assetUrl, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[CRYPTO GRID ASSET CLIENT]: {0}", e); - } - } - - #endregion - } -} diff --git a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs b/OpenSim/Framework/Communications/Cache/FileAssetClient.cs deleted file mode 100644 index 8d03f56..0000000 --- a/OpenSim/Framework/Communications/Cache/FileAssetClient.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Reflection; -using log4net; -using System.Xml.Serialization; - -namespace OpenSim.Framework.Communications.Cache -{ - public class FileAssetClient : AssetServerBase - { - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region IPlugin - - public override string Name - { - get { return "File"; } - } - - public override string Version - { - get { return "1.0"; } - } - - public override void Initialise(ConfigSettings p_set, string p_url) - { - m_log.Debug("[FILEASSET] Plugin configured initialisation"); - Initialise(p_url); - } - - #endregion - - private string m_dir; - private readonly XmlSerializer m_xs = new XmlSerializer(typeof(AssetBase)); - - public FileAssetClient() {} - - public FileAssetClient(string p_url) - { - m_log.Debug("[FILEASSET] Direct constructor"); - Initialise(p_url); - } - - public void Initialise(string dir) - { - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - m_dir = dir; - } - - public override void StoreAsset(AssetBase asset) - { - byte[] idBytes = asset.FullID.Guid.ToByteArray(); - - string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] - + Path.DirectorySeparatorChar + idBytes[1]; - - if (!Directory.Exists(m_dir + Path.DirectorySeparatorChar + idBytes[0])) - Directory.CreateDirectory(m_dir + Path.DirectorySeparatorChar + idBytes[0]); - - if (!Directory.Exists(cdir)) - Directory.CreateDirectory(cdir); - - FileStream x = new FileStream(cdir + Path.DirectorySeparatorChar + asset.FullID + ".xml", FileMode.Create); - m_xs.Serialize(x, asset); - - x.Flush(); - x.Close(); - } - - public override void UpdateAsset(AssetBase asset) - { - StoreAsset(asset); - } - - protected override AssetBase GetAsset(AssetRequest req) - { - byte[] idBytes = req.AssetID.Guid.ToByteArray(); - - string cdir = m_dir + Path.DirectorySeparatorChar + idBytes[0] - + Path.DirectorySeparatorChar + idBytes[1]; - if (File.Exists(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml")) - { - FileStream x = File.OpenRead(cdir + Path.DirectorySeparatorChar + req.AssetID + ".xml"); - AssetBase ret = (AssetBase) m_xs.Deserialize(x); - x.Close(); - return ret; - } - return null; - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs deleted file mode 100644 index e070131..0000000 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ /dev/null @@ -1,140 +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 OpenSimulator 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.IO; -using System.Reflection; -using System.Xml.Serialization; -using log4net; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework.Communications.Cache -{ - public class GridAssetClient : AssetServerBase - { - #region IPlugin - - public override string Name - { - get { return "Grid"; } - } - - public override string Version - { - get { return "1.0"; } - } - - public override void Initialise(ConfigSettings p_set, string p_url) - { - m_log.Debug("[GRID ASSET CLIENT]: Plugin configured initialisation"); - Initialise(p_url); - } - - #endregion - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string _assetServerUrl; - - public GridAssetClient() {} - - public GridAssetClient(string p_url) - { - m_log.Debug("[GRID ASSET CLIENT]: Direct constructor"); - Initialise(p_url); - } - - public void Initialise(string serverUrl) - { - _assetServerUrl = serverUrl; - } - - #region IAssetServer Members - - protected override AssetBase GetAsset(AssetRequest req) - { - #if DEBUG - //m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString()); - #endif - - RestClient rc = new RestClient(_assetServerUrl); - rc.AddResourcePath("assets"); - rc.AddResourcePath(req.AssetID.ToString()); - - rc.RequestMethod = "GET"; - - Stream s = rc.Request(); - - if (s == null) - return null; - - if (s.Length > 0) - { - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); - - return (AssetBase) xs.Deserialize(s); - } - - return null; - } - - public override void UpdateAsset(AssetBase asset) - { - throw new Exception("The method or operation is not implemented."); - } - - public override void StoreAsset(AssetBase asset) - { - try - { - // MemoryStream s = new MemoryStream(); - - // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - // xs.Serialize(s, asset); - // RestClient rc = new RestClient(_assetServerUrl); - - string assetUrl = _assetServerUrl + "/assets/"; - - //rc.AddResourcePath("assets"); - - // rc.RequestMethod = "POST"; - // rc.Request(s); - //m_log.InfoFormat("[ASSET]: Stored {0}", rc); - - m_log.InfoFormat("[GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); - - RestObjectPoster.BeginPostObject(assetUrl, asset); - } - catch (Exception e) - { - m_log.ErrorFormat("[GRID ASSET CLIENT]: {0}", e); - } - } - - #endregion - } -} -- cgit v1.1 From d12c173a70cc58fb0ee575fa3a88259491bae0ed Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 09:01:07 -0700 Subject: AssetCache.addin.xml seems to be historical junk too. Removed. --- .../Communications/Resources/AssetCache.addin.xml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Resources/AssetCache.addin.xml (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml b/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml deleted file mode 100644 index 2ac6dca..0000000 --- a/OpenSim/Framework/Communications/Resources/AssetCache.addin.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - -- cgit v1.1 From 5d2a157e64f19a061a37d5458b34cc563ee288a1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 10:48:21 -0700 Subject: First pass at cleaning up old OGS1 and Local Inventory: removed everything-inventory in CommsManager, which wasn't actively used anymore. --- .../Communications/CommunicationsManager.cs | 114 --------------------- 1 file changed, 114 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e1a70e5..e9a6adb 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -109,120 +109,6 @@ namespace OpenSim.Framework.Communications m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); } - #region Inventory - protected string m_defaultInventoryHost = "default"; - - protected List m_inventoryServices = new List(); - // protected IInventoryServices m_inventoryService; - protected List m_secureinventoryServices = new List(); - - public ISecureInventoryService SecureInventoryService - { - get - { - if (m_secureinventoryServices.Count > 0) - { - // return m_inventoryServices[0]; - ISecureInventoryService invService; - if (TryGetSecureInventoryService(m_defaultInventoryHost, out invService)) - { - return invService; - } - } - return null; - } - } - - public IInventoryServices InventoryService - { - get - { - if (m_inventoryServices.Count > 0) - { - // return m_inventoryServices[0]; - IInventoryServices invService; - if (TryGetInventoryService(m_defaultInventoryHost, out invService)) - { - return invService; - } - } - return null; - } - } - - public bool TryGetSecureInventoryService(string host, out ISecureInventoryService inventoryService) - { - if ((host == string.Empty) || (host == "default")) - { - host = m_defaultInventoryHost; - } - - lock (m_secureinventoryServices) - { - foreach (ISecureInventoryService service in m_secureinventoryServices) - { - if (service.Host == host) - { - inventoryService = service; - return true; - } - } - } - - inventoryService = null; - return false; - } - - public bool TryGetInventoryService(string host, out IInventoryServices inventoryService) - { - if ((host == string.Empty) || (host == "default")) - { - host = m_defaultInventoryHost; - } - - lock (m_inventoryServices) - { - foreach (IInventoryServices service in m_inventoryServices) - { - if (service.Host == host) - { - inventoryService = service; - return true; - } - } - } - - inventoryService = null; - return false; - } - - public virtual void AddInventoryService(string hostUrl) - { - - } - - public virtual void AddSecureInventoryService(string hostUrl) - { - - } - - public virtual void AddSecureInventoryService(ISecureInventoryService service) - { - lock (m_secureinventoryServices) - { - m_secureinventoryServices.Add(service); - } - } - - public virtual void AddInventoryService(IInventoryServices service) - { - lock (m_inventoryServices) - { - m_inventoryServices.Add(service); - } - } - - #endregion #region Friend Methods -- cgit v1.1 From 34d0f119cbb28839ba73f834fae99d501d771211 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 11:48:30 -0700 Subject: Conditional to prevent a null ref in tests. The tests may still not pass. --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b9044eb..bd5d0e3 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -698,7 +698,7 @@ namespace OpenSim.Framework.Communications if (rootfolder != null) userProf.RootInventoryFolderID = rootfolder.ID; } - else + else if (m_commsManager.InterServiceInventoryService != null) { // used by the user server m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); -- cgit v1.1 From 17cc9b98573a1c4dd4a69113eea90c7fbeccad83 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 12:44:15 -0700 Subject: Last piece of cleaning up old inventory. Old IInventoryServices and ISecureInventoryService interfaces removed. --- .../Framework/Communications/IInventoryServices.cs | 137 --------------------- .../Communications/ISecureInventoryService.cs | 117 ------------------ .../Communications/InventoryServiceBase.cs | 6 +- 3 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IInventoryServices.cs delete mode 100644 OpenSim/Framework/Communications/ISecureInventoryService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs deleted file mode 100644 index 166b9aa..0000000 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework.Communications.Cache; - -namespace OpenSim.Framework.Communications -{ - /// - /// Callback used when a user's inventory is received from the inventory service - /// - public delegate void InventoryReceiptCallback( - ICollection folders, ICollection items); - - /// - /// Defines all the operations one can perform on a user's inventory. - /// - public interface IInventoryServices - { - string Host - { - get; - } - - /// - /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the - /// inventory has been received - /// - /// - /// - void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback); - - /// - /// Add a new folder to the user's inventory - /// - /// - /// true if the folder was successfully added - bool AddFolder(InventoryFolderBase folder); - - /// - /// Update a folder in the user's inventory - /// - /// - /// true if the folder was successfully updated - bool UpdateFolder(InventoryFolderBase folder); - - /// - /// Move an inventory folder to a new location - /// - /// A folder containing the details of the new location - /// true if the folder was successfully moved - bool MoveFolder(InventoryFolderBase folder); - - /// - /// Purge an inventory folder of all its items and subfolders. - /// - /// - /// true if the folder was successfully purged - bool PurgeFolder(InventoryFolderBase folder); - - /// - /// Add a new item to the user's inventory - /// - /// - /// true if the item was successfully added - bool AddItem(InventoryItemBase item); - - /// - /// Update an item in the user's inventory - /// - /// - /// true if the item was successfully updated - bool UpdateItem(InventoryItemBase item); - - /// - /// Delete an item from the user's inventory - /// - /// - /// true if the item was successfully deleted - bool DeleteItem(InventoryItemBase item); - - /// - /// Query the server for an item that may have been added by - /// another region - /// - /// - /// true if the item was found in local cache - InventoryItemBase QueryItem(InventoryItemBase item); - - /// - /// Query the server for a folder that may have been added by - /// another region - /// - /// - /// true if the folder was found in local cache - InventoryFolderBase QueryFolder(InventoryFolderBase folder); - - /// - /// Does the given user have an inventory structure? - /// - /// - /// - bool HasInventoryForUser(UUID userID); - - /// - /// Retrieve the root inventory folder for the given user. - /// - /// - /// null if no root folder was found - InventoryFolderBase RequestRootFolder(UUID userID); - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs deleted file mode 100644 index ef2b40c..0000000 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - /// - /// Defines all the operations one can perform on a user's inventory. - /// - public interface ISecureInventoryService - { - string Host - { - get; - } - - /// - /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the - /// inventory has been received - /// - /// - /// - void RequestInventoryForUser(UUID userID, UUID session_id, InventoryReceiptCallback callback); - - /// - /// Add a new folder to the user's inventory - /// - /// - /// true if the folder was successfully added - bool AddFolder(InventoryFolderBase folder, UUID session_id); - - /// - /// Update a folder in the user's inventory - /// - /// - /// true if the folder was successfully updated - bool UpdateFolder(InventoryFolderBase folder, UUID session_id); - - /// - /// Move an inventory folder to a new location - /// - /// A folder containing the details of the new location - /// true if the folder was successfully moved - bool MoveFolder(InventoryFolderBase folder, UUID session_id); - - /// - /// Purge an inventory folder of all its items and subfolders. - /// - /// - /// true if the folder was successfully purged - bool PurgeFolder(InventoryFolderBase folder, UUID session_id); - - /// - /// Add a new item to the user's inventory - /// - /// - /// true if the item was successfully added - bool AddItem(InventoryItemBase item, UUID session_id); - - /// - /// Update an item in the user's inventory - /// - /// - /// true if the item was successfully updated - bool UpdateItem(InventoryItemBase item, UUID session_id); - - /// - /// Delete an item from the user's inventory - /// - /// - /// true if the item was successfully deleted - bool DeleteItem(InventoryItemBase item, UUID session_id); - - InventoryItemBase QueryItem(InventoryItemBase item, UUID session_id); - - InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id); - - /// - /// Does the given user have an inventory structure? - /// - /// - /// - bool HasInventoryForUser(UUID userID); - - /// - /// Retrieve the root inventory folder for the given user. - /// - /// - /// null if no root folder was found - InventoryFolderBase RequestRootFolder(UUID userID); - } -} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index a51de2d..309c415 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -36,8 +36,9 @@ namespace OpenSim.Framework.Communications /// /// Abstract base class used by local and grid implementations of an inventory service. /// - public abstract class InventoryServiceBase : IInventoryServices, IInterServiceInventoryServices + public abstract class InventoryServiceBase : IInterServiceInventoryServices { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -153,9 +154,6 @@ namespace OpenSim.Framework.Communications return false; } - // See IInventoryServices - public abstract void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback); - public List GetActiveGestures(UUID userId) { List activeGestures = new List(); -- cgit v1.1 From 0c47f8e7ab1a1c28de218a3338143038ccaaa4a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 16:02:09 -0700 Subject: Changed RequestRootFolder to GetRootFolder --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 47e0293..373d7cf 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -552,7 +552,7 @@ namespace OpenSim.Framework.Communications.Tests return false; } - public InventoryFolderBase RequestRootFolder(UUID userID) + public InventoryFolderBase GetRootFolder(UUID userID) { InventoryFolderBase root = new InventoryFolderBase(); root.ID = UUID.Random(); diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bd5d0e3..58174a0 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -694,7 +694,7 @@ namespace OpenSim.Framework.Communications // local service (standalone) m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); m_InventoryService.CreateUserInventory(userProf.ID); - InventoryFolderBase rootfolder = m_InventoryService.RequestRootFolder(userProf.ID); + InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID); if (rootfolder != null) userProf.RootInventoryFolderID = rootfolder.ID; } -- cgit v1.1 From cdcbc48534f19afe7cbdeb6c690e6b7d9f2ff099 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 20:31:51 -0700 Subject: Added two new methods to IIventoryService -- GetFolderForType and GetFolderContent. Some meat to it, but not completed. None of this code is called anywhere yet. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 373d7cf..17a3393 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -497,6 +497,16 @@ namespace OpenSim.Framework.Communications.Tests { } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return null; + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + return null; + } + public List GetFolderItems(UUID userID, UUID folderID) { return null; -- cgit v1.1 From 18aa2ea0c5ebd8d5131902ed9856e68f46e76e11 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Tue, 11 Aug 2009 12:07:54 -0300 Subject: * Improves SceneSetupHelper to allow the tester to choose a real or mock, inventory and asset, service modules. The boolean startServices was replaced with realServices string. If the string contains the word asset, it will start a real asset module, if it contains inventory, it starts a real inventory. Otherwise, it use mock (NullPlugin-like) objects, for tests that don't really need functionality. * SetupScene is now actually sharing the asset and inventory modules if the tester wishes to have multiple regions connected. To link regions, just start SetupScene with the same CommunicationManager for all scenes. SceneSetupHelper will hold a static reference to the modules and won't initialize them again, just run the scenes through the modules AddRegion, RegionLoaded and PostInitialize. * With the recent changes, both asset and inventory (and in the future, user) services should always be asked from the scene, not instantiated alone. The tests should reflect this new behavior and always start a scene. --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 13 ++- .../Communications/Tests/LoginServiceTests.cs | 128 ++------------------- .../Framework/Communications/UserManagerBase.cs | 2 +- 3 files changed, 15 insertions(+), 128 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index fdc20dd..0402883 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -54,6 +54,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo nonExistingUserInfo; TestCommunicationsManager commsManager = new TestCommunicationsManager(); + Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); // Check we can't retrieve info before it exists by uuid nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); @@ -116,7 +117,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { @@ -132,7 +133,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { @@ -154,7 +155,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { @@ -190,7 +191,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { @@ -256,7 +257,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { @@ -297,7 +298,7 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); - Scene myScene = SceneSetupHelpers.SetupScene(); + Scene myScene = SceneSetupHelpers.SetupScene("inventory"); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); for (int i = 0 ; i < 50 ; i++) { diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 47e0293..9e181f3 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -36,6 +36,7 @@ using Nwc.XmlRpc; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Services; using OpenSim.Region.Communications.Local; +using OpenSim.Tests.Common.Setup; using OpenSim.Tests.Common.Mock; using OpenSim.Client.Linden; using OpenSim.Tests.Common; @@ -57,11 +58,12 @@ namespace OpenSim.Framework.Communications.Tests private string m_regionExternalName = "localhost"; private IPEndPoint m_capsEndPoint; - private CommunicationsManager m_commsManager; + private TestCommunicationsManager m_commsManager; private TestLoginToRegionConnector m_regionConnector; private LocalUserServices m_localUserServices; private LoginService m_loginService; private UserProfileData m_userProfileData; + private TestScene m_testScene; [SetUp] public void SetUpLoginEnviroment() @@ -69,13 +71,16 @@ namespace OpenSim.Framework.Communications.Tests m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); m_regionConnector = new TestLoginToRegionConnector(); + m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, ""); m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); + //IInventoryService m_inventoryService = new TestInventoryService(); + m_localUserServices = (LocalUserServices) m_commsManager.UserService; m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); - m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", new TestInventoryService(), + m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_testScene.InventoryService, m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector); m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); @@ -442,123 +447,4 @@ namespace OpenSim.Framework.Communications.Tests #endregion } } - - class TestInventoryService : IInventoryService - { - public TestInventoryService() - { - } - - /// - /// - /// - /// - /// - public bool CreateUserInventory(UUID userId) - { - return false; - } - - /// - /// - /// - /// - /// - public List GetInventorySkeleton(UUID userId) - { - List folders = new List(); - InventoryFolderBase folder = new InventoryFolderBase(); - folder.ID = UUID.Random(); - folder.Owner = userId; - folders.Add(folder); - return folders; - } - - /// - /// Returns a list of all the active gestures in a user's inventory. - /// - /// - /// The of the user - /// - /// - /// A flat list of the gesture items. - /// - public List GetActiveGestures(UUID userId) - { - return null; - } - - public InventoryCollection GetUserInventory(UUID userID) - { - return null; - } - - public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) - { - } - - public List GetFolderItems(UUID userID, UUID folderID) - { - return null; - } - - public bool AddFolder(InventoryFolderBase folder) - { - return false; - } - - public bool UpdateFolder(InventoryFolderBase folder) - { - return false; - } - - public bool MoveFolder(InventoryFolderBase folder) - { - return false; - } - - public bool PurgeFolder(InventoryFolderBase folder) - { - return false; - } - - public bool AddItem(InventoryItemBase item) - { - return false; - } - - public bool UpdateItem(InventoryItemBase item) - { - return false; - } - - public bool DeleteItem(InventoryItemBase item) - { - return false; - } - - public InventoryItemBase QueryItem(InventoryItemBase item) - { - return null; - } - - public InventoryFolderBase QueryFolder(InventoryFolderBase folder) - { - return null; - } - - public bool HasInventoryForUser(UUID userID) - { - return false; - } - - public InventoryFolderBase RequestRootFolder(UUID userID) - { - InventoryFolderBase root = new InventoryFolderBase(); - root.ID = UUID.Random(); - root.Owner = userID; - root.ParentID = UUID.Zero; - return root; - } - } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bd5d0e3..b9044eb 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -698,7 +698,7 @@ namespace OpenSim.Framework.Communications if (rootfolder != null) userProf.RootInventoryFolderID = rootfolder.ID; } - else if (m_commsManager.InterServiceInventoryService != null) + else { // used by the user server m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); -- cgit v1.1 From 226c082ed417f4a5f2295595e45eca2fcb1e42c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 11 Aug 2009 16:45:16 +0100 Subject: Establish CachedUserInfo.OnInventoryReceived event so that region/test inventory code can be written with the async inventory fetch --- .../Communications/Cache/CachedUserInfo.cs | 19 ++++- .../Tests/Cache/UserProfileCacheServiceTests.cs | 96 ++++++++++++---------- 2 files changed, 68 insertions(+), 47 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 10aff42..8ee1b1a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); public delegate void OnItemReceivedDelegate(UUID itemID); + public delegate void OnInventoryReceivedDelegate(UUID userID); /// /// Stores user profile and inventory data received from backend services for a particular user. /// public class CachedUserInfo - { + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + //// + /// Fired when a particular item has been received from the inventory service + /// public event OnItemReceivedDelegate OnItemReceived; - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Fired once the entire inventory has been received for the user + /// + public event OnInventoryReceivedDelegate OnInventoryReceived; /// /// The comms manager holds references to services (user, grid, inventory, etc.) @@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache UUID parentFolderId = folder.ParentID; if (dictionary.ContainsKey(parentFolderId)) + { dictionary[parentFolderId].Add(folder); + } else { IList folders = new List(); @@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache request.Execute(); } } + + if (OnInventoryReceived != null) + OnInventoryReceived(UserProfile.ID); } /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 0402883..fe88cf5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests [TestFixture] public class UserProfileCacheServiceTests { + /// Used by tests to indicate whether an async operation timed out + private bool timedOut; + + private void InventoryReceived(UUID userId) + { + lock (this) + { + timedOut = false; + Monitor.PulseAll(this); + } + } + [Test] public void TestGetUserDetails() { @@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); - } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); + + timedOut = true; + lock (this) + { + UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); + } + + Assert.That(timedOut, Is.False, "Timed out"); } [Test] @@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); + CachedUserInfo userInfo; + + lock (this) + { + userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); @@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); + CachedUserInfo userInfo; + + lock (this) + { + userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); @@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); + CachedUserInfo userInfo; + + lock (this) + { + userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); InventoryFolderImpl rootFolder = userInfo.RootFolder; @@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); + CachedUserInfo userInfo; + + lock (this) + { + userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); @@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests //log4net.Config.XmlConfigurator.Configure(); Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); + CachedUserInfo userInfo; + + lock (this) + { + userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); + Monitor.Wait(this, 60000); } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); InventoryFolderImpl rootFolder = userInfo.RootFolder; @@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); } } -} +} \ No newline at end of file -- cgit v1.1 From bd7ff803fe189ffd730599350429d9b9d41582be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 11 Aug 2009 14:31:45 -0700 Subject: Re-adding a conditional in UserManager that was removed with arthusv's commit. Changing new inventory ops to POST. --- OpenSim/Framework/Communications/UserManagerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 7ad6bbf..58174a0 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -698,7 +698,7 @@ namespace OpenSim.Framework.Communications if (rootfolder != null) userProf.RootInventoryFolderID = rootfolder.ID; } - else + else if (m_commsManager.InterServiceInventoryService != null) { // used by the user server m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); -- cgit v1.1 From 5246dc33dcfc51b7ebb19b269159df3991029350 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 13 Aug 2009 14:10:12 -0700 Subject: Renamed QueryItem/QueryFolder to GetItem/GetFolder. The word 'query' starting to get on my nerves. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ++-- .../Tests/Cache/UserProfileCacheServiceTests.cs | 14 +++++++------- .../Framework/Communications/Tests/LoginServiceTests.cs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 8ee1b1a..ca641d0 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -747,7 +747,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase itemInfo = null; - itemInfo = m_InventoryService.QueryItem(item); + itemInfo = m_InventoryService.GetItem(item); if (itemInfo != null) { @@ -784,7 +784,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderBase folderInfo = null; - folderInfo = m_InventoryService.QueryFolder(folder); + folderInfo = m_InventoryService.GetFolder(folder); if (folderInfo != null) { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index fe88cf5..670c9ff 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -186,14 +186,14 @@ namespace OpenSim.Framework.Communications.Tests Assert.That( userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); - Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); + Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); // 2: Try a folder create that should work Assert.That( userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); - Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null); + Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } @@ -228,7 +228,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); - InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder); + InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder); Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); } @@ -254,7 +254,7 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); - InventoryFolderBase dataFolder1 = myScene.InventoryService.QueryFolder(myFolder2); + InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2); Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); @@ -296,7 +296,7 @@ namespace OpenSim.Framework.Communications.Tests InventoryFolderBase myFolder = new InventoryFolderBase(); myFolder.ID = folderToMoveId; Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); - Assert.That(myScene.InventoryService.QueryFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); + Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); } @@ -322,13 +322,13 @@ namespace OpenSim.Framework.Communications.Tests myFolder.ID = folder1Id; userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Not.Null); + Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); // Test purge userInfo.PurgeFolder(rootFolder.ID); Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); - Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); + Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); } } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index b1b7809..3161364 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -552,12 +552,12 @@ namespace OpenSim.Framework.Communications.Tests return false; } - public InventoryItemBase QueryItem(InventoryItemBase item) + public InventoryItemBase GetItem(InventoryItemBase item) { return null; } - public InventoryFolderBase QueryFolder(InventoryFolderBase folder) + public InventoryFolderBase GetFolder(InventoryFolderBase folder) { return null; } -- cgit v1.1 From 034c9cf606373bfa9d3f8040cd787f789e0efbf2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 13 Aug 2009 17:34:15 -0700 Subject: Added GetAssetPermissions. Few last bugs nixed. This is ready for testing. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 3161364..22dcef9 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -575,5 +575,10 @@ namespace OpenSim.Framework.Communications.Tests root.ParentID = UUID.Zero; return root; } + + public int GetAssetPermissions(UUID userID, UUID assetID) + { + return 1; + } } } -- cgit v1.1 From 87f116ab3a23e662813fe35992db1169d350618c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 16 Aug 2009 19:51:16 -0700 Subject: Remove the call to ResetAttachments upon login. The info in the DB should always have {itemID, assetID}. --- OpenSim/Framework/Communications/Services/LoginService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 9709975..1b4c016 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -205,6 +205,7 @@ namespace OpenSim.Framework.Communications.Services // Otherwise... // Create a new agent session + // XXYY we don't need this m_userManager.ResetAttachments(userProfile.ID); CreateAgent(userProfile, request); @@ -462,7 +463,8 @@ namespace OpenSim.Framework.Communications.Services // Otherwise... // Create a new agent session - m_userManager.ResetAttachments(userProfile.ID); + // XXYY We don't need this + //m_userManager.ResetAttachments(userProfile.ID); CreateAgent(userProfile, request); -- cgit v1.1 From 67a629081eaf28176aa7920e4a4aba8497905cfb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 16 Aug 2009 19:54:49 -0700 Subject: uh. how about *really* removing it, and not just write a comment above, hey diva? --- OpenSim/Framework/Communications/Services/LoginService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 1b4c016..8a8108b 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -206,7 +206,7 @@ namespace OpenSim.Framework.Communications.Services // Create a new agent session // XXYY we don't need this - m_userManager.ResetAttachments(userProfile.ID); + //m_userManager.ResetAttachments(userProfile.ID); CreateAgent(userProfile, request); -- cgit v1.1 From 806f48d81a4d47779aef217ace2e141b590055ed Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 17 Aug 2009 17:00:27 -0700 Subject: Added one conditional missing on login, for creating inventory if it doesn't exist already. This hopefully fixes the master avatar problems on standalone. --- OpenSim/Framework/Communications/Services/LoginService.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 8a8108b..cac6616 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1131,7 +1131,18 @@ namespace OpenSim.Framework.Communications.Services // tools are creating the user profile directly in the database without creating the inventory. At // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already // exist. - if ((m_interInventoryService != null) && !m_interInventoryService.CreateNewUserInventory(userID)) + if (m_interInventoryService != null) + { + if (!m_interInventoryService.CreateNewUserInventory(userID)) + { + throw new Exception( + String.Format( + "The inventory creation request for user {0} did not succeed." + + " Please contact your inventory service provider for more information.", + userID)); + } + } + else if ((m_InventoryService != null) && !m_InventoryService.CreateUserInventory(userID)) { throw new Exception( String.Format( @@ -1140,6 +1151,7 @@ namespace OpenSim.Framework.Communications.Services userID)); } + m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); if (m_InventoryService != null) -- cgit v1.1 From c5af39239f7f2a1725d9c08bea80522de8835e0f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 00:13:51 -0700 Subject: A better purge of trash folder. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 +++- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index ca641d0..238810a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -653,7 +653,9 @@ namespace OpenSim.Framework.Communications.Cache if (RootFolder.DeleteItem(item.ID)) { - return m_InventoryService.DeleteItem(item); + List uuids = new List(); + uuids.Add(itemID); + return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids); } } else diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 22dcef9..d5d4d1e 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -547,7 +547,7 @@ namespace OpenSim.Framework.Communications.Tests return false; } - public bool DeleteItem(InventoryItemBase item) + public bool DeleteItems(UUID owner, List items) { return false; } -- cgit v1.1 From d519f1885f587409592cf92bc0f4ba8533a1866f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 10:56:08 -0700 Subject: Added MoveItems, which is most useful upon viewer-delete inventory operation. Moving a batch of items is a 1-time operation. Made it async anyway, so that the viewer doesn't wait in case the DB layer is dumb (which is the case currently). --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index d5d4d1e..6f86704 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -547,6 +547,11 @@ namespace OpenSim.Framework.Communications.Tests return false; } + public bool MoveItems(UUID owner, List items) + { + return false; + } + public bool DeleteItems(UUID owner, List items) { return false; -- cgit v1.1 From b1853d9f265fb32cf51d65fdcf2d5b4741911f00 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 23:25:12 -0500 Subject: Fixing a spot I missed in assets. Switching Grid to the new naming schema with Store/Get --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 2 +- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index c9f5236..7f1c7e9 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -184,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache // Commented out for now. The implementation needs to be improved by protecting against race conditions, // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via // returning a read only class from the cache). -// public bool UpdateProfile(UserProfileData userProfile) +// public bool StoreProfile(UserProfileData userProfile) // { // lock (m_userProfilesById) // { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 670c9ff..933fa12 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -110,14 +110,14 @@ namespace OpenSim.Framework.Communications.Tests IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; // Check that we can't update info before it exists - Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); + Assert.That(userCacheService.StoreProfile(newProfile), Is.False); Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); // Check that we can update a profile once it exists LocalUserServices lus = (LocalUserServices)commsManager.UserService; lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); - Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); + Assert.That(userCacheService.StoreProfile(newProfile), Is.True); UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); -- cgit v1.1 From 75021b5309c5e74c08feea5d508b69ce05491375 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 21 Aug 2009 21:31:18 -0700 Subject: Moved AuthedSessionCache to where it is used -- Grid/InventoryServer. --- .../Communications/Cache/AuthedSessionCache.cs | 133 ------ .../Communications/InventoryServiceBase.cs | 517 --------------------- 2 files changed, 650 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs delete mode 100644 OpenSim/Framework/Communications/InventoryServiceBase.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs b/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs deleted file mode 100644 index d56e48a..0000000 --- a/OpenSim/Framework/Communications/Cache/AuthedSessionCache.cs +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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; - -namespace OpenSim.Framework.Communications.Cache -{ - public class AuthedSessionCache - { - public class CacheData - { - private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); - private string m_session_id; - private string m_agent_id; - private int m_expire; - - private int get_current_unix_time() - { - return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; - } - - public CacheData(string sid, string aid) - { - m_session_id = sid; - m_agent_id = aid; - m_expire = get_current_unix_time() + DEFAULT_LIFETIME; - } - - public CacheData(string sid, string aid, int time_now) - { - m_session_id = sid; - m_agent_id = aid; - m_expire = time_now + DEFAULT_LIFETIME; - } - - public string SessionID - { - get { return m_session_id; } - set { m_session_id = value; } - } - - public string AgentID - { - get { return m_agent_id; } - set { m_agent_id = value; } - } - - public bool isExpired - { - get { return m_expire < get_current_unix_time(); } - } - - public void Renew() - { - m_expire = get_current_unix_time() + DEFAULT_LIFETIME; - } - } - - private static readonly int DEFAULT_LIFETIME = 30; - private Dictionary m_authed_sessions = new Dictionary(); - // private int m_session_lifetime = DEFAULT_LIFETIME; - - public AuthedSessionCache() - { - // m_session_lifetime = DEFAULT_LIFETIME; - } - - public AuthedSessionCache(int timeout) - { - // m_session_lifetime = timeout; - } - - public CacheData getCachedSession(string session_id, string agent_id) - { - CacheData ret = null; - lock (m_authed_sessions) - { - if (m_authed_sessions.ContainsKey(session_id)) - { - CacheData cached_session = m_authed_sessions[session_id]; - if (!cached_session.isExpired && cached_session.AgentID == agent_id) - { - ret = m_authed_sessions[session_id]; - // auto renew - m_authed_sessions[session_id].Renew(); - } - } - } - return ret; - } - - public void Add(string session_id, string agent_id) - { - CacheData data = new CacheData(session_id, agent_id); - lock (m_authed_sessions) - { - if (m_authed_sessions.ContainsKey(session_id)) - { - m_authed_sessions[session_id] = data; - } - else - { - m_authed_sessions.Add(session_id, data); - } - } - } - } -} diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs deleted file mode 100644 index 309c415..0000000 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Data; - -namespace OpenSim.Framework.Communications -{ - /// - /// Abstract base class used by local and grid implementations of an inventory service. - /// - public abstract class InventoryServiceBase : IInterServiceInventoryServices - { - - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected List m_plugins = new List(); - - #region Plugin methods - - /// - /// Add a new inventory data plugin - plugins will be requested in the order they were added. - /// - /// The plugin that will provide data - public void AddPlugin(IInventoryDataPlugin plugin) - { - m_plugins.Add(plugin); - } - - /// - /// Adds a list of inventory data plugins, as described by `provider' - /// and `connect', to `m_plugins'. - /// - /// - /// The filename of the inventory server plugin DLL. - /// - /// - /// The connection string for the storage backend. - /// - public void AddPlugin(string provider, string connect) - { - m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); - } - - #endregion - - #region IInventoryServices methods - - public string Host - { - get { return "default"; } - } - - public List GetInventorySkeleton(UUID userId) - { -// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); - - InventoryFolderBase rootFolder = RequestRootFolder(userId); - - // Agent has no inventory structure yet. - if (null == rootFolder) - { - return null; - } - - List userFolders = new List(); - - userFolders.Add(rootFolder); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - IList folders = plugin.getFolderHierarchy(rootFolder.ID); - userFolders.AddRange(folders); - } - -// foreach (InventoryFolderBase folder in userFolders) -// { -// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); -// } - - return userFolders; - } - - // See IInventoryServices - public virtual bool HasInventoryForUser(UUID userID) - { - return false; - } - - // See IInventoryServices - public virtual InventoryFolderBase RequestRootFolder(UUID userID) - { - // Retrieve the first root folder we get from the list of plugins. - foreach (IInventoryDataPlugin plugin in m_plugins) - { - InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID); - if (rootFolder != null) - return rootFolder; - } - - // Return nothing if no plugin was able to supply a root folder - return null; - } - - // See IInventoryServices - public bool CreateNewUserInventory(UUID user) - { - InventoryFolderBase existingRootFolder = RequestRootFolder(user); - - if (null != existingRootFolder) - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " - + "a root inventory folder with id {1}", - user, existingRootFolder.ID); - } - else - { - UsersInventory inven = new UsersInventory(); - inven.CreateNewInventorySet(user); - AddNewInventorySet(inven); - - return true; - } - - return false; - } - - public List GetActiveGestures(UUID userId) - { - List activeGestures = new List(); - foreach (IInventoryDataPlugin plugin in m_plugins) - { - activeGestures.AddRange(plugin.fetchActiveGestures(userId)); - } - - return activeGestures; - } - - #endregion - - #region Methods used by GridInventoryService - - public List RequestSubFolders(UUID parentFolderID) - { - List inventoryList = new List(); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID)); - } - - return inventoryList; - } - - public List RequestFolderItems(UUID folderID) - { - List itemsList = new List(); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - itemsList.AddRange(plugin.getInventoryInFolder(folderID)); - } - - return itemsList; - } - - #endregion - - // See IInventoryServices - public virtual bool AddFolder(InventoryFolderBase folder) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.addInventoryFolder(folder); - } - - // FIXME: Should return false on failure - return true; - } - - // See IInventoryServices - public virtual bool UpdateFolder(InventoryFolderBase folder) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.updateInventoryFolder(folder); - } - - // FIXME: Should return false on failure - return true; - } - - // See IInventoryServices - public virtual bool MoveFolder(InventoryFolderBase folder) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.moveInventoryFolder(folder); - } - - // FIXME: Should return false on failure - return true; - } - - // See IInventoryServices - public virtual bool AddItem(InventoryItemBase item) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.addInventoryItem(item); - } - - // FIXME: Should return false on failure - return true; - } - - // See IInventoryServices - public virtual bool UpdateItem(InventoryItemBase item) - { - m_log.InfoFormat( - "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.updateInventoryItem(item); - } - - // FIXME: Should return false on failure - return true; - } - - // See IInventoryServices - public virtual bool DeleteItem(InventoryItemBase item) - { - m_log.InfoFormat( - "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.deleteInventoryItem(item.ID); - } - - // FIXME: Should return false on failure - return true; - } - - public virtual InventoryItemBase QueryItem(InventoryItemBase item) - { - foreach (IInventoryDataPlugin plugin in m_plugins) - { - InventoryItemBase result = plugin.queryInventoryItem(item.ID); - if (result != null) - return result; - } - - return null; - } - - public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) - { - foreach (IInventoryDataPlugin plugin in m_plugins) - { - InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); - if (result != null) - return result; - } - - return null; - } - - /// - /// Purge a folder of all items items and subfolders. - /// - /// FIXME: Really nasty in a sense, because we have to query the database to get information we may - /// already know... Needs heavy refactoring. - /// - /// - public virtual bool PurgeFolder(InventoryFolderBase folder) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); - - List subFolders = RequestSubFolders(folder.ID); - - foreach (InventoryFolderBase subFolder in subFolders) - { -// m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); - - foreach (IInventoryDataPlugin plugin in m_plugins) - { - plugin.deleteInventoryFolder(subFolder.ID); - } - } - - List items = RequestFolderItems(folder.ID); - - foreach (InventoryItemBase item in items) - { - DeleteItem(item); - } - - // FIXME: Should return false on failure - return true; - } - - private void AddNewInventorySet(UsersInventory inventory) - { - foreach (InventoryFolderBase folder in inventory.Folders.Values) - { - AddFolder(folder); - } - } - - public InventoryItemBase GetInventoryItem(UUID itemID) - { - foreach (IInventoryDataPlugin plugin in m_plugins) - { - InventoryItemBase item = plugin.getInventoryItem(itemID); - if (item != null) - return item; - } - - return null; - } - - /// - /// Used to create a new user inventory. - /// - private class UsersInventory - { - public Dictionary Folders = new Dictionary(); - public Dictionary Items = new Dictionary(); - - public virtual void CreateNewInventorySet(UUID user) - { - InventoryFolderBase folder = new InventoryFolderBase(); - - folder.ParentID = UUID.Zero; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "My Inventory"; - folder.Type = (short)AssetType.Folder; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - UUID rootFolder = folder.ID; - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Animations"; - folder.Type = (short)AssetType.Animation; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Body Parts"; - folder.Type = (short)AssetType.Bodypart; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Calling Cards"; - folder.Type = (short)AssetType.CallingCard; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Clothing"; - folder.Type = (short)AssetType.Clothing; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Gestures"; - folder.Type = (short)AssetType.Gesture; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Landmarks"; - folder.Type = (short)AssetType.Landmark; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Lost And Found"; - folder.Type = (short)AssetType.LostAndFoundFolder; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Notecards"; - folder.Type = (short)AssetType.Notecard; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Objects"; - folder.Type = (short)AssetType.Object; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Photo Album"; - folder.Type = (short)AssetType.SnapshotFolder; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Scripts"; - folder.Type = (short)AssetType.LSLText; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Sounds"; - folder.Type = (short)AssetType.Sound; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Textures"; - folder.Type = (short)AssetType.Texture; - folder.Version = 1; - Folders.Add(folder.ID, folder); - - folder = new InventoryFolderBase(); - folder.ParentID = rootFolder; - folder.Owner = user; - folder.ID = UUID.Random(); - folder.Name = "Trash"; - folder.Type = (short)AssetType.TrashFolder; - folder.Version = 1; - Folders.Add(folder.ID, folder); - } - } - } -} -- cgit v1.1 From b03eeeb9f6331ed36c61f55aef847ce3b2db7ba4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 22 Aug 2009 10:24:26 -0700 Subject: * Fixes mantis http://opensimulator.org/mantis/view.php?id=4044. Turns out folders were never being removed from trash when they were singled out for purging in trash. They were being removed when Trash was purged as a whole. That behavior is now fixed for the new InventoryService set. * Removed left-overs from AssetInventoryServer. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 6f86704..57a908e 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -532,6 +532,11 @@ namespace OpenSim.Framework.Communications.Tests return false; } + public bool DeleteFolders(UUID ownerID, List ids) + { + return false; + } + public bool PurgeFolder(InventoryFolderBase folder) { return false; -- cgit v1.1 From 6f077d5e5f9929f6593850dc096983dcf237e387 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 26 Aug 2009 21:05:46 -0400 Subject: * Another attempt at fixing the random spurious test error. * This time it might be the listening socket thread from HttpServer aborting with a non blocking thread abort exception. Hopefully calling Stop() on MainServer.Instance will solve that. --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 11 +++++++++++ OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 10 ++++++++++ 2 files changed, 21 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 933fa12..2bb0926 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -330,5 +330,16 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); } + + [TearDown] + public void TearDown() + { + try + { + if (MainServer.Instance != null) MainServer.Instance.Stop(); + } + catch (System.NullReferenceException) + { } + } } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 57a908e..0a9d2ae 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -362,6 +362,16 @@ namespace OpenSim.Framework.Communications.Tests //Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); } + [TearDown] + public void TearDown() + { + try + { + if (MainServer.Instance != null) MainServer.Instance.Stop(); + } catch (NullReferenceException) + {} + } + public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector { private List m_regionsList = new List(); -- cgit v1.1 From d649194be310bf267675ac3cd9f9fce302cc3798 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 12:52:40 +0100 Subject: minor: formatting and comments --- OpenSim/Framework/Communications/Services/LoginService.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index cac6616..bf59f8e 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1063,7 +1063,18 @@ namespace OpenSim.Framework.Communications.Services protected abstract RegionInfo RequestClosestRegion(string region); protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); + + /// + /// Prepare a login to the given region. This involves both telling the region to expect a connection + /// and appropriately customising the response to the user. + /// + /// + /// + /// + /// + /// true if the region was successfully contacted, false otherwise + protected abstract bool PrepareLoginToRegion( + RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); /// /// Add active gestures of the user to the login response. -- cgit v1.1 From 05756e1fb96aa47f9ff111dd04499934c7077731 Mon Sep 17 00:00:00 2001 From: dr scofield (aka dirk husemann) Date: Wed, 2 Sep 2009 09:43:22 +0200 Subject: warnings safari. --- .../Communications/Tests/Cache/UserProfileCacheServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 2bb0926..e5d8895 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo nonExistingUserInfo; TestCommunicationsManager commsManager = new TestCommunicationsManager(); - Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); + // Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); // Check we can't retrieve info before it exists by uuid nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); -- cgit v1.1 From 0683cf6e0d541571d04d6511dc0ecabb17dd1e1e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Sep 2009 18:03:49 +0100 Subject: Add test to check behaviour if an iar is loaded where no user profile exists for the creators Disable generation of temporary profiles for now, instead record loading user as creator --- OpenSim/Framework/Communications/Osp/OspResolver.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 502fee3..e98317a 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -153,7 +153,9 @@ namespace OpenSim.Framework.Communications.Osp CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (userInfo != null) return userInfo.UserProfile.ID; - + + // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc + /* UserProfileData tempUserProfile = new UserProfileData(); tempUserProfile.FirstName = firstName; tempUserProfile.SurName = lastName; @@ -164,6 +166,9 @@ namespace OpenSim.Framework.Communications.Osp commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); return tempUserProfile.ID; + */ + + return UUID.Zero; } } } -- cgit v1.1 From 03438f7d449a09e28dcb1543b2075d70b2573ffc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Sep 2009 16:24:26 +0100 Subject: minor: remove double initialization of user appearance module in Grid.UserServer.Main --- OpenSim/Framework/Communications/Services/LoginService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index bf59f8e..a6cd918 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1221,11 +1221,13 @@ namespace OpenSim.Framework.Communications.Services { return Util.CreateUnknownUserErrorResponse(); } + UUID.TryParse((string)requestData["session_id"], out guess_sid); if (guess_sid == UUID.Zero) { return Util.CreateUnknownUserErrorResponse(); } + if (m_userManager.VerifySession(guess_aid, guess_sid)) { authed = "TRUE"; @@ -1243,6 +1245,5 @@ namespace OpenSim.Framework.Communications.Services response.Value = responseData; return response; } - } -} +} \ No newline at end of file -- cgit v1.1 From 7870152d23db4cb6f5834d4921fac17feb717220 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Sep 2009 14:54:12 +0100 Subject: Allow load/save iar password checks to be done in grid mode This should allow load/save iar to work for grid mode as long as the grid user service is later than this revision Grid services of earlier revisions will always erroneously report incorrect password. This will be addressed shortly. --- OpenSim/Framework/Communications/IUserService.cs | 16 +++++++++-- .../Communications/Tests/Cache/AssetCacheTests.cs | 5 ++++ .../Framework/Communications/UserManagerBase.cs | 32 +++++++++++++++++++--- 3 files changed, 47 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 725225d..15c5a96 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being updated /// The agent that is getting or loosing permissions /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); + void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); /// /// Logs off a user on the user server @@ -137,9 +137,21 @@ namespace OpenSim.Framework.Communications // But since Scenes only have IUserService references, I'm placing it here for now. bool VerifySession(UUID userID, UUID sessionID); + /// + /// Authenticate a user by their password. + /// + /// + /// This is used by callers outside the login process that want to + /// verify a user who has given their password. + /// + /// This should probably also be in IAuthentication but is here for the same reasons as VerifySession() is + /// + /// + /// + /// + bool AuthenticateUserByPassword(UUID userID, string password); // Temporary Hack until we move everything to the new service model void SetInventoryService(IInventoryService invService); - } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index ac0dc6d..a757282 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -149,6 +149,11 @@ namespace OpenSim.Framework.Communications.Tests { throw new NotImplementedException(); } + + public virtual bool AuthenticateUserByPassword(UUID userID, string password) + { + throw new NotImplementedException(); + } } } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 58174a0..1abd733 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -44,7 +44,8 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication + public abstract class UserManagerBase + : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -93,9 +94,9 @@ namespace OpenSim.Framework.Communications public void AddPlugin(string provider, string connect) { m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); - } + } - #region UserProfile + #region UserProfile public virtual void AddTemporaryUserProfile(UserProfileData userProfile) { @@ -891,7 +892,10 @@ namespace OpenSim.Framework.Communications if (userProfile != null && userProfile.CurrentAgent != null) { - m_log.DebugFormat("[USER AUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID); + m_log.DebugFormat( + "[USER AUTH]: Verifying session {0} for {1}; current session {2}", + sessionID, userID, userProfile.CurrentAgent.SessionID); + if (userProfile.CurrentAgent.SessionID == sessionID) { return true; @@ -901,6 +905,26 @@ namespace OpenSim.Framework.Communications return false; } + public virtual bool AuthenticateUserByPassword(UUID userID, string password) + { +// m_log.DebugFormat("[USER AUTH]: Authenticating user {0} given password {1}", userID, password); + + UserProfileData userProfile = GetUserProfile(userID); + + if (null == userProfile) + return false; + + string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt); + +// m_log.DebugFormat( +// "[USER AUTH]: Submitted hash {0}, stored hash {1}", md5PasswordHash, userProfile.PasswordHash); + + if (md5PasswordHash == userProfile.PasswordHash) + return true; + else + return false; + } + #endregion } } -- cgit v1.1 From 5757afe7665543e8b3ed4a322a7d6e095dafcdb3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 07:48:21 -0700 Subject: First pass at the heart surgery for grid services. Compiles and runs minimally. A few bugs to catch now. --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 73e2db0..3419ce2 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -35,6 +35,8 @@ using System.Text; using OpenMetaverse; using OpenMetaverse.StructuredData; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + using log4net; namespace OpenSim.Framework.Communications.Clients @@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) + public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason) { reason = String.Empty; @@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) + public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) { // Eventually, we want to use a caps url instead of the agentID string uri = string.Empty; @@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) + public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) { agent = null; // Eventually, we want to use a caps url instead of the agentID @@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoCloseAgentCall(RegionInfo region, UUID id) + public bool DoCloseAgentCall(GridRegion region, UUID id) { string uri = string.Empty; try @@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients return true; } - public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) + public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) { ulong regionHandle = GetRegionHandle(region.RegionHandle); string uri @@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients } - public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) + public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) { ulong regionHandle = GetRegionHandle(region.RegionHandle); string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; @@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients return false; } - public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) + public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) { } -- cgit v1.1 From 68e40a87cafcab580ab484956f187068c098e84e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:29:54 -0700 Subject: Poof! on LocalBackend. CommsManager.GridServices deleted. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index e9a6adb..9f377a6 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications } protected IMessagingService m_messageService; - public IGridServices GridService - { - get { return m_gridService; } - } - protected IGridServices m_gridService; public UserProfileCacheService UserProfileCacheService { -- cgit v1.1 From 0f05bbb4a20224492febf17604fa23ef2486fa1a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 05:54:37 -0700 Subject: Deleted some files that aren't being used anymore. --- OpenSim/Framework/Communications/IGridServices.cs | 92 ----------------------- OpenSim/Framework/Communications/IHyperlink.cs | 38 ---------- 2 files changed, 130 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IGridServices.cs delete mode 100644 OpenSim/Framework/Communications/IHyperlink.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs deleted file mode 100644 index 6365919..0000000 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IGridServices - { - string gdebugRegionName { get; set; } - - /// - /// If true, then regions will accept logins from the user service. If false, then they will not. - /// - bool RegionLoginsEnabled { get; set; } - - /// - /// Register a region with the grid service. - /// - /// - /// - /// Thrown if region registration failed - RegionCommsListener RegisterRegion(RegionInfo regionInfos); - - /// - /// Deregister a region with the grid service. - /// - /// - /// - /// Thrown if region deregistration failed - bool DeregisterRegion(RegionInfo regionInfo); - - /// - /// Get information about the regions neighbouring the given co-ordinates. - /// - /// - /// - /// - List RequestNeighbours(uint x, uint y); - - RegionInfo RequestNeighbourInfo(ulong regionHandle); - RegionInfo RequestNeighbourInfo(UUID regionID); - RegionInfo RequestNeighbourInfo(string name); - RegionInfo RequestNeighbourInfo(string host, uint port); - - RegionInfo RequestClosestRegion(string regionName); - Dictionary GetGridSettings(); - List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); - // not complete yet, only contains the fields needed for ParcelInfoReqeust - LandData RequestLandData(ulong regionHandle, uint x, uint y); - - /// - /// Get information about regions starting with the provided name. - /// - /// - /// The name to match against. - /// - /// - /// The maximum number of results to return. - /// - /// - /// A list of s of regions with matching name. If the - /// grid-server couldn't be contacted or returned an error, return null. - /// - List RequestNamedRegions(string name, int maxNumber); - } -} diff --git a/OpenSim/Framework/Communications/IHyperlink.cs b/OpenSim/Framework/Communications/IHyperlink.cs deleted file mode 100644 index 5057386..0000000 --- a/OpenSim/Framework/Communications/IHyperlink.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Framework.Communications -{ - public interface IHyperlink - { - bool IsHyperlinkRegion(ulong handle); - RegionInfo GetHyperlinkRegion(ulong handle); - ulong FindRegionHandle(ulong handle); - bool SendUserInformation(RegionInfo region, AgentCircuitData aCircuit); - void AdjustUserInformation(AgentCircuitData aCircuit); - } -} -- cgit v1.1 From 1006a2254c733655bf11d3cf25e41d1b43bd5f6a Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Sep 2009 13:36:03 +0100 Subject: Make create user to the Right Thing with regard to salting user passwords --- OpenSim/Framework/Communications/UserManagerBase.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 1abd733..86238b1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -650,15 +650,17 @@ namespace OpenSim.Framework.Communications public virtual UUID AddUser( string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) { - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); UserProfileData user = new UserProfileData(); + + user.PasswordSalt = Util.Md5Hash(UUID.Random().ToString()); + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + user.PasswordSalt); + user.HomeLocation = new Vector3(128, 128, 100); user.ID = SetUUID; user.FirstName = firstName; user.SurName = lastName; user.PasswordHash = md5PasswdHash; - user.PasswordSalt = String.Empty; user.Created = Util.UnixTimeSinceEpoch(); user.HomeLookAt = new Vector3(100, 100, 100); user.HomeRegionX = regX; -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- .../Communications/Cache/CachedUserInfo.cs | 8 ++--- .../Cache/UserProfileCacheService.cs | 34 +++++++++++----------- .../Communications/CommunicationsManager.cs | 4 +-- OpenSim/Framework/Communications/IAvatarService.cs | 2 +- .../Framework/Communications/IUserAdminService.cs | 2 +- OpenSim/Framework/Communications/IUserService.cs | 6 ++-- .../Osp/OspInventoryWrapperPlugin.cs | 6 ++-- .../Framework/Communications/Osp/OspResolver.cs | 12 ++++---- .../Communications/Services/LoginService.cs | 2 +- .../Communications/TemporaryUserProfilePlugin.cs | 4 +-- .../Communications/Tests/Cache/AssetCacheTests.cs | 4 +-- .../Tests/Cache/UserProfileCacheServiceTests.cs | 12 ++++---- .../Communications/Tests/LoginServiceTests.cs | 2 +- .../Framework/Communications/UserManagerBase.cs | 8 ++--- 14 files changed, 53 insertions(+), 53 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 238810a..8c39ca8 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -55,7 +55,7 @@ namespace OpenSim.Framework.Communications.Cache /// Stores user profile and inventory data received from backend services for a particular user. /// public class CachedUserInfo - { + { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); //// @@ -190,7 +190,7 @@ namespace OpenSim.Framework.Communications.Cache resolvedFolders.Add(folder); resolvedFolderDictionary[folder.ID] = folder; parentFolder.AddChildFolder(folder); - } + } } } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) @@ -422,7 +422,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, - /// and needs to be changed. + /// and needs to be changed. /// /// /// @@ -500,7 +500,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl oldParentFolder = RootFolder.FindFolder(folder.ParentID); if (oldParentFolder != null) - { + { oldParentFolder.RemoveChildFolder(folderID); parentFolder.AddChildFolder(folder); } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 7f1c7e9..2a1da50 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache /// User profiles indexed by name /// private readonly Dictionary m_userProfilesByName - = new Dictionary(); + = new Dictionary(); /// /// The root library folder. @@ -125,26 +125,26 @@ namespace OpenSim.Framework.Communications.Cache /// /// If the user isn't in cache then the user is requested from the profile service. /// - /// null if no user details are found + /// null if no user details are found public CachedUserInfo GetUserDetails(string fname, string lname) { lock (m_userProfilesByName) - { + { CachedUserInfo userInfo; - if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) + if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) { return userInfo; - } + } else - { + { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); if (userProfile != null) - return AddToCaches(userProfile); + return AddToCaches(userProfile); else return null; - } + } } } @@ -185,20 +185,20 @@ namespace OpenSim.Framework.Communications.Cache // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via // returning a read only class from the cache). // public bool StoreProfile(UserProfileData userProfile) -// { +// { // lock (m_userProfilesById) -// { +// { // CachedUserInfo userInfo = GetUserDetails(userProfile.ID); -// +// // if (userInfo != null) // { -// userInfo.m_userProfile = userProfile; +// userInfo.m_userProfile = userProfile; // m_commsManager.UserService.UpdateUserProfile(userProfile); -// +// // return true; // } // } -// +// // return false; // } @@ -220,7 +220,7 @@ namespace OpenSim.Framework.Communications.Cache } } - return createdUserInfo; + return createdUserInfo; } /// @@ -234,7 +234,7 @@ namespace OpenSim.Framework.Communications.Cache { if (m_userProfilesById.ContainsKey(userId)) { - CachedUserInfo userInfo = m_userProfilesById[userId]; + CachedUserInfo userInfo = m_userProfilesById[userId]; m_userProfilesById.Remove(userId); lock (m_userProfilesByName) @@ -244,7 +244,7 @@ namespace OpenSim.Framework.Communications.Cache return true; } - } + } return false; } diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 9f377a6..2410f31 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -90,8 +90,8 @@ namespace OpenSim.Framework.Communications public IUserAdminService UserAdminService { get { return m_userAdminService; } - } - protected IUserAdminService m_userAdminService; + } + protected IUserAdminService m_userAdminService; /// /// Constructor diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs index 4afc58f..760aa62 100644 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ b/OpenSim/Framework/Communications/IAvatarService.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Communications /// Update avatar appearance information /// /// - /// + /// void UpdateUserAppearance(UUID user, AvatarAppearance appearance); } } diff --git a/OpenSim/Framework/Communications/IUserAdminService.cs b/OpenSim/Framework/Communications/IUserAdminService.cs index 15b989d..423b49b 100644 --- a/OpenSim/Framework/Communications/IUserAdminService.cs +++ b/OpenSim/Framework/Communications/IUserAdminService.cs @@ -66,6 +66,6 @@ namespace OpenSim.Framework.Communications /// /// /// true if the update was successful, false otherwise - bool ResetUserPassword(string firstName, string lastName, string newPassword); + bool ResetUserPassword(string firstName, string lastName, string newPassword); } } diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 15c5a96..2872e5e 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications /// The agent that who's friends list is being updated /// The agent that is getting or loosing permissions /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); + void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); /// /// Logs off a user on the user server @@ -130,7 +130,7 @@ namespace OpenSim.Framework.Communications /// /// A List of FriendListItems that contains info about the user's friends. /// Always returns a list even if the user has no friends - /// + /// List GetUserFriendList(UUID friendlistowner); // This probably shouldn't be here, it belongs to IAuthentication @@ -149,7 +149,7 @@ namespace OpenSim.Framework.Communications /// /// /// - bool AuthenticateUserByPassword(UUID userID, string password); + bool AuthenticateUserByPassword(UUID userID, string password); // Temporary Hack until we move everything to the new service model void SetInventoryService(IInventoryService invService); diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index 98d0e0f..e96c5e8 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Osp public string Name { get { return "OspInventoryWrapperPlugin"; } } public string Version { get { return "0.1"; } } - public void Initialise() {} + public void Initialise() {} public void Initialise(string connect) {} public void Dispose() {} @@ -80,9 +80,9 @@ namespace OpenSim.Framework.Communications.Osp } protected InventoryItemBase PostProcessItem(InventoryItemBase item) - { + { item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); - return item; + return item; } public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); } diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index e98317a..32f0efc 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -33,13 +33,13 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; namespace OpenSim.Framework.Communications.Osp -{ +{ /// /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for /// identifying user profiles or supplying a simple name if no profile is available. /// public class OspResolver - { + { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public const string OSPA_PREFIX = "ospa:"; @@ -73,7 +73,7 @@ namespace OpenSim.Framework.Communications.Osp { return OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - } + } /// /// Resolve an osp string into the most suitable internal OpenSim identifier. @@ -89,13 +89,13 @@ namespace OpenSim.Framework.Communications.Osp /// is returned. /// public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) - { + { if (!ospa.StartsWith(OSPA_PREFIX)) return UUID.Zero; m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); - string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); + string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); foreach (string tuple in ospaTuples) @@ -162,7 +162,7 @@ namespace OpenSim.Framework.Communications.Osp tempUserProfile.ID = HashName(tempUserProfile.Name); m_log.DebugFormat( - "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); + "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); return tempUserProfile.ID; diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index a6cd918..922cd49 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1072,7 +1072,7 @@ namespace OpenSim.Framework.Communications.Services /// /// /// - /// true if the region was successfully contacted, false otherwise + /// true if the region was successfully contacted, false otherwise protected abstract bool PrepareLoginToRegion( RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index 43f1440..d56211f 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -33,7 +33,7 @@ using OpenMetaverse; using OpenSim.Data; namespace OpenSim.Framework.Communications -{ +{ /// /// Plugin for managing temporary user profiles. /// @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications public string Name { get { return "TemporaryUserProfilePlugin"; } } public string Version { get { return "0.1"; } } - public void Initialise() {} + public void Initialise() {} public void Initialise(string connect) {} public void Dispose() {} diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index a757282..caaebd7 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs @@ -152,8 +152,8 @@ namespace OpenSim.Framework.Communications.Tests public virtual bool AuthenticateUserByPassword(UUID userID, string password) { - throw new NotImplementedException(); - } + throw new NotImplementedException(); + } } } } diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index e5d8895..830c877 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -133,7 +133,7 @@ namespace OpenSim.Framework.Communications.Tests timedOut = true; lock (this) - { + { UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo; lock (this) - { + { userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } @@ -171,7 +171,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo; lock (this) - { + { userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } @@ -206,7 +206,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo; lock (this) - { + { userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } @@ -271,7 +271,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo; lock (this) - { + { userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } @@ -311,7 +311,7 @@ namespace OpenSim.Framework.Communications.Tests CachedUserInfo userInfo; lock (this) - { + { userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); Monitor.Wait(this, 60000); } diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 0a9d2ae..e891d9c 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -318,7 +318,7 @@ namespace OpenSim.Framework.Communications.Tests { TestHelper.InMethod(); - //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); + //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); //log4net.Config.XmlConfigurator.Configure(); string error_already_logged = "You appear to be already logged in. " + diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 86238b1..bf4f331 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -94,9 +94,9 @@ namespace OpenSim.Framework.Communications public void AddPlugin(string provider, string connect) { m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); - } + } - #region UserProfile + #region UserProfile public virtual void AddTemporaryUserProfile(UserProfileData userProfile) { @@ -924,8 +924,8 @@ namespace OpenSim.Framework.Communications if (md5PasswordHash == userProfile.PasswordHash) return true; else - return false; - } + return false; + } #endregion } -- cgit v1.1 From 606e831ff5337fb5e94dcebf9d6852bd4c434d4b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 09:38:36 +0900 Subject: Formatting cleanup. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 2 +- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 4 ++-- OpenSim/Framework/Communications/IUserService.cs | 2 +- OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 8c39ca8..aa71536 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -219,7 +219,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Fetch inventory for this user. /// - /// This has to be executed as a separate step once user information is retreived. + /// This has to be executed as a separate step once user information is retreived. /// This will occur synchronously if the inventory service is in the same process as this class, and /// asynchronously otherwise. public void FetchInventory() diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 2a1da50..9e12d948 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -123,7 +123,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Get details of the given user. /// - /// If the user isn't in cache then the user is requested from the profile service. + /// If the user isn't in cache then the user is requested from the profile service. /// /// null if no user details are found public CachedUserInfo GetUserDetails(string fname, string lname) @@ -151,7 +151,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// Get details of the given user. /// - /// If the user isn't in cache then the user is requested from the profile service. + /// If the user isn't in cache then the user is requested from the profile service. /// /// null if no user details are found public CachedUserInfo GetUserDetails(UUID userID) diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs index 2872e5e..dfa059d 100644 --- a/OpenSim/Framework/Communications/IUserService.cs +++ b/OpenSim/Framework/Communications/IUserService.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.Communications /// /// The agent for whom we're retreiving the friends Data. /// - /// A List of FriendListItems that contains info about the user's friends. + /// A List of FriendListItems that contains info about the user's friends. /// Always returns a list even if the user has no friends /// List GetUserFriendList(UUID friendlistowner); diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs index d56211f..2413055 100644 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -35,7 +35,7 @@ using OpenSim.Data; namespace OpenSim.Framework.Communications { /// - /// Plugin for managing temporary user profiles. + /// Plugin for managing temporary user profiles. /// public class TemporaryUserProfilePlugin : IUserDataPlugin { -- cgit v1.1 From 387e9f7a7faeb412054383080afc3507a1522746 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 2 Oct 2009 18:31:08 -0700 Subject: * Creates Util.UTF8 and switches some references of Encoding.UTF8 to Util.UTF8 (not all references were switched since not all OpenSim libraries reference OpenSim.Framework) * Shrinks the largest in-memory object, the LLRAW.HeightmapLookupValue struct (only used for exporting to LLRAW terrain files), to the minimum possible size. This seems to have the odd side effect of cutting the size of the two double[256,256] terrain objects in half. Possibly an alignment optimization? --- OpenSim/Framework/Communications/XMPP/XmppWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs index b52eda7..415d808 100644 --- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs +++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.XMPP { } - public XMPPWriter(IOStream stream) : this(stream, Encoding.UTF8) + public XMPPWriter(IOStream stream) : this(stream, Util.UTF8) { } -- cgit v1.1 From 30aac00f6bb24e0aed2e8a49907e0c4c573febfd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 4 Oct 2009 10:12:19 -0700 Subject: Closing more streams even if things fail. --- .../Communications/Clients/RegionClient.cs | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 3419ce2..10be069 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -106,7 +106,6 @@ namespace OpenSim.Framework.Communications.Clients AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send os = AgentCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); } //catch (WebException ex) @@ -116,6 +115,11 @@ namespace OpenSim.Framework.Communications.Clients reason = "cannot contact remote region"; return false; } + finally + { + if (os != null) + os.Close(); + } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); @@ -224,7 +228,6 @@ namespace OpenSim.Framework.Communications.Clients ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send os = ChildUpdateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); } //catch (WebException ex) @@ -234,6 +237,11 @@ namespace OpenSim.Framework.Communications.Clients return false; } + finally + { + if (os != null) + os.Close(); + } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); @@ -437,7 +445,6 @@ namespace OpenSim.Framework.Communications.Clients ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send os = ObjectCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); } //catch (WebException ex) @@ -447,6 +454,11 @@ namespace OpenSim.Framework.Communications.Clients return false; } + finally + { + if (os != null) + os.Close(); + } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); @@ -512,7 +524,6 @@ namespace OpenSim.Framework.Communications.Clients ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send os = ObjectCreateRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); } //catch (WebException ex) @@ -522,6 +533,11 @@ namespace OpenSim.Framework.Communications.Clients return false; } + finally + { + if (os != null) + os.Close(); + } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); @@ -597,7 +613,6 @@ namespace OpenSim.Framework.Communications.Clients HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send os = HelloNeighbourRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it - os.Close(); //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); } //catch (WebException ex) @@ -607,7 +622,11 @@ namespace OpenSim.Framework.Communications.Clients return false; } - + finally + { + if (os != null) + os.Close(); + } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); -- cgit v1.1 From e474fc2fdbc424e64ce3a0f249b0d0afa44d86eb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 08:50:25 -0700 Subject: Corrected words in error message. --- OpenSim/Framework/Communications/RestClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7a73506..d98f47d 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -318,11 +318,11 @@ namespace OpenSim.Framework.Communications HttpWebResponse errorResponse = e.Response as HttpWebResponse; if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) { - m_log.Warn("[ASSET] Asset not found (404)"); + m_log.Warn("[REST CLIENT] Resource not found (404)"); } else { - m_log.Error("[ASSET] Error fetching asset from asset server"); + m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString()); m_log.Debug(e.ToString()); } -- cgit v1.1 From e992ca025571a891333a57012c2cd4419b6581e5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 15:39:53 -0700 Subject: Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed. --- .../Cache/UserProfileCacheService.cs | 66 +++++++++------------- 1 file changed, 27 insertions(+), 39 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 9e12d948..b02cf5b 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -128,24 +128,18 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(string fname, string lname) { + CachedUserInfo userInfo; lock (m_userProfilesByName) - { - CachedUserInfo userInfo; - + { if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) - { return userInfo; - } - else - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; - } } + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); + + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; } /// @@ -160,20 +154,14 @@ namespace OpenSim.Framework.Communications.Cache return null; lock (m_userProfilesById) - { if (m_userProfilesById.ContainsKey(userID)) - { return m_userProfilesById[userID]; - } - else - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; - } - } + + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; } /// @@ -211,14 +199,10 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); lock (m_userProfilesById) - { m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; - - lock (m_userProfilesByName) - { - m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; - } - } + + lock (m_userProfilesByName) + m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; return createdUserInfo; } @@ -230,21 +214,25 @@ namespace OpenSim.Framework.Communications.Cache /// true if there was a profile to remove, false otherwise protected bool RemoveFromCaches(UUID userId) { + CachedUserInfo userInfo = null; lock (m_userProfilesById) { if (m_userProfilesById.ContainsKey(userId)) { - CachedUserInfo userInfo = m_userProfilesById[userId]; + userInfo = m_userProfilesById[userId]; m_userProfilesById.Remove(userId); - - lock (m_userProfilesByName) + } + } + + if (userInfo != null) + lock (m_userProfilesByName) + { + if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name)) { m_userProfilesByName.Remove(userInfo.UserProfile.Name); + return true; } - - return true; } - } return false; } -- cgit v1.1 From 89d23a1fa23cb191e7ebde047311adcadf3b2e45 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Oct 2009 01:45:49 +0100 Subject: Revert "Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed." This reverts commit e992ca025571a891333a57012c2cd4419b6581e5. --- .../Cache/UserProfileCacheService.cs | 66 +++++++++++++--------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b02cf5b..9e12d948 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -128,18 +128,24 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(string fname, string lname) { - CachedUserInfo userInfo; lock (m_userProfilesByName) - { + { + CachedUserInfo userInfo; + if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) + { return userInfo; + } + else + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); + + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; + } } - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; } /// @@ -154,14 +160,20 @@ namespace OpenSim.Framework.Communications.Cache return null; lock (m_userProfilesById) + { if (m_userProfilesById.ContainsKey(userID)) + { return m_userProfilesById[userID]; - - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; + } + else + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; + } + } } /// @@ -199,10 +211,14 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); lock (m_userProfilesById) + { m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; - - lock (m_userProfilesByName) - m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; + + lock (m_userProfilesByName) + { + m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; + } + } return createdUserInfo; } @@ -214,25 +230,21 @@ namespace OpenSim.Framework.Communications.Cache /// true if there was a profile to remove, false otherwise protected bool RemoveFromCaches(UUID userId) { - CachedUserInfo userInfo = null; lock (m_userProfilesById) { if (m_userProfilesById.ContainsKey(userId)) { - userInfo = m_userProfilesById[userId]; + CachedUserInfo userInfo = m_userProfilesById[userId]; m_userProfilesById.Remove(userId); - } - } - - if (userInfo != null) - lock (m_userProfilesByName) - { - if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name)) + + lock (m_userProfilesByName) { m_userProfilesByName.Remove(userInfo.UserProfile.Name); - return true; } + + return true; } + } return false; } -- cgit v1.1 From b5b53dd3ebb331c5d235df161fe9cefc405c3660 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 19:55:35 -0700 Subject: * One more debug message on FetchInventoryDescendants * More streams close on finally --- .../Communications/Clients/RegionClient.cs | 79 +++++++++++++++++----- 1 file changed, 62 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 10be069..220a9b6 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -124,9 +124,11 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + WebResponse webResponse = null; + StreamReader sr = null; try { - WebResponse webResponse = AgentCreateRequest.GetResponse(); + webResponse = AgentCreateRequest.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); @@ -134,11 +136,10 @@ namespace OpenSim.Framework.Communications.Clients else { - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); string response = sr.ReadToEnd().Trim(); - sr.Close(); m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); - + if (!String.IsNullOrEmpty(response)) { try @@ -167,6 +168,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -246,15 +252,17 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); + WebResponse webResponse = null; + StreamReader sr = null; try { - WebResponse webResponse = ChildUpdateRequest.GetResponse(); + webResponse = ChildUpdateRequest.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -266,6 +274,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -284,6 +297,7 @@ namespace OpenSim.Framework.Communications.Clients HttpWebResponse webResponse = null; string reply = string.Empty; + StreamReader sr = null; try { webResponse = (HttpWebResponse)request.GetResponse(); @@ -292,9 +306,8 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent get "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); reply = sr.ReadToEnd().Trim(); - sr.Close(); //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); @@ -305,6 +318,11 @@ namespace OpenSim.Framework.Communications.Clients // ignore, really return false; } + finally + { + if (sr != null) + sr.Close(); + } if (webResponse.StatusCode == HttpStatusCode.OK) { @@ -333,6 +351,7 @@ namespace OpenSim.Framework.Communications.Clients request.Method = "DELETE"; request.Timeout = 10000; + StreamReader sr = null; try { WebResponse webResponse = request.GetResponse(); @@ -341,7 +360,7 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent delete "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -353,6 +372,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -377,6 +401,7 @@ namespace OpenSim.Framework.Communications.Clients request.Method = "DELETE"; request.Timeout = 10000; + StreamReader sr = null; try { WebResponse webResponse = request.GetResponse(); @@ -385,7 +410,7 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent delete "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -397,6 +422,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -463,6 +493,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + StreamReader sr = null; try { WebResponse webResponse = ObjectCreateRequest.GetResponse(); @@ -471,10 +502,9 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); } @@ -483,6 +513,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -542,6 +577,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + StreamReader sr = null; try { WebResponse webResponse = ObjectCreateRequest.GetResponse(); @@ -550,11 +586,10 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); - + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); } @@ -563,6 +598,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -630,6 +670,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); + StreamReader sr = null; try { WebResponse webResponse = HelloNeighbourRequest.GetResponse(); @@ -638,10 +679,9 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); } @@ -650,6 +690,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; -- cgit v1.1 From 494a1e922dd5c86ef54d7a83347ec8ba255e0e83 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 9 Oct 2009 02:10:53 -0700 Subject: Calling .Close() on AutoResetEvent and ManualResetEvent (those classes contain an unmanaged resource that will not automatically be disposed when they are GCed), and commenting out some ManualResetEvents that are not in use yet --- OpenSim/Framework/Communications/GenericAsyncResult.cs | 1 + OpenSim/Framework/Communications/RestClient.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/GenericAsyncResult.cs b/OpenSim/Framework/Communications/GenericAsyncResult.cs index efd2f43..8e3f62b 100644 --- a/OpenSim/Framework/Communications/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/GenericAsyncResult.cs @@ -146,6 +146,7 @@ namespace OpenSim.Framework.Communications // If the operation isn't done, wait for it AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); + m_waitHandle.Close(); m_waitHandle = null; // Allow early GC } diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index d98f47d..a74169e 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -105,7 +105,7 @@ namespace OpenSim.Framework.Communications /// /// This flag will help block the main synchroneous method, in case we run in synchroneous mode /// - public static ManualResetEvent _allDone = new ManualResetEvent(false); + //public static ManualResetEvent _allDone = new ManualResetEvent(false); /// /// Default time out period @@ -282,12 +282,12 @@ namespace OpenSim.Framework.Communications else { s.Close(); - _allDone.Set(); + //_allDone.Set(); } } catch (Exception e) { - _allDone.Set(); + //_allDone.Set(); _asyncException = e; } } -- cgit v1.1 From c146f2c8c4eb60d063196972d5c0dd2ec550b27e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Oct 2009 13:49:55 -0700 Subject: Use the cache, Luke! --- .../Communications/CommunicationsManager.cs | 33 ++++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 2410f31..9c02842 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -210,34 +210,17 @@ namespace OpenSim.Framework.Communications private string[] doUUIDNameRequest(UUID uuid) { string[] returnstring = new string[0]; - bool doLookup = false; + CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid); - lock (m_nameRequestCache) + if ((uinfo != null) && (uinfo.UserProfile != null)) { - if (m_nameRequestCache.ContainsKey(uuid)) - { - returnstring = m_nameRequestCache[uuid]; - } - else - { - // we don't want to lock the dictionary while we're doing the lookup - doLookup = true; - } - } - - if (doLookup) { - UserProfileData profileData = m_userService.GetUserProfile(uuid); - if (profileData != null) + returnstring = new string[2]; + returnstring[0] = uinfo.UserProfile.FirstName; + returnstring[1] = uinfo.UserProfile.SurName; + lock (m_nameRequestCache) { - returnstring = new string[2]; - // UUID profileId = profileData.ID; - returnstring[0] = profileData.FirstName; - returnstring[1] = profileData.SurName; - lock (m_nameRequestCache) - { - if (!m_nameRequestCache.ContainsKey(uuid)) - m_nameRequestCache.Add(uuid, returnstring); - } + if (!m_nameRequestCache.ContainsKey(uuid)) + m_nameRequestCache.Add(uuid, returnstring); } } -- cgit v1.1 From f29bd8036dac4e3129b937cceda9606d496a20b7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Oct 2009 14:36:08 -0700 Subject: A slight improvement on name fetching -- using the local name cache, since it exists. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 9c02842..4bf9018 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -209,6 +209,12 @@ namespace OpenSim.Framework.Communications private string[] doUUIDNameRequest(UUID uuid) { + lock (m_nameRequestCache) + { + if (m_nameRequestCache.ContainsKey(uuid)) + return m_nameRequestCache[uuid]; + } + string[] returnstring = new string[0]; CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid); -- cgit v1.1 From 8030ed89b00cfba6215143fe5e630fa12e05639e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Oct 2009 06:35:31 -0700 Subject: Use Util.UTF8 instead of creating a new heap object every time. --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 220a9b6..297b046 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications.Clients try { strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); + Encoding str = Util.UTF8; buffer = str.GetBytes(strBuffer); } @@ -218,7 +218,7 @@ namespace OpenSim.Framework.Communications.Clients try { strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); + Encoding str = Util.UTF8; buffer = str.GetBytes(strBuffer); } @@ -459,7 +459,7 @@ namespace OpenSim.Framework.Communications.Clients try { strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); + Encoding str = Util.UTF8; buffer = str.GetBytes(strBuffer); } @@ -543,7 +543,7 @@ namespace OpenSim.Framework.Communications.Clients try { strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); + Encoding str = Util.UTF8; buffer = str.GetBytes(strBuffer); } @@ -637,7 +637,7 @@ namespace OpenSim.Framework.Communications.Clients try { strBuffer = OSDParser.SerializeJsonString(args); - UTF8Encoding str = new UTF8Encoding(); + Encoding str = Util.UTF8; buffer = str.GetBytes(strBuffer); } -- cgit v1.1 From fdce1be3db287bed901332b90ba57165e201d3fc Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 19 Oct 2009 16:52:27 -0700 Subject: * Removed OpenSim.Data.NHibernate * Replaced calls to ThreadPool.QueueUserWorkItem() with ThreadPool.UnsafeQueueUserWorkItem() since OpenSim does not use Code Access Security sandboxing --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index a74169e..317b3a0 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -403,7 +403,7 @@ namespace OpenSim.Framework.Communications /// In case, we are invoked asynchroneously this object will keep track of the state /// AsyncResult ar = new AsyncResult(callback, state); - ThreadPool.QueueUserWorkItem(RequestHelper, ar); + ThreadPool.UnsafeQueueUserWorkItem(RequestHelper, ar); return ar; } -- cgit v1.1 From 32ccd5bb40447ea4d96f1181cf73edff3645a55a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 21 Oct 2009 23:03:18 -0700 Subject: * Changed the misc. methods calling ThreadPool.UnsafeQueueUserWorkItem() to Util.FireAndForget() * Changed Util.FireAndForget() to use any of five different methods set with async_call_method in the [Startup] section of OpenSim.ini. Look at the example config for possible values --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 317b3a0..97b3b60 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -403,7 +403,7 @@ namespace OpenSim.Framework.Communications /// In case, we are invoked asynchroneously this object will keep track of the state /// AsyncResult ar = new AsyncResult(callback, state); - ThreadPool.UnsafeQueueUserWorkItem(RequestHelper, ar); + Util.FireAndForget(RequestHelper, ar); return ar; } -- cgit v1.1 From b81c829576dd916c0a7bf141919f5e13f025d818 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 14:13:17 -0700 Subject: * Standalone logins will now go through the sequence of "requested region, default region, any region" before giving up * Hip offset should have been added not subtracted (it's a negative offset). This puts avatar feet closer to the ground * Improved duplicate checking for terse updates. This should reduce bandwidth and walking through walls --- .../Communications/Services/LoginService.cs | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 922cd49..b652299 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1031,30 +1031,26 @@ namespace OpenSim.Framework.Communications.Services return true; } - // StartLocation not available, send him to a nearby region instead - // regionInfo = m_gridService.RequestClosestRegion(""); - //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + // Get the default region handle + ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize); - // Send him to default region instead - ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | - ((ulong)m_defaultHomeY * Constants.RegionSize); + // If we haven't already tried the default region, reset regionInfo + if (regionInfo != null && defaultHandle != regionInfo.RegionHandle) + regionInfo = null; - if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + if (regionInfo == null) { - m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); - return false; + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); } - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - if (regionInfo == null) { - m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); - return false; + m_log.ErrorFormat("[LOGIN]: Sending user to any region"); + regionInfo = RequestClosestRegion(String.Empty); } - theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f); response.StartLocation = "safe"; return PrepareLoginToRegion(regionInfo, theUser, response, client); -- cgit v1.1 From c72f78215bb3435ee2bbb507746c23eccec4dd34 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 01:56:19 +0000 Subject: Backport the fixes to WebFetchInventoryDescendents to the UDP InventoryDescendents packet. Testing has shown that UDP inventory now works flawlessly and, unlike CAPS inventory, doesn't download the entire agent inventory on start. Neither does it incessantly re-request folder NULL_KEY. Therefore, I have disabled CAPS inventory. --- OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index aa71536..6648c36 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -679,7 +679,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the request was queued or successfully processed, false otherwise - public bool SendInventoryDecendents(IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems) + public bool SendInventoryDecendents(IClientAPI client, UUID folderID, int version, bool fetchFolders, bool fetchItems) { if (m_hasReceivedInventory) { @@ -693,7 +693,7 @@ namespace OpenSim.Framework.Communications.Cache client.SendInventoryFolderDetails( client.AgentId, folderID, folder.RequestListOfItems(), - folder.RequestListOfFolders(), fetchFolders, fetchItems); + folder.RequestListOfFolders(), version, fetchFolders, fetchItems); return true; } -- cgit v1.1 From 2f092d271e80dbc7af47671fbb946de75b6110a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 18:44:03 +0000 Subject: Rename test services to mock services, since this is a more accurate description remove duplicate mock inventory service --- .../Communications/Tests/LoginServiceTests.cs | 151 +-------------------- 1 file changed, 4 insertions(+), 147 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index e891d9c..60f0ba8 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Tests m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); - //IInventoryService m_inventoryService = new TestInventoryService(); + //IInventoryService m_inventoryService = new MockInventoryService(); m_localUserServices = (LocalUserServices) m_commsManager.UserService; m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); @@ -95,7 +95,8 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); // We want to use our own LoginService for this test, one that // doesn't require authentication. - new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), + new LLStandaloneLoginService( + (UserManagerBase)m_commsManager.UserService, "Hello folks", new MockInventoryService(), m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); Hashtable loginParams = new Hashtable(); @@ -457,148 +458,4 @@ namespace OpenSim.Framework.Communications.Tests #endregion } } - - class TestInventoryService : IInventoryService - { - public TestInventoryService() - { - } - - /// - /// - /// - /// - /// - public bool CreateUserInventory(UUID userId) - { - return false; - } - - /// - /// - /// - /// - /// - public List GetInventorySkeleton(UUID userId) - { - List folders = new List(); - InventoryFolderBase folder = new InventoryFolderBase(); - folder.ID = UUID.Random(); - folder.Owner = userId; - folders.Add(folder); - return folders; - } - - /// - /// Returns a list of all the active gestures in a user's inventory. - /// - /// - /// The of the user - /// - /// - /// A flat list of the gesture items. - /// - public List GetActiveGestures(UUID userId) - { - return null; - } - - public InventoryCollection GetUserInventory(UUID userID) - { - return null; - } - - public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) - { - } - - public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) - { - return null; - } - - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) - { - return null; - } - - public List GetFolderItems(UUID userID, UUID folderID) - { - return null; - } - - public bool AddFolder(InventoryFolderBase folder) - { - return false; - } - - public bool UpdateFolder(InventoryFolderBase folder) - { - return false; - } - - public bool MoveFolder(InventoryFolderBase folder) - { - return false; - } - - public bool DeleteFolders(UUID ownerID, List ids) - { - return false; - } - - public bool PurgeFolder(InventoryFolderBase folder) - { - return false; - } - - public bool AddItem(InventoryItemBase item) - { - return false; - } - - public bool UpdateItem(InventoryItemBase item) - { - return false; - } - - public bool MoveItems(UUID owner, List items) - { - return false; - } - - public bool DeleteItems(UUID owner, List items) - { - return false; - } - - public InventoryItemBase GetItem(InventoryItemBase item) - { - return null; - } - - public InventoryFolderBase GetFolder(InventoryFolderBase folder) - { - return null; - } - - public bool HasInventoryForUser(UUID userID) - { - return false; - } - - public InventoryFolderBase GetRootFolder(UUID userID) - { - InventoryFolderBase root = new InventoryFolderBase(); - root.ID = UUID.Random(); - root.Owner = userID; - root.ParentID = UUID.Zero; - return root; - } - - public int GetAssetPermissions(UUID userID, UUID assetID) - { - return 1; - } - } -} +} \ No newline at end of file -- cgit v1.1 From d95df603dfc8e6a033649be669c6b54071ccb7d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 19:33:38 +0000 Subject: move fake user service to a separate mock user service class delete asset cache tests shell --- .../Communications/Tests/Cache/AssetCacheTests.cs | 159 --------------------- 1 file changed, 159 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs deleted file mode 100644 index caaebd7..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Threading; -using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common.Mock; - -namespace OpenSim.Framework.Communications.Tests -{ - /// - /// Asset cache tests - /// - [TestFixture] - public class AssetCacheTests - { - private class FakeUserService : IUserService - { - public void AddTemporaryUserProfile(UserProfileData userProfile) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(string firstName, string lastName) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(UUID userId) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(Uri uri) - { - UserProfileData userProfile = new UserProfileData(); - -// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); - - return userProfile; - } - - public Uri GetUserUri(UserProfileData userProfile) - { - throw new NotImplementedException(); - } - - public UserAgentData GetAgentByUUID(UUID userId) - { - throw new NotImplementedException(); - } - - public void ClearUserAgent(UUID avatarID) - { - throw new NotImplementedException(); - } - - public List GenerateAgentPickerRequestResponse(UUID QueryID, string Query) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(string firstName, string lastName) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(string firstName, string lastName, string password) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(UUID userId) - { - throw new NotImplementedException(); - } - - public bool UpdateUserProfile(UserProfileData data) - { - throw new NotImplementedException(); - } - - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) - { - throw new NotImplementedException(); - } - - public void RemoveUserFriend(UUID friendlistowner, UUID friend) - { - throw new NotImplementedException(); - } - - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) - { - throw new NotImplementedException(); - } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) - { - throw new NotImplementedException(); - } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) - { - throw new NotImplementedException(); - } - - public List GetUserFriendList(UUID friendlistowner) - { - throw new NotImplementedException(); - } - - public bool VerifySession(UUID userID, UUID sessionID) - { - return true; - } - - public void SetInventoryService(IInventoryService inv) - { - throw new NotImplementedException(); - } - - public virtual bool AuthenticateUserByPassword(UUID userID, string password) - { - throw new NotImplementedException(); - } - } - } -} -- cgit v1.1 From 0712196c262d24e3d4ca0d13abac0bd3fa6964cf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 18:56:23 +0000 Subject: make logging less verbose when loading iars --- OpenSim/Framework/Communications/Osp/OspResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 32f0efc..4013896 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Osp if (!ospa.StartsWith(OSPA_PREFIX)) return UUID.Zero; - m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); +// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); -- cgit v1.1 From 4c61fcfc401cdf08f5027e3bce21c4b465711c60 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sat, 5 Dec 2009 09:54:33 -0600 Subject: Getting rid of the dead field RootInventoryFolderId on UserProfileData, It's not even stored in mysql. Signed-off-by: Melanie --- OpenSim/Framework/Communications/Services/LoginService.cs | 2 -- OpenSim/Framework/Communications/UserManagerBase.cs | 3 --- 2 files changed, 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index b652299..57ca704 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -244,7 +244,6 @@ namespace OpenSim.Framework.Communications.Services InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; @@ -501,7 +500,6 @@ namespace OpenSim.Framework.Communications.Services InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.RootInventoryFolderID = inventData.RootFolderID; // Inventory Library Section diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index bf4f331..4f0af06 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -697,9 +697,6 @@ namespace OpenSim.Framework.Communications // local service (standalone) m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); m_InventoryService.CreateUserInventory(userProf.ID); - InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID); - if (rootfolder != null) - userProf.RootInventoryFolderID = rootfolder.ID; } else if (m_commsManager.InterServiceInventoryService != null) { -- cgit v1.1 From decd51f0811639169d63cb80fcc7dec931ea9530 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 08:11:26 -0800 Subject: Attempt at fixing mantis #4411. --- .../Communications/Cache/UserProfileCacheService.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 9e12d948..cebd571 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -139,9 +139,16 @@ namespace OpenSim.Framework.Communications.Cache else { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - + if (userProfile != null) + { + if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } @@ -169,7 +176,14 @@ namespace OpenSim.Framework.Communications.Cache { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) + { + if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } -- cgit v1.1 From 5f0478c4c445cf049f8668bb82468fa30d783baf Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 08:28:24 -0800 Subject: Fix to make [bad] tests happy. --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index cebd571..29a9e14 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -142,9 +142,9 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile != null) { - if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; return AddToCaches(userProfile); @@ -177,9 +177,9 @@ namespace OpenSim.Framework.Communications.Cache UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) { - if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; return AddToCaches(userProfile); -- cgit v1.1 From d20fe7bfdd41e3526e03a384b14b84a0fd92a1c2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 20:06:42 -0800 Subject: A couple of more sanity guards, but this won't fix things when user profile fetching is borked. --- OpenSim/Framework/Communications/Clients/AuthClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 6b4bfec..adae637 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Clients } Hashtable responseData = (Hashtable)UserResp.Value; - if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") + if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") { //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); return true; -- cgit v1.1 From c0a8c2e70728afa10aa84be3bb7cb9930dc791e9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Dec 2009 06:58:21 -0800 Subject: Making the library read the item's flag, so that clothing items can have the proper icons. --- OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 7305795..42e6510 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -171,6 +171,7 @@ namespace OpenSim.Framework.Communications.Cache item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); + item.Flags = (uint)config.GetInt("flags", 0); if (libraryFolders.ContainsKey(item.Folder)) { -- cgit v1.1 From 68187f7245a113e0afab0bfc28820bb0be5387b5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Dec 2009 07:44:17 -0800 Subject: Bug fix: in standalone, HGInventoryBroker needs to get the local inventory server URL from NetworkServersInfo. --- OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 29a9e14..acae4b1 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -142,6 +142,7 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile != null) { + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) @@ -177,6 +178,7 @@ namespace OpenSim.Framework.Communications.Cache UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) { + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) -- cgit v1.1 From c27aa3749c093d87b7d3216e7045d9fab948b4e1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Dec 2009 11:45:39 -0800 Subject: Change in how the Library returns its descendant folders, so that it includes folders added after the initial load off the file system, by other mechanisms. --- .../Communications/Cache/LibraryRootFolder.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 42e6510..74ba0a5 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -232,7 +232,26 @@ namespace OpenSim.Framework.Communications.Cache /// public Dictionary RequestSelfAndDescendentFolders() { - return libraryFolders; + Dictionary fs = new Dictionary(); + fs.Add(ID, this); + List fis = TraverseFolder(this); + foreach (InventoryFolderImpl f in fis) + { + fs.Add(f.ID, f); + } + //return libraryFolders; + return fs; + } + + private List TraverseFolder(InventoryFolderImpl node) + { + List folders = node.RequestListOfFolderImpls(); + List subs = new List(); + foreach (InventoryFolderImpl f in folders) + subs.AddRange(TraverseFolder(f)); + + folders.AddRange(subs); + return folders; } } } -- cgit v1.1 From 0b5cdc539c767b526f14cb7e7d97fd83bea14424 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 Dec 2009 18:35:06 +0000 Subject: Change teleports so the TeleportFlags are sent to the destination sim. It can now determine if a connection is from login, teleport or crossing. Needed for a meaningful banlines implementation --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 297b046..5ceaf39 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason) + public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) { reason = String.Empty; @@ -83,7 +83,8 @@ namespace OpenSim.Framework.Communications.Clients } // Add the regionhandle of the destination region ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); string strBuffer = ""; byte[] buffer = new byte[1]; -- cgit v1.1 From b29ae7246076126e8e39827564438db6e53eac8a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 30 Dec 2009 21:00:16 -0800 Subject: First pass at the new login service. Still incomplete, but doesn't disrupt the existing code. --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 5ceaf39..ee7dec8 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Communications.Clients } // Add the regionhandle of the destination region ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); string strBuffer = ""; -- cgit v1.1 From b63405c1a796b44b58081857d01f726372467628 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 8 Jan 2010 10:43:34 -0800 Subject: Inching ahead... This compiles, but very likely does not run. --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 345 --------------------- 1 file changed, 345 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs deleted file mode 100644 index 830c877..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using System.Threading; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Communications.Local; -using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Communications.Tests -{ - [TestFixture] - public class UserProfileCacheServiceTests - { - /// Used by tests to indicate whether an async operation timed out - private bool timedOut; - - private void InventoryReceived(UUID userId) - { - lock (this) - { - timedOut = false; - Monitor.PulseAll(this); - } - } - - [Test] - public void TestGetUserDetails() - { - TestHelper.InMethod(); - - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - string firstName = "Bill"; - string lastName = "Bailey"; - CachedUserInfo nonExistingUserInfo; - - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - // Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); - - // Check we can't retrieve info before it exists by uuid - nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); - Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); - - // Check we can't retrieve info before it exists by name - nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); - - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); - - CachedUserInfo existingUserInfo; - - // Check we can retrieve info by uuid - existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); - Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); - - // Check we can retrieve info by name - existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); - } - - /** - * Disabled as not fully implemented - [Test] - public void TestUpdateProfile() - { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); - string firstName = "Inspector"; - string originalLastName = "Morse"; - string newLastName = "Gadget"; - - UserProfileData newProfile = new UserProfileData(); - newProfile.ID = userId; - newProfile.FirstName = firstName; - newProfile.SurName = newLastName; - - TestCommunicationsManager commsManager = new TestCommunicationsManager(); - UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; - IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; - - // Check that we can't update info before it exists - Assert.That(userCacheService.StoreProfile(newProfile), Is.False); - Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); - - // Check that we can update a profile once it exists - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); - - Assert.That(userCacheService.StoreProfile(newProfile), Is.True); - UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; - Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); - Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); - } - */ - - [Test] - public void TestFetchInventory() - { - TestHelper.InMethod(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - - timedOut = true; - lock (this) - { - UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - Assert.That(timedOut, Is.False, "Timed out"); - } - - [Test] - public void TestGetChildFolder() - { - TestHelper.InMethod(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); - userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); - - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); - } - - [Test] - public void TestCreateFolder() - { - TestHelper.InMethod(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); - Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); - - // 1: Try a folder create that should fail because the parent id given does not exist - UUID missingFolderId = UUID.Random(); - InventoryFolderBase myFolder = new InventoryFolderBase(); - myFolder.ID = folderId; - - Assert.That( - userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); - Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); - Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); - Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); - - // 2: Try a folder create that should work - Assert.That( - userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); - Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); - Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); - } - - //[Test] - public void TestUpdateFolder() - { - TestHelper.InMethod(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - InventoryFolderImpl rootFolder = userInfo.RootFolder; - InventoryFolderBase myFolder = new InventoryFolderBase(); - myFolder.ID = folder1Id; - - userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - - // 1: Test updates that don't involve moving the folder - { - string newFolderName1 = "newFolderName1"; - ushort folderType1 = (ushort)AssetType.Texture; - userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); - - InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); - Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); - Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); - - InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder); - Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); - Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); - } - - // 2: Test an update that also involves moving the folder - { - UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061"); - userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); - InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); - - InventoryFolderBase myFolder2 = new InventoryFolderBase(); - myFolder2.ID = folder2Id; - - string newFolderName2 = "newFolderName2"; - ushort folderType2 = (ushort)AssetType.Bodypart; - userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); - - InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id); - Assert.That(newFolderName2, Is.EqualTo(folder1.Name)); - Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type)); - Assert.That(folder2Id, Is.EqualTo(folder1.ParentID)); - - Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); - Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); - - InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2); - Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); - Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); - Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); - } - - } - - [Test] - public void TestMoveFolder() - { - TestHelper.InMethod(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); - UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); - UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); - InventoryFolderImpl rootFolder = userInfo.RootFolder; - - userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); - userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); - InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); - - // Check folder is currently in folder1 - userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id); - Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True); - - userInfo.MoveFolder(folderToMoveId, folder2Id); - - // Check folder is now in folder2 and no trace remains in folder1 - InventoryFolderBase myFolder = new InventoryFolderBase(); - myFolder.ID = folderToMoveId; - Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); - Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); - - Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); - } - - [Test] - public void TestPurgeFolder() - { - TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); - - Scene myScene = SceneSetupHelpers.SetupScene("inventory"); - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); - InventoryFolderImpl rootFolder = userInfo.RootFolder; - InventoryFolderBase myFolder = new InventoryFolderBase(); - myFolder.ID = folder1Id; - - userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); - Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); - - // Test purge - userInfo.PurgeFolder(rootFolder.ID); - - Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); - Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); - } - - [TearDown] - public void TearDown() - { - try - { - if (MainServer.Instance != null) MainServer.Instance.Stop(); - } - catch (System.NullReferenceException) - { } - } - } -} \ No newline at end of file -- cgit v1.1 From 6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 8 Jan 2010 20:31:29 -0800 Subject: A few more inches... Old friends things removed. Less references to UserProfileService. --- .../Communications/CommunicationsManager.cs | 55 --- .../Communications/Tests/LoginServiceTests.cs | 461 --------------------- 2 files changed, 516 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Tests/LoginServiceTests.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 4bf9018..52f6202 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -53,13 +53,6 @@ namespace OpenSim.Framework.Communications } protected IUserService m_userService; - public IMessagingService MessageService - { - get { return m_messageService; } - } - protected IMessagingService m_messageService; - - public UserProfileCacheService UserProfileCacheService { get { return m_userProfileCacheService; } @@ -105,18 +98,6 @@ namespace OpenSim.Framework.Communications } - #region Friend Methods - - /// - /// Adds a new friend to the database for XUser - /// - /// The agent that who's friends list is being added to - /// The agent that being added to the friends list of the friends list owner - /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) - { - m_userService.AddNewUserFriend(friendlistowner, friend, perms); - } /// /// Logs off a user and does the appropriate communications @@ -145,42 +126,6 @@ namespace OpenSim.Framework.Communications m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); } - /// - /// Delete friend on friendlistowner's friendlist. - /// - /// The agent that who's friends list is being updated - /// The Ex-friend agent - public void RemoveUserFriend(UUID friendlistowner, UUID friend) - { - m_userService.RemoveUserFriend(friendlistowner, friend); - } - - /// - /// Update permissions for friend on friendlistowner's friendlist. - /// - /// The agent that who's friends list is being updated - /// The agent that is getting or loosing permissions - /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) - { - m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); - } - - /// - /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner - /// - /// The agent that we're retreiving the friends Data. - public List GetUserFriendList(UUID friendlistowner) - { - return m_userService.GetUserFriendList(friendlistowner); - } - - public Dictionary GetFriendRegionInfos(List uuids) - { - return m_messageService.GetFriendRegionInfos(uuids); - } - - #endregion #region Packet Handlers diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs deleted file mode 100644 index 60f0ba8..0000000 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Text.RegularExpressions; -using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using Nwc.XmlRpc; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Services; -using OpenSim.Region.Communications.Local; -using OpenSim.Tests.Common.Setup; -using OpenSim.Tests.Common.Mock; -using OpenSim.Client.Linden; -using OpenSim.Tests.Common; -using OpenSim.Services.Interfaces; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Tests -{ - /// - /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService - /// is abstract - /// - - [TestFixture] - public class LoginServiceTests - { - private string m_firstName = "Adam"; - private string m_lastName = "West"; - private string m_regionExternalName = "localhost"; - - private IPEndPoint m_capsEndPoint; - private TestCommunicationsManager m_commsManager; - private TestLoginToRegionConnector m_regionConnector; - private LocalUserServices m_localUserServices; - private LoginService m_loginService; - private UserProfileData m_userProfileData; - private TestScene m_testScene; - - [SetUp] - public void SetUpLoginEnviroment() - { - m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); - m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); - m_regionConnector = new TestLoginToRegionConnector(); - m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, ""); - - m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); - - //IInventoryService m_inventoryService = new MockInventoryService(); - - m_localUserServices = (LocalUserServices) m_commsManager.UserService; - m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); - - m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_testScene.InventoryService, - m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector); - - m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); - } - - /// - /// Test the normal response to a login. Does not test authentication. - /// - [Test] - public void T010_TestUnauthenticatedLogin() - { - TestHelper.InMethod(); - // We want to use our own LoginService for this test, one that - // doesn't require authentication. - new LLStandaloneLoginService( - (UserManagerBase)m_commsManager.UserService, "Hello folks", new MockInventoryService(), - m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); - - Hashtable loginParams = new Hashtable(); - loginParams["first"] = m_firstName; - loginParams["last"] = m_lastName; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - - Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); - Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); - Assert.That( - responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); - - Regex capsSeedPattern - = new Regex("^http://" - + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) - + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); - - Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); - } - - [Test] - public void T011_TestAuthenticatedLoginSuccess() - { - TestHelper.InMethod(); - // TODO: Not check inventory part of response yet. - // TODO: Not checking all of login response thoroughly yet. - - // 1) Test for positive authentication - - Hashtable loginParams = new Hashtable(); - loginParams["first"] = m_firstName; - loginParams["last"] = m_lastName; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - - UserAgentData uagent = m_userProfileData.CurrentAgent; - Assert.That(uagent,Is.Not.Null); - - Assert.That(responseData["first_name"], Is.Not.Null); - Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); - Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); - Assert.That(responseData["agent_id"], Is.EqualTo(uagent.ProfileID.ToString())); - Assert.That(responseData["session_id"], Is.EqualTo(uagent.SessionID.ToString())); - Assert.That(responseData["secure_session_id"], Is.EqualTo(uagent.SecureSessionID.ToString())); - ArrayList invlibroot = (ArrayList) responseData["inventory-lib-root"]; - Hashtable invlibroothash = (Hashtable) invlibroot[0]; - Assert.That(invlibroothash["folder_id"],Is.EqualTo("00000112-000f-0000-0000-000100bba000")); - Assert.That( - responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); - Assert.That(responseData["message"], Is.EqualTo("Hello folks")); - Assert.That(responseData["buddy-list"], Is.Empty); - Assert.That(responseData["start_location"], Is.EqualTo("last")); - - Regex capsSeedPattern - = new Regex("^http://" - + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) - + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); - - Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); - } - - [Test] - public void T012_TestAuthenticatedLoginForBuddies() - { - TestHelper.InMethod(); - // 1.1) Test for budddies! - m_localUserServices.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); - m_localUserServices.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); - - UserProfileData friend1 = m_localUserServices.GetUserProfile("Friend","Number1"); - UserProfileData friend2 = m_localUserServices.GetUserProfile("Friend","Number2"); - m_localUserServices.AddNewUserFriend(friend1.ID,m_userProfileData.ID,1); - m_localUserServices.AddNewUserFriend(friend1.ID,friend2.ID,2); - - Hashtable loginParams = new Hashtable(); - loginParams["first"] = "Friend"; - loginParams["last"] = "Number1"; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - - ArrayList friendslist = (ArrayList) responseData["buddy-list"]; - - Assert.That(friendslist,Is.Not.Null); - - Hashtable buddy1 = (Hashtable) friendslist[0]; - Hashtable buddy2 = (Hashtable) friendslist[1]; - Assert.That(friendslist.Count, Is.EqualTo(2)); - Assert.That(m_userProfileData.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); - Assert.That(friend2.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); - } - - [Test] - public void T020_TestAuthenticatedLoginBadUsername() - { - TestHelper.InMethod(); - - // 2) Test for negative authentication - // - string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; - //string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; - // 2.1) Test for wrong user name - Hashtable loginParams = new Hashtable(); - loginParams["first"] = m_lastName; - loginParams["last"] = m_firstName; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); - - } - - [Test] - public void T021_TestAuthenticatedLoginBadPassword() - { - TestHelper.InMethod(); - - string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; - // 2.2) Test for wrong password - Hashtable loginParams = new Hashtable(); - loginParams["first"] = "Friend"; - loginParams["last"] = "Number2"; - loginParams["passwd"] = "boing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); - - } - - [Test] - public void T022_TestAuthenticatedLoginBadXml() - { - TestHelper.InMethod(); - - string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; - // 2.3) Bad XML - Hashtable loginParams = new Hashtable(); - loginParams["first"] = "Friend"; - loginParams["banana"] = "Banana"; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); - - } - - // [Test] - // Commenting out test now that LLStandAloneLoginService no longer replies with message in this case. - // Kept the code for future test with grid mode, which will keep this behavior. - public void T023_TestAuthenticatedLoginAlreadyLoggedIn() - { - TestHelper.InMethod(); - - //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); - //log4net.Config.XmlConfigurator.Configure(); - - string error_already_logged = "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; - // 2.4) Already logged in and sucessfull post login - Hashtable loginParams = new Hashtable(); - loginParams["first"] = "Adam"; - loginParams["last"] = "West"; - loginParams["passwd"] = "boingboing"; - - ArrayList sendParams = new ArrayList(); - sendParams.Add(loginParams); - sendParams.Add(m_capsEndPoint); // is this parameter correct? - sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? - - // First we log in. - XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - - IPAddress tmpLocal = Util.GetLocalHost(); - IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - - Hashtable responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo("Hello folks")); - - // Then we try again, this time expecting failure. - request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); - - // Finally the third time we should be able to get right back in. - request = new XmlRpcRequest("login_to_simulator", sendParams); - - response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); - responseData = (Hashtable)response.Value; - Assert.That(responseData["message"], Is.EqualTo("Hello folks")); - - //Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); - } - - [TearDown] - public void TearDown() - { - try - { - if (MainServer.Instance != null) MainServer.Instance.Stop(); - } catch (NullReferenceException) - {} - } - - public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector - { - private List m_regionsList = new List(); - - public void AddRegion(RegionInfo regionInfo) - { - lock (m_regionsList) - { - if (!m_regionsList.Contains(regionInfo)) - { - m_regionsList.Add(regionInfo); - } - } - } - - #region ILoginRegionsConnector Members - public bool RegionLoginsEnabled - { - get { return true; } - } - - public void LogOffUserFromGrid(ulong regionHandle, OpenMetaverse.UUID AvatarID, OpenMetaverse.UUID RegionSecret, string message) - { - } - - public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) - { - reason = String.Empty; - lock (m_regionsList) - { - foreach (RegionInfo regInfo in m_regionsList) - { - if (regInfo.RegionHandle == regionHandle) - return true; - } - } - reason = "Region not found"; - return false; - } - - public RegionInfo RequestClosestRegion(string region) - { - lock (m_regionsList) - { - foreach (RegionInfo regInfo in m_regionsList) - { - if (regInfo.RegionName == region) - return regInfo; - } - } - - return null; - } - - public RegionInfo RequestNeighbourInfo(OpenMetaverse.UUID regionID) - { - lock (m_regionsList) - { - foreach (RegionInfo regInfo in m_regionsList) - { - if (regInfo.RegionID == regionID) - return regInfo; - } - } - - return null; - } - - public RegionInfo RequestNeighbourInfo(ulong regionHandle) - { - lock (m_regionsList) - { - foreach (RegionInfo regInfo in m_regionsList) - { - if (regInfo.RegionHandle == regionHandle) - return regInfo; - } - } - - return null; - } - - #endregion - } - } -} \ No newline at end of file -- cgit v1.1 From 25fdbd6cbcfc857c444042745d7d4fa8e495a982 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 09:09:32 -0800 Subject: Less refs to UserProfileCacheService. Compiles but likely doesn't run. --- .../Communications/CommunicationsManager.cs | 63 ---------------------- .../Osp/OspInventoryWrapperPlugin.cs | 10 ++-- .../Framework/Communications/Osp/OspResolver.cs | 21 ++++---- 3 files changed, 17 insertions(+), 77 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 52f6202..d215340 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -135,69 +135,6 @@ namespace OpenSim.Framework.Communications return; } - public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) - { - if (uuid == m_userProfileCacheService.LibraryRoot.Owner) - { - remote_client.SendNameReply(uuid, "Mr", "OpenSim"); - } - else - { - string[] names = doUUIDNameRequest(uuid); - if (names.Length == 2) - { - remote_client.SendNameReply(uuid, names[0], names[1]); - } - - } - } - - private string[] doUUIDNameRequest(UUID uuid) - { - lock (m_nameRequestCache) - { - if (m_nameRequestCache.ContainsKey(uuid)) - return m_nameRequestCache[uuid]; - } - - string[] returnstring = new string[0]; - CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid); - - if ((uinfo != null) && (uinfo.UserProfile != null)) - { - returnstring = new string[2]; - returnstring[0] = uinfo.UserProfile.FirstName; - returnstring[1] = uinfo.UserProfile.SurName; - lock (m_nameRequestCache) - { - if (!m_nameRequestCache.ContainsKey(uuid)) - m_nameRequestCache.Add(uuid, returnstring); - } - } - - return returnstring; - } - - public bool UUIDNameCachedTest(UUID uuid) - { - lock (m_nameRequestCache) - return m_nameRequestCache.ContainsKey(uuid); - } - - public string UUIDNameRequestString(UUID uuid) - { - string[] names = doUUIDNameRequest(uuid); - if (names.Length == 2) - { - string firstname = names[0]; - string lastname = names[1]; - - return firstname + " " + lastname; - - } - return "(hippos)"; - } - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) { List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index e96c5e8..bcd1eee 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using OpenSim.Data; using OpenMetaverse; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Osp { @@ -37,12 +38,13 @@ namespace OpenSim.Framework.Communications.Osp public class OspInventoryWrapperPlugin : IInventoryDataPlugin { protected IInventoryDataPlugin m_wrappedPlugin; - protected CommunicationsManager m_commsManager; + //protected CommunicationsManager m_commsManager; + protected IUserAccountService m_userAccountService; - public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, CommunicationsManager commsManager) + public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService) { m_wrappedPlugin = wrappedPlugin; - m_commsManager = commsManager; + m_userAccountService = userService; } public string Name { get { return "OspInventoryWrapperPlugin"; } } @@ -81,7 +83,7 @@ namespace OpenSim.Framework.Communications.Osp protected InventoryItemBase PostProcessItem(InventoryItemBase item) { - item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService); return item; } diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 4013896..14f813a 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -31,6 +31,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Osp { @@ -55,11 +56,11 @@ namespace OpenSim.Framework.Communications.Osp /// /// /// The OSPA. Null if a user with the given UUID could not be found. - public static string MakeOspa(UUID userId, CommunicationsManager commsManager) + public static string MakeOspa(UUID userId, IUserAccountService userService) { - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); - if (userInfo != null) - return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); + UserAccount account = userService.GetUserAccount(UUID.Zero, userId); + if (account != null) + return MakeOspa(account.FirstName, account.LastName); return null; } @@ -88,7 +89,7 @@ namespace OpenSim.Framework.Communications.Osp /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero /// is returned. /// - public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) + public static UUID ResolveOspa(string ospa, IUserAccountService userService) { if (!ospa.StartsWith(OSPA_PREFIX)) return UUID.Zero; @@ -112,7 +113,7 @@ namespace OpenSim.Framework.Communications.Osp string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); if (OSPA_NAME_KEY == key) - return ResolveOspaName(value, commsManager); + return ResolveOspaName(value, userService); } return UUID.Zero; @@ -137,7 +138,7 @@ namespace OpenSim.Framework.Communications.Osp /// /// An OpenSim internal identifier for the name given. Returns null if the name was not valid /// - protected static UUID ResolveOspaName(string name, CommunicationsManager commsManager) + protected static UUID ResolveOspaName(string name, IUserAccountService userService) { int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); @@ -150,9 +151,9 @@ namespace OpenSim.Framework.Communications.Osp string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - if (userInfo != null) - return userInfo.UserProfile.ID; + UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); + if (account != null) + return account.PrincipalID; // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc /* -- cgit v1.1 From 81d5a4b6d8d8548dde98cbf827d171bb1ebf96ba Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 03:03:18 +0000 Subject: Remove "login disable", "login enable" and "login status" commands. --- OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 60f0ba8..a274ae7 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -388,12 +388,6 @@ namespace OpenSim.Framework.Communications.Tests } } - #region ILoginRegionsConnector Members - public bool RegionLoginsEnabled - { - get { return true; } - } - public void LogOffUserFromGrid(ulong regionHandle, OpenMetaverse.UUID AvatarID, OpenMetaverse.UUID RegionSecret, string message) { } @@ -454,8 +448,6 @@ namespace OpenSim.Framework.Communications.Tests return null; } - - #endregion } } -} \ No newline at end of file +} -- cgit v1.1 From 3c90d834eac382af5edf091e83aea1ffcce91792 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 22:41:42 +0000 Subject: Remove all references to master avatar, replacing with estate owner where appropriate. This changes the behavior of the REST plugins and RemoteAdmin's region creation process. --- OpenSim/Framework/Communications/Clients/GridClient.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs index 4836556..0198d75 100644 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ b/OpenSim/Framework/Communications/Clients/GridClient.cs @@ -68,10 +68,7 @@ namespace OpenSim.Framework.Communications.Clients GridParams["region_secret"] = regionInfo.regionSecret; GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); - if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) - GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); - else - GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); + GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); -- cgit v1.1 From 53e83e5dbb3590cb9c858aa301665357d1511b30 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 16:20:59 -0800 Subject: * Starting to clean the house... * Fixed circular dependency --- .../Communications/Cache/CachedUserInfo.cs | 847 --------------------- .../Cache/UserProfileCacheService.cs | 277 ------- .../Communications/CommunicationsManager.cs | 37 - 3 files changed, 1161 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/CachedUserInfo.cs delete mode 100644 OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs deleted file mode 100644 index 6648c36..0000000 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 log4net; -using OpenMetaverse; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications.Cache -{ - internal delegate void AddItemDelegate(InventoryItemBase itemInfo); - internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); - internal delegate void DeleteItemDelegate(UUID itemID); - internal delegate void QueryItemDelegate(UUID itemID); - internal delegate void QueryFolderDelegate(UUID folderID); - - internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); - internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); - internal delegate void PurgeFolderDelegate(UUID folderID); - internal delegate void UpdateFolderDelegate(string name, UUID folderID, ushort type, UUID parentID); - - internal delegate void SendInventoryDescendentsDelegate( - IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); - - public delegate void OnItemReceivedDelegate(UUID itemID); - public delegate void OnInventoryReceivedDelegate(UUID userID); - - /// - /// Stores user profile and inventory data received from backend services for a particular user. - /// - public class CachedUserInfo - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - //// - /// Fired when a particular item has been received from the inventory service - /// - public event OnItemReceivedDelegate OnItemReceived; - - /// - /// Fired once the entire inventory has been received for the user - /// - public event OnInventoryReceivedDelegate OnInventoryReceived; - - /// - /// The comms manager holds references to services (user, grid, inventory, etc.) - /// - private readonly IInventoryService m_InventoryService; - - public UserProfileData UserProfile { get { return m_userProfile; } } - private UserProfileData m_userProfile; - - /// - /// Have we received the user's inventory from the inventory service? - /// - public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } - private bool m_hasReceivedInventory; - - /// - /// Inventory requests waiting for receipt of this user's inventory from the inventory service. - /// - private readonly IList m_pendingRequests = new List(); - - /// - /// The root folder of this user's inventory. Returns null if the root folder has not yet been received. - /// - public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } - private InventoryFolderImpl m_rootFolder; - - public UUID SessionID - { - get { return m_session_id; } - set { m_session_id = value; } - } - private UUID m_session_id = UUID.Zero; - - /// - /// Constructor - /// - /// - /// - public CachedUserInfo(IInventoryService invService, UserProfileData userProfile) - { - m_userProfile = userProfile; - m_InventoryService = invService; - } - - /// - /// This allows a request to be added to be processed once we receive a user's inventory - /// from the inventory service. If we already have the inventory, the request - /// is executed immediately instead. - /// - /// - protected void AddRequest(IInventoryRequest request) - { - lock (m_pendingRequests) - { - if (HasReceivedInventory) - { - request.Execute(); - } - else - { - m_pendingRequests.Add(request); - } - } - } - - /// - /// Helper function for InventoryReceive() - Store a folder temporarily until we've received entire folder list - /// - /// - private void AddFolderToDictionary(InventoryFolderImpl folder, IDictionary> dictionary) - { - UUID parentFolderId = folder.ParentID; - - if (dictionary.ContainsKey(parentFolderId)) - { - dictionary[parentFolderId].Add(folder); - } - else - { - IList folders = new List(); - folders.Add(folder); - dictionary[parentFolderId] = folders; - } - } - - /// - /// Recursively, in depth-first order, add all the folders we've received (stored - /// in a dictionary indexed by parent ID) into the tree that describes user folder - /// heirarchy - /// Any folder that is resolved into the tree is also added to resolvedFolderDictionary, - /// indexed by folder ID. - /// - /// - /// A - /// - private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, - IDictionary> receivedFolderDictionary, - IDictionary resolvedFolderDictionary) - { - if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) - { - List resolvedFolders = new List(); // Folders we've resolved with this invocation - foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID]) - { - if (parentFolder.ContainsChildFolder(folder.ID)) - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", - folder.Name, folder.ID); - } - else - { - if (resolvedFolderDictionary.ContainsKey(folder.ID)) - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", - folder.Name, folder.ID); - } - else - { - resolvedFolders.Add(folder); - resolvedFolderDictionary[folder.ID] = folder; - parentFolder.AddChildFolder(folder); - } - } - } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) - - receivedFolderDictionary.Remove(parentFolder.ID); - foreach (InventoryFolderImpl folder in resolvedFolders) - ResolveReceivedFolders(folder, receivedFolderDictionary, resolvedFolderDictionary); - } // if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) - } - - /// - /// Drop all cached inventory. - /// - public void DropInventory() - { - m_log.Debug("[INVENTORY CACHE]: DropInventory called"); - // Make sure there aren't pending requests around when we do this - // FIXME: There is still a race condition where an inventory operation can be requested (since these aren't being locked). - // Will have to extend locking to exclude this very soon. - lock (m_pendingRequests) - { - m_hasReceivedInventory = false; - m_rootFolder = null; - } - } - - /// - /// Fetch inventory for this user. - /// - /// This has to be executed as a separate step once user information is retreived. - /// This will occur synchronously if the inventory service is in the same process as this class, and - /// asynchronously otherwise. - public void FetchInventory() - { - m_InventoryService.GetUserInventory(UserProfile.ID, InventoryReceive); - } - - /// - /// Callback invoked when the inventory is received from an async request to the inventory service - /// - /// - /// - public void InventoryReceive(ICollection folders, ICollection items) - { - // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these - // are simply being swallowed - - try - { - // collection of all received folders, indexed by their parent ID - IDictionary> receivedFolders = - new Dictionary>(); - - // collection of all folders that have been placed into the folder heirarchy starting at m_rootFolder - // This dictonary exists so we don't have to do an InventoryFolderImpl.FindFolder(), which is O(n) on the - // number of folders in our inventory. - // Maybe we should make this structure a member so we can skip InventoryFolderImpl.FindFolder() calls later too? - IDictionary resolvedFolders = - new Dictionary(); - - // Take all received folders, find the root folder, and put ther rest into - // the pendingCategorizationFolders collection - foreach (InventoryFolderImpl folder in folders) - AddFolderToDictionary(folder, receivedFolders); - - if (!receivedFolders.ContainsKey(UUID.Zero)) - throw new Exception("Database did not return a root inventory folder"); - else - { - IList rootFolderList = receivedFolders[UUID.Zero]; - m_rootFolder = rootFolderList[0]; - resolvedFolders[m_rootFolder.ID] = m_rootFolder; - if (rootFolderList.Count > 1) - { - for (int i = 1; i < rootFolderList.Count; i++) - { - m_log.WarnFormat( - "[INVENTORY CACHE]: Discarding extra root folder {0}. Using previously received root folder {1}", - rootFolderList[i].ID, RootFolder.ID); - } - } - receivedFolders.Remove(UUID.Zero); - } - - // Now take the pendingCategorizationFolders collection, and turn that into a tree, - // with the root being RootFolder - if (RootFolder != null) - ResolveReceivedFolders(RootFolder, receivedFolders, resolvedFolders); - - // Generate a warning for folders that are not part of the heirarchy - foreach (KeyValuePair> folderList in receivedFolders) - { - foreach (InventoryFolderImpl folder in folderList.Value) - m_log.WarnFormat("[INVENTORY CACHE]: Malformed Database: Unresolved Pending Folder {0}", folder.Name); - } - - // Take all ther received items and put them into the folder tree heirarchy - foreach (InventoryItemBase item in items) { - InventoryFolderImpl folder = resolvedFolders.ContainsKey(item.Folder) ? resolvedFolders[item.Folder] : null; - ItemReceive(item, folder); - } - } - catch (Exception e) - { - m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); - } - - // Deal with pending requests - lock (m_pendingRequests) - { - // We're going to change inventory status within the lock to avoid a race condition - // where requests are processed after the AddRequest() method has been called. - m_hasReceivedInventory = true; - - foreach (IInventoryRequest request in m_pendingRequests) - { - request.Execute(); - } - } - - if (OnInventoryReceived != null) - OnInventoryReceived(UserProfile.ID); - } - - /// - /// Callback invoked when an item is received from an async request to the inventory service. - /// - /// We're assuming here that items are always received after all the folders - /// received. - /// If folder is null, we will search for it starting from RootFolder (an O(n) operation), - /// otherwise we'll just put it into folder - /// - /// - private void ItemReceive(InventoryItemBase itemInfo, InventoryFolderImpl folder) - { - // m_log.DebugFormat( - // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", - // itemInfo.Name, itemInfo.ID, userID); - - if (folder == null && RootFolder != null) - folder = RootFolder.FindFolder(itemInfo.Folder); - - if (null == folder) - { - m_log.WarnFormat( - "Received item {0} {1} but its folder {2} does not exist", - itemInfo.Name, itemInfo.ID, itemInfo.Folder); - - return; - } - - lock (folder.Items) - { - folder.Items[itemInfo.ID] = itemInfo; - } - - if (OnItemReceived != null) - OnItemReceived(itemInfo.ID); - } - - /// - /// Create a folder in this agent's inventory. - /// - /// - /// If the inventory service has not yet delievered the inventory - /// for this user then the request will be queued. - /// - /// - /// - public bool CreateFolder(string folderName, UUID folderID, ushort folderType, UUID parentID) - { - // m_log.DebugFormat( - // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); - - if (m_hasReceivedInventory) - { - InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); - - if (null == parentFolder) - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", - folderName, folderID, parentID); - - return false; - } - - InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); - - if (createdFolder != null) - { - InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); - createdBaseFolder.Owner = createdFolder.Owner; - createdBaseFolder.ID = createdFolder.ID; - createdBaseFolder.Name = createdFolder.Name; - createdBaseFolder.ParentID = createdFolder.ParentID; - createdBaseFolder.Type = createdFolder.Type; - createdBaseFolder.Version = createdFolder.Version; - - m_InventoryService.AddFolder(createdBaseFolder); - - return true; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", - folderName, folderID); - - return false; - } - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"), - new object[] { folderName, folderID, folderType, parentID })); - - return true; - } - } - - /// - /// Handle a client request to update the inventory folder - /// - /// - /// If the inventory service has not yet delievered the inventory - /// for this user then the request will be queued. - /// - /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE - /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, - /// and needs to be changed. - /// - /// - /// - /// - /// - public bool UpdateFolder(string name, UUID folderID, ushort type, UUID parentID) - { - // m_log.DebugFormat( - // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); - - if (m_hasReceivedInventory) - { - InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - - // Delegate movement if updated parent id isn't the same as the existing parentId - if (folder.ParentID != parentID) - MoveFolder(folderID, parentID); - - InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.Owner = m_userProfile.ID; - baseFolder.ID = folderID; - baseFolder.Name = name; - baseFolder.ParentID = parentID; - baseFolder.Type = (short)type; - baseFolder.Version = RootFolder.Version; - - m_InventoryService.UpdateFolder(baseFolder); - - folder.Name = name; - folder.Type = (short)type; - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"), - new object[] { name, folderID, type, parentID })); - } - - return true; - } - - /// - /// Handle an inventory folder move request from the client. - /// - /// If the inventory service has not yet delievered the inventory - /// for this user then the request will be queued. - /// - /// - /// - /// - /// - /// true if the delete was successful, or if it was queued pending folder receipt - /// false if the folder to be deleted did not exist. - /// - public bool MoveFolder(UUID folderID, UUID parentID) - { - // m_log.DebugFormat( - // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", - // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); - - if (m_hasReceivedInventory) - { - InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.Owner = m_userProfile.ID; - baseFolder.ID = folderID; - baseFolder.ParentID = parentID; - - m_InventoryService.MoveFolder(baseFolder); - - InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); - if (parentFolder != null && folder != null) - { - InventoryFolderImpl oldParentFolder = RootFolder.FindFolder(folder.ParentID); - - if (oldParentFolder != null) - { - oldParentFolder.RemoveChildFolder(folderID); - parentFolder.AddChildFolder(folder); - } - else - { - return false; - } - } - else - { - return false; - } - - return true; - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"), - new object[] { folderID, parentID })); - - return true; - } - } - - /// - /// This method will delete all the items and folders in the given folder. - /// - /// If the inventory service has not yet delievered the inventory - /// for this user then the request will be queued. - /// - /// - public bool PurgeFolder(UUID folderID) - { - // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", - // folderID, remoteClient.Name, remoteClient.AgentId); - - if (m_hasReceivedInventory) - { - InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID); - - if (purgedFolder != null) - { - // XXX Nasty - have to create a new object to hold details we already have - InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); - purgedBaseFolder.Owner = purgedFolder.Owner; - purgedBaseFolder.ID = purgedFolder.ID; - purgedBaseFolder.Name = purgedFolder.Name; - purgedBaseFolder.ParentID = purgedFolder.ParentID; - purgedBaseFolder.Type = purgedFolder.Type; - purgedBaseFolder.Version = purgedFolder.Version; - - m_InventoryService.PurgeFolder(purgedBaseFolder); - - purgedFolder.Purge(); - - return true; - } - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"), - new object[] { folderID })); - - return true; - } - - return false; - } - - /// - /// Add an item to the user's inventory. - /// - /// If the item has no folder set (i.e. it is UUID.Zero), then it is placed in the most appropriate folder - /// for that type. - /// - public void AddItem(InventoryItemBase item) - { - if (m_hasReceivedInventory) - { - if (item.Folder == UUID.Zero) - { - InventoryFolderImpl f = FindFolderForType(item.AssetType); - if (f != null) - item.Folder = f.ID; - else - item.Folder = RootFolder.ID; - } - ItemReceive(item, null); - - m_InventoryService.AddItem(item); - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(AddItemDelegate), this, "AddItem"), - new object[] { item })); - } - } - - /// - /// Update an item in the user's inventory - /// - /// - /// - public void UpdateItem(InventoryItemBase item) - { - if (m_hasReceivedInventory) - { - m_InventoryService.UpdateItem(item); - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(UpdateItemDelegate), this, "UpdateItem"), - new object[] { item })); - } - } - - /// - /// Delete an item from the user's inventory - /// - /// If the inventory service has not yet delievered the inventory - /// for this user then the request will be queued. - /// - /// - /// - /// true on a successful delete or a if the request is queued. - /// Returns false on an immediate failure - /// - public bool DeleteItem(UUID itemID) - { - if (m_hasReceivedInventory) - { - // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though - // really only the item id is required. - InventoryItemBase item = RootFolder.FindItem(itemID); - - if (null == item) - { - m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID); - - return false; - } - - if (RootFolder.DeleteItem(item.ID)) - { - List uuids = new List(); - uuids.Add(itemID); - return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids); - } - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"), - new object[] { itemID })); - - return true; - } - - return false; - } - - /// - /// Send details of the inventory items and/or folders in a given folder to the client. - /// - /// - /// - /// - /// - /// true if the request was queued or successfully processed, false otherwise - public bool SendInventoryDecendents(IClientAPI client, UUID folderID, int version, bool fetchFolders, bool fetchItems) - { - if (m_hasReceivedInventory) - { - InventoryFolderImpl folder; - - if ((folder = RootFolder.FindFolder(folderID)) != null) - { - // m_log.DebugFormat( - // "[AGENT INVENTORY]: Found folder {0} for client {1}", - // folderID, remoteClient.AgentId); - - client.SendInventoryFolderDetails( - client.AgentId, folderID, folder.RequestListOfItems(), - folder.RequestListOfFolders(), version, fetchFolders, fetchItems); - - return true; - } - else - { - m_log.WarnFormat( - "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", - folderID, client.Name, client.AgentId); - - return false; - } - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents", false, false), - new object[] { client, folderID, fetchFolders, fetchItems })); - - return true; - } - } - - /// - /// Find an appropriate folder for the given asset type - /// - /// - /// null if no appropriate folder exists - public InventoryFolderImpl FindFolderForType(int type) - { - if (RootFolder == null) - return null; - - return RootFolder.FindFolderForType(type); - } - - // Load additional items that other regions have put into the database - // The item will be added tot he local cache. Returns true if the item - // was found and can be sent to the client - // - public bool QueryItem(InventoryItemBase item) - { - if (m_hasReceivedInventory) - { - InventoryItemBase invItem = RootFolder.FindItem(item.ID); - - if (invItem != null) - { - // Item is in local cache, just update client - // - return true; - } - - InventoryItemBase itemInfo = null; - - itemInfo = m_InventoryService.GetItem(item); - - if (itemInfo != null) - { - InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); - ItemReceive(itemInfo, folder); - return true; - } - - return false; - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(QueryItemDelegate), this, "QueryItem"), - new object[] { item.ID })); - - return true; - } - } - - public bool QueryFolder(InventoryFolderBase folder) - { - if (m_hasReceivedInventory) - { - InventoryFolderBase invFolder = RootFolder.FindFolder(folder.ID); - - if (invFolder != null) - { - // Folder is in local cache, just update client - // - return true; - } - - InventoryFolderBase folderInfo = null; - - folderInfo = m_InventoryService.GetFolder(folder); - - if (folderInfo != null) - { - InventoryFolderImpl createdFolder = RootFolder.CreateChildFolder(folderInfo.ID, folderInfo.Name, (ushort)folderInfo.Type); - - createdFolder.Version = folderInfo.Version; - createdFolder.Owner = folderInfo.Owner; - createdFolder.ParentID = folderInfo.ParentID; - - return true; - } - - return false; - } - else - { - AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(QueryFolderDelegate), this, "QueryFolder"), - new object[] { folder.ID })); - - return true; - } - } - } - - /// - /// Should be implemented by callers which require a callback when the user's inventory is received - /// - public interface IInventoryRequest - { - /// - /// This is the method executed once we have received the user's inventory by which the request can be fulfilled. - /// - void Execute(); - } - - /// - /// Generic inventory request - /// - class InventoryRequest : IInventoryRequest - { - private Delegate m_delegate; - private Object[] m_args; - - internal InventoryRequest(Delegate delegat, Object[] args) - { - m_delegate = delegat; - m_args = args; - } - - public void Execute() - { - if (m_delegate != null) - m_delegate.DynamicInvoke(m_args); - } - } -} diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs deleted file mode 100644 index acae4b1..0000000 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications.Cache -{ - /// - /// Holds user profile information and retrieves it from backend services. - /// - public class UserProfileCacheService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Standard format for names. - /// - public const string NAME_FORMAT = "{0} {1}"; - - /// - /// The comms manager holds references to services (user, grid, inventory, etc.) - /// - private readonly CommunicationsManager m_commsManager; - - /// - /// User profiles indexed by UUID - /// - private readonly Dictionary m_userProfilesById - = new Dictionary(); - - /// - /// User profiles indexed by name - /// - private readonly Dictionary m_userProfilesByName - = new Dictionary(); - - /// - /// The root library folder. - /// - public readonly InventoryFolderImpl LibraryRoot; - - private IInventoryService m_InventoryService; - - /// - /// Constructor - /// - /// - /// - public UserProfileCacheService(CommunicationsManager commsManager, LibraryRootFolder libraryRootFolder) - { - m_commsManager = commsManager; - LibraryRoot = libraryRootFolder; - } - - public void SetInventoryService(IInventoryService invService) - { - m_InventoryService = invService; - } - - /// - /// A new user has moved into a region in this instance so retrieve their profile from the user service. - /// - /// - /// It isn't strictly necessary to make this call since user data can be lazily requested later on. However, - /// it might be helpful in order to avoid an initial response delay later on - /// - /// - public void AddNewUser(UUID userID) - { - if (userID == UUID.Zero) - return; - - //m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); - GetUserDetails(userID); - } - - /// - /// Remove this user's profile cache. - /// - /// - /// true if the user was successfully removed, false otherwise - public bool RemoveUser(UUID userId) - { - if (!RemoveFromCaches(userId)) - { - m_log.WarnFormat( - "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); - - return false; - } - - return true; - } - - /// - /// Get details of the given user. - /// - /// If the user isn't in cache then the user is requested from the profile service. - /// - /// null if no user details are found - public CachedUserInfo GetUserDetails(string fname, string lname) - { - lock (m_userProfilesByName) - { - CachedUserInfo userInfo; - - if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) - { - return userInfo; - } - else - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - - if (userProfile != null) - { - - if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) - userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) - userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; - - return AddToCaches(userProfile); - } - else - return null; - } - } - } - - /// - /// Get details of the given user. - /// - /// If the user isn't in cache then the user is requested from the profile service. - /// - /// null if no user details are found - public CachedUserInfo GetUserDetails(UUID userID) - { - if (userID == UUID.Zero) - return null; - - lock (m_userProfilesById) - { - if (m_userProfilesById.ContainsKey(userID)) - { - return m_userProfilesById[userID]; - } - else - { - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); - if (userProfile != null) - { - - if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) - userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) - userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; - - return AddToCaches(userProfile); - } - else - return null; - } - } - } - - /// - /// Update an existing profile - /// - /// - /// true if a user profile was found to update, false otherwise - // Commented out for now. The implementation needs to be improved by protecting against race conditions, - // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via - // returning a read only class from the cache). -// public bool StoreProfile(UserProfileData userProfile) -// { -// lock (m_userProfilesById) -// { -// CachedUserInfo userInfo = GetUserDetails(userProfile.ID); -// -// if (userInfo != null) -// { -// userInfo.m_userProfile = userProfile; -// m_commsManager.UserService.UpdateUserProfile(userProfile); -// -// return true; -// } -// } -// -// return false; -// } - - /// - /// Populate caches with the given user profile - /// - /// - protected CachedUserInfo AddToCaches(UserProfileData userProfile) - { - CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); - - lock (m_userProfilesById) - { - m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; - - lock (m_userProfilesByName) - { - m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; - } - } - - return createdUserInfo; - } - - /// - /// Remove profile belong to the given uuid from the caches - /// - /// - /// true if there was a profile to remove, false otherwise - protected bool RemoveFromCaches(UUID userId) - { - lock (m_userProfilesById) - { - if (m_userProfilesById.ContainsKey(userId)) - { - CachedUserInfo userInfo = m_userProfilesById[userId]; - m_userProfilesById.Remove(userId); - - lock (m_userProfilesByName) - { - m_userProfilesByName.Remove(userInfo.UserProfile.Name); - } - - return true; - } - } - - return false; - } - - /// - /// Preloads User data into the region cache. Modules may use this service to add non-standard clients - /// - /// - public void PreloadUserCache(UserProfileData userData) - { - AddToCaches(userData); - } - } -} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d215340..4dff71f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -53,12 +53,6 @@ namespace OpenSim.Framework.Communications } protected IUserService m_userService; - public UserProfileCacheService UserProfileCacheService - { - get { return m_userProfileCacheService; } - } - protected UserProfileCacheService m_userProfileCacheService; - public IAvatarService AvatarService { get { return m_avatarService; } @@ -94,39 +88,8 @@ namespace OpenSim.Framework.Communications LibraryRootFolder libraryRootFolder) { m_networkServersInfo = serversInfo; - m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); - } - - - - /// - /// Logs off a user and does the appropriate communications - /// - /// - /// - /// - /// - /// - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) - { - m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat); - } - - /// - /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27) - /// - /// - /// - /// - /// - /// - /// - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) - { - m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); } - #region Packet Handlers public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) -- cgit v1.1 From 49618dc102c42b7125303511d826f76f0ebaab4c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 19:19:34 -0800 Subject: Moved GridInfo service from where it was to Handlers/Grid --- .../Communications/Services/GridInfoService.cs | 176 --------------------- 1 file changed, 176 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Services/GridInfoService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs deleted file mode 100644 index cd2a152..0000000 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework.Communications.Services -{ - public class GridInfoService - { - private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable _info = new Hashtable(); - - /// - /// Instantiate a GridInfoService object. - /// - /// path to config path containing - /// grid information - /// - /// GridInfoService uses the [GridInfo] section of the - /// standard OpenSim.ini file --- which is not optimal, but - /// anything else requires a general redesign of the config - /// system. - /// - public GridInfoService(IConfigSource configSource) - { - loadGridInfo(configSource); - } - - /// - /// Default constructor, uses OpenSim.ini. - /// - public GridInfoService() - { - try - { - IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); - loadGridInfo(configSource); - } - catch (FileNotFoundException) - { - _log.Warn( - "[GRID INFO SERVICE]: No OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); - } - } - - private void loadGridInfo(IConfigSource configSource) - { - _info["platform"] = "OpenSim"; - try - { - IConfig startupCfg = configSource.Configs["Startup"]; - IConfig gridCfg = configSource.Configs["GridInfo"]; - IConfig netCfg = configSource.Configs["Network"]; - - bool grid = startupCfg.GetBoolean("gridmode", false); - - if (grid) - _info["mode"] = "grid"; - else - _info["mode"] = "standalone"; - - - if (null != gridCfg) - { - foreach (string k in gridCfg.GetKeys()) - { - _info[k] = gridCfg.GetString(k); - } - } - else if (null != netCfg) - { - if (grid) - _info["login"] - = netCfg.GetString( - "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()); - else - _info["login"] - = String.Format( - "http://127.0.0.1:{0}/", - netCfg.GetString( - "http_listener_port", ConfigSettings.DefaultRegionHttpPort.ToString())); - - IssueWarning(); - } - else - { - _info["login"] = "http://127.0.0.1:9000/"; - IssueWarning(); - } - } - catch (Exception) - { - _log.Debug("[GRID INFO SERVICE]: Cannot get grid info from config source, using minimal defaults"); - } - - _log.DebugFormat("[GRID INFO SERVICE]: Grid info service initialized with {0} keys", _info.Count); - - } - - private void IssueWarning() - { - _log.Warn("[GRID INFO SERVICE]: found no [GridInfo] section in your OpenSim.ini"); - _log.Warn("[GRID INFO SERVICE]: trying to guess sensible defaults, you might want to provide better ones:"); - - foreach (string k in _info.Keys) - { - _log.WarnFormat("[GRID INFO SERVICE]: {0}: {1}", k, _info[k]); - } - } - - public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - - _log.Info("[GRID INFO SERVICE]: Request for grid info"); - - foreach (string k in _info.Keys) - { - responseData[k] = _info[k]; - } - response.Value = responseData; - - return response; - } - - public string RestGetGridInfoMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - StringBuilder sb = new StringBuilder(); - - sb.Append("\n"); - foreach (string k in _info.Keys) - { - sb.AppendFormat("<{0}>{1}\n", k, _info[k]); - } - sb.Append("\n"); - - return sb.ToString(); - } - } -} -- cgit v1.1 From 0c2946031bccf75c28968b6adcde5cce5bc45c13 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 19:42:36 -0800 Subject: CommunicationsManager is practically empty. Only NetworkServersInfo is there. --- .../Communications/CommunicationsManager.cs | 44 ---------------------- .../Framework/Communications/UserManagerBase.cs | 19 ---------- 2 files changed, 63 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 4dff71f..bc04009 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -45,26 +45,6 @@ namespace OpenSim.Framework.Communications { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Dictionary m_nameRequestCache = new Dictionary(); - - public IUserService UserService - { - get { return m_userService; } - } - protected IUserService m_userService; - - public IAvatarService AvatarService - { - get { return m_avatarService; } - } - protected IAvatarService m_avatarService; - - public IInterServiceInventoryServices InterServiceInventoryService - { - get { return m_interServiceInventoryService; } - } - protected IInterServiceInventoryServices m_interServiceInventoryService; - public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } @@ -72,15 +52,6 @@ namespace OpenSim.Framework.Communications protected NetworkServersInfo m_networkServersInfo; /// - /// Interface to user service for administrating users. - /// - public IUserAdminService UserAdminService - { - get { return m_userAdminService; } - } - protected IUserAdminService m_userAdminService; - - /// /// Constructor /// /// @@ -90,20 +61,5 @@ namespace OpenSim.Framework.Communications m_networkServersInfo = serversInfo; } - #region Packet Handlers - - public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) - { - m_userService.UpdateUserProfile(UserProfile); - return; - } - - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) - { - List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); - return pickerlist; - } - - #endregion } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 4f0af06..caa9c1c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -686,25 +686,6 @@ namespace OpenSim.Framework.Communications } else { - // - // WARNING: This is a horrible hack - // The purpose here is to avoid touching the user server at this point. - // There are dragons there that I can't deal with right now. - // diva 06/09/09 - // - if (m_InventoryService != null) - { - // local service (standalone) - m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); - m_InventoryService.CreateUserInventory(userProf.ID); - } - else if (m_commsManager.InterServiceInventoryService != null) - { - // used by the user server - m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); - m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID); - } - return userProf.ID; } } -- cgit v1.1 From dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 20:29:09 -0800 Subject: All Framework.Communications.Clients and Framework.Communications.Services deleted, including old LoginService. --- .../Framework/Communications/Clients/AuthClient.cs | 151 --- .../Framework/Communications/Clients/GridClient.cs | 389 ------ .../Communications/Clients/InventoryClient.cs | 79 -- .../Communications/Clients/RegionClient.cs | 755 ------------ .../Communications/Services/HGLoginAuthService.cs | 339 ------ .../Communications/Services/LoginResponse.cs | 823 ------------- .../Communications/Services/LoginService.cs | 1243 -------------------- 7 files changed, 3779 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Clients/AuthClient.cs delete mode 100644 OpenSim/Framework/Communications/Clients/GridClient.cs delete mode 100644 OpenSim/Framework/Communications/Clients/InventoryClient.cs delete mode 100644 OpenSim/Framework/Communications/Clients/RegionClient.cs delete mode 100644 OpenSim/Framework/Communications/Services/HGLoginAuthService.cs delete mode 100644 OpenSim/Framework/Communications/Services/LoginResponse.cs delete mode 100644 OpenSim/Framework/Communications/Services/LoginService.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs deleted file mode 100644 index adae637..0000000 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 Nwc.XmlRpc; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Clients -{ - public class AuthClient - { - public static string GetNewKey(string authurl, UUID userID, UUID authToken) - { - //Hashtable keyParams = new Hashtable(); - //keyParams["user_id"] = userID; - //keyParams["auth_token"] = authKey; - - List SendParams = new List(); - SendParams.Add(userID.ToString()); - SendParams.Add(authToken.ToString()); - - XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); - XmlRpcResponse reply; - try - { - reply = request.Send(authurl, 6000); - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); - return string.Empty; - } - - if (!reply.IsFault) - { - string newKey = string.Empty; - if (reply.Value != null) - newKey = (string)reply.Value; - - return newKey; - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); - return string.Empty; - } - - } - - public static bool VerifyKey(string authurl, UUID userID, string authKey) - { - List SendParams = new List(); - SendParams.Add(userID.ToString()); - SendParams.Add(authKey); - - System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl); - - XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); - XmlRpcResponse reply; - try - { - reply = request.Send(authurl, 10000); - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); - return false; - } - - if (reply != null) - { - if (!reply.IsFault) - { - bool success = false; - if (reply.Value != null) - success = (bool)reply.Value; - - return success; - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); - return false; - } - } - else - { - System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); - return false; - } - } - - public static bool VerifySession(string authurl, UUID userID, UUID sessionID) - { - Hashtable requestData = new Hashtable(); - requestData["avatar_uuid"] = userID.ToString(); - requestData["session_id"] = sessionID.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); - XmlRpcResponse UserResp = null; - try - { - UserResp = UserReq.Send(authurl, 3000); - } - catch (Exception e) - { - System.Console.WriteLine("[Session Auth]: VerifySession XmlRpc: " + e.Message); - return false; - } - - Hashtable responseData = (Hashtable)UserResp.Value; - if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") - { - //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); - return true; - } - else - { - //System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); - return false; - } - } - } -} diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs deleted file mode 100644 index 0198d75..0000000 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; - -using log4net; -using OpenMetaverse; -using Nwc.XmlRpc; - -namespace OpenSim.Framework.Communications.Clients -{ - public class GridClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public bool RegisterRegion( - string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) - { - m_log.InfoFormat( - "[GRID CLIENT]: Registering region {0} with grid at {1}", regionInfo.RegionName, gridServerURL); - - forcefulBanLines = true; - - Hashtable GridParams = new Hashtable(); - // Login / Authentication - - GridParams["authkey"] = sendKey; - GridParams["recvkey"] = receiveKey; - GridParams["UUID"] = regionInfo.RegionID.ToString(); - GridParams["sim_ip"] = regionInfo.ExternalHostName; - GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); - GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); - GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); - GridParams["sim_name"] = regionInfo.RegionName; - GridParams["http_port"] = regionInfo.HttpPort.ToString(); - GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); - GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); - GridParams["originUUID"] = regionInfo.originRegionID.ToString(); - GridParams["server_uri"] = regionInfo.ServerURI; - GridParams["region_secret"] = regionInfo.regionSecret; - GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); - - GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); - XmlRpcResponse GridResp; - - try - { - // The timeout should always be significantly larger than the timeout for the grid server to request - // the initial status of the region before confirming registration. - GridResp = GridReq.Send(gridServerURL, 90000); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to register region with grid at {0}. Grid service not running?", - gridServerURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable)GridResp.Value; - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData.ContainsKey("error")) - { - string errorstring = (string)GridRespData["error"]; - - Exception e = new Exception( - String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); - - throw e; - } - else - { - // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); - if (GridRespData.ContainsKey("allow_forceful_banlines")) - { - if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") - { - forcefulBanLines = false; - } - } - - } - return true; - } - - public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg) - { - errorMsg = ""; - Hashtable GridParams = new Hashtable(); - - GridParams["UUID"] = regionInfo.RegionID.ToString(); - - // Package into an XMLRPC Request - ArrayList SendParams = new ArrayList(); - SendParams.Add(GridParams); - - // Send Request - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); - XmlRpcResponse GridResp = null; - - try - { - GridResp = GridReq.Send(gridServerURL, 10000); - } - catch (Exception e) - { - Exception e2 - = new Exception( - String.Format( - "Unable to deregister region with grid at {0}. Grid service not running?", - gridServerURL), - e); - - throw e2; - } - - Hashtable GridRespData = (Hashtable)GridResp.Value; - - // Hashtable griddatahash = GridRespData; - - // Process Response - if (GridRespData != null && GridRespData.ContainsKey("error")) - { - errorMsg = (string)GridRespData["error"]; - return false; - } - - return true; - } - - public bool RequestNeighborInfo( - string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, - out RegionInfo regionInfo, out string errorMsg) - { - // didn't find it so far, we have to go the long way - regionInfo = null; - errorMsg = string.Empty; - Hashtable requestData = new Hashtable(); - requestData["region_UUID"] = regionUUID.ToString(); - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse gridResp = null; - - try - { - gridResp = gridReq.Send(gridServerURL, 3000); - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - - Hashtable responseData = (Hashtable)gridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; ; - } - - regionInfo = BuildRegionInfo(responseData, String.Empty); - - return true; - } - - public bool RequestNeighborInfo( - string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, - out RegionInfo regionInfo, out string errorMsg) - { - // didn't find it so far, we have to go the long way - regionInfo = null; - errorMsg = string.Empty; - - try - { - Hashtable requestData = new Hashtable(); - requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; - } - - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string externalHostName = (string)responseData["sim_ip"]; - uint simPort = Convert.ToUInt32(responseData["sim_port"]); - string regionName = (string)responseData["region_name"]; - UUID regionID = new UUID((string)responseData["region_UUID"]); - uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); - - uint httpPort = 9000; - if (responseData.ContainsKey("http_port")) - { - httpPort = Convert.ToUInt32((string)responseData["http_port"]); - } - - // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? - - string simURI = "http://" + externalHostName + ":" + simPort; - - // string externalUri = (string) responseData["sim_uri"]; - - //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); - regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - - return true; - } - - public bool RequestClosestRegion( - string gridServerURL, string sendKey, string receiveKey, string regionName, - out RegionInfo regionInfo, out string errorMsg) - { - regionInfo = null; - errorMsg = string.Empty; - try - { - Hashtable requestData = new Hashtable(); - requestData["region_name_search"] = regionName; - requestData["authkey"] = sendKey; - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("error")) - { - errorMsg = (string)responseData["error"]; - return false; - } - - regionInfo = BuildRegionInfo(responseData, ""); - - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - return true; - } - - /// - /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates - /// - /// REDUNDANT - OGS1 is to be phased out in favour of OGS2 - /// Minimum X value - /// Minimum Y value - /// Maximum X value - /// Maximum Y value - /// Hashtable of hashtables containing map data elements - public bool MapBlockQuery( - string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) - { - respData = new Hashtable(); - errorMsg = string.Empty; - - Hashtable param = new Hashtable(); - param["xmin"] = minX; - param["ymin"] = minY; - param["xmax"] = maxX; - param["ymax"] = maxY; - IList parameters = new ArrayList(); - parameters.Add(param); - - try - { - XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); - XmlRpcResponse resp = req.Send(gridServerURL, 10000); - respData = (Hashtable)resp.Value; - return true; - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - } - - public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) - { - respData = null; - errorMsg = string.Empty; - try - { - XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); - XmlRpcResponse resp = request.Send(gridServerURL, 10000); - respData = (Hashtable)resp.Value; - if (respData != null && respData.Contains("faultCode")) - { - errorMsg = (string)respData["faultString"]; - return false; - } - - return true; - } - catch (Exception e) - { - errorMsg = e.Message; - return false; - } - } - - public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix) - { - uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]); - uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]); - string internalIpStr = (string)responseData[prefix + "sim_ip"]; - uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); - - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port); - - RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]); - regionInfo.RemotingAddress = internalIpStr; - - if (responseData.ContainsKey(prefix + "http_port")) - { - regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]); - } - - regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]); - regionInfo.RegionName = (string)responseData[prefix + "region_name"]; - - regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]); - return regionInfo; - } - } -} diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs deleted file mode 100644 index e4f5e2a..0000000 --- a/OpenSim/Framework/Communications/Clients/InventoryClient.cs +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c), Contributors. All rights reserved. - * 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 Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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 OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; - -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Clients -{ - public class InventoryClient - { - private string ServerURL; - - public InventoryClient(string url) - { - ServerURL = url; - } - - public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse callBack) - { - System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL); - try - { - RestSessionObjectPosterResponse requester - = new RestSessionObjectPosterResponse(); - requester.ResponseCallback = callBack; - - requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty); - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); - } - } - - public InventoryItemBase GetInventoryItem(InventoryItemBase item) - { - System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL); - try - { - item = SynchronousRestSessionObjectPoster.BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, "", ""); - return item; - } - catch (Exception e) - { - System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); - } - return null; - } - - } -} diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs deleted file mode 100644 index ee7dec8..0000000 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Net; -using System.Reflection; -using System.Text; - -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -using log4net; - -namespace OpenSim.Framework.Communications.Clients -{ - public class RegionClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) - { - reason = String.Empty; - - // Eventually, we want to use a caps url instead of the agentID - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); - reason = e.Message; - return false; - } - - //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); - - HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); - AgentCreateRequest.Method = "POST"; - AgentCreateRequest.ContentType = "application/json"; - AgentCreateRequest.Timeout = 10000; - //AgentCreateRequest.KeepAlive = false; - AgentCreateRequest.Headers.Add("Authorization", authKey); - - // Fill it in - OSDMap args = null; - try - { - args = aCircuit.PackAgentCircuitData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = AgentCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - reason = "cannot contact remote region"; - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - WebResponse webResponse = null; - StreamReader sr = null; - try - { - webResponse = AgentCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); - } - else - { - - sr = new StreamReader(webResponse.GetResponseStream()); - string response = sr.ReadToEnd().Trim(); - m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); - - if (!String.IsNullOrEmpty(response)) - { - try - { - // we assume we got an OSDMap back - OSDMap r = GetOSDMap(response); - bool success = r["success"].AsBoolean(); - reason = r["reason"].AsString(); - return success; - } - catch (NullReferenceException e) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); - - // check for old style response - if (response.ToLower().StartsWith("true")) - return true; - - return false; - } - } - } - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) - { - // Eventually, we want to use a caps url instead of the agentID - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); - return false; - } - //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); - - HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); - ChildUpdateRequest.Method = "PUT"; - ChildUpdateRequest.ContentType = "application/json"; - ChildUpdateRequest.Timeout = 10000; - //ChildUpdateRequest.KeepAlive = false; - - // Fill it in - OSDMap args = null; - try - { - args = cAgentData.Pack(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ChildUpdateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); - - WebResponse webResponse = null; - StreamReader sr = null; - try - { - webResponse = ChildUpdateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) - { - agent = null; - // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); - request.Method = "GET"; - request.Timeout = 10000; - //request.Headers.Add("authorization", ""); // coming soon - - HttpWebResponse webResponse = null; - string reply = string.Empty; - StreamReader sr = null; - try - { - webResponse = (HttpWebResponse)request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent get "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - reply = sr.ReadToEnd().Trim(); - - //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); - // ignore, really - return false; - } - finally - { - if (sr != null) - sr.Close(); - } - - if (webResponse.StatusCode == HttpStatusCode.OK) - { - // we know it's jason - OSDMap args = GetOSDMap(reply); - if (args == null) - { - //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); - return false; - } - - agent = new CompleteAgentData(); - agent.Unpack(args); - return true; - } - - //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); - return false; - } - - public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) - { - //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - StreamReader sr = null; - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - - public bool DoCloseAgentCall(GridRegion region, UUID id) - { - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); - return false; - } - - //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - StreamReader sr = null; - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri - = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort - + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "POST"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["sog"] = OSD.FromString(sogXml2); - args["extra"] = OSD.FromString(sog.ExtraToXmlString()); - if (allowScriptCrossing) - { - string state = sog.GetStateSnapshot(); - if (state.Length > 0) - args["state"] = OSD.FromString(state); - } - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "PUT"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["userid"] = OSD.FromUUID(userID); - args["itemid"] = OSD.FromUUID(itemID); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) - { - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; - //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); - - WebRequest HelloNeighbourRequest = WebRequest.Create(uri); - HelloNeighbourRequest.Method = "POST"; - HelloNeighbourRequest.ContentType = "application/json"; - HelloNeighbourRequest.Timeout = 10000; - - // Fill it in - OSDMap args = null; - try - { - args = thisRegion.PackRegionInfoData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send - os = HelloNeighbourRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = HelloNeighbourRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - #region Hyperlinks - - public virtual ulong GetRegionHandle(ulong handle) - { - return handle; - } - - public virtual bool IsHyperlink(ulong handle) - { - return false; - } - - public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) - { - } - - public virtual void AdjustUserInformation(AgentCircuitData aCircuit) - { - } - - #endregion /* Hyperlinks */ - - public static OSDMap GetOSDMap(string data) - { - OSDMap args = null; - try - { - OSD buffer; - // We should pay attention to the content-type, but let's assume we know it's Json - buffer = OSDParser.DeserializeJson(data); - if (buffer.Type == OSDType.Map) - { - args = (OSDMap)buffer; - return args; - } - else - { - // uh? - System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); - return null; - } - } - catch (Exception ex) - { - System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); - return null; - } - } - - - } -} diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs deleted file mode 100644 index d3f813e..0000000 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Servers; - -using OpenMetaverse; - -using log4net; -using Nini.Config; -using Nwc.XmlRpc; - -namespace OpenSim.Framework.Communications.Services -{ - public class HGLoginAuthService : LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected NetworkServersInfo m_serversInfo; - protected bool m_authUsers = false; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_interServiceInventoryService; - - /// - /// Used to make requests to the local regions. - /// - protected ILoginServiceToRegionsConnector m_regionsConnector; - - public HGLoginAuthService( - UserManagerBase userManager, string welcomeMess, - IInterServiceInventoryServices interServiceInventoryService, - NetworkServersInfo serversInfo, - bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) - : base(userManager, libraryRootFolder, welcomeMess) - { - this.m_serversInfo = serversInfo; - if (m_serversInfo != null) - { - m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; - m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; - } - m_authUsers = authenticate; - - m_interServiceInventoryService = interServiceInventoryService; - m_regionsConnector = regionsConnector; - m_interInventoryService = interServiceInventoryService; - } - - public void SetServersInfo(NetworkServersInfo sinfo) - { - m_serversInfo = sinfo; - } - - public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - m_log.Info("[HGLOGIN]: HGLogin called " + request.MethodName); - XmlRpcResponse response = base.XmlRpcLoginMethod(request, remoteClient); - Hashtable responseData = (Hashtable)response.Value; - - responseData["grid_service"] = m_serversInfo.GridURL; - responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; - responseData["inventory_service"] = m_serversInfo.InventoryURL; - responseData["asset_service"] = m_serversInfo.AssetURL; - responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; - int x = (Int32)responseData["region_x"]; - int y = (Int32)responseData["region_y"]; - uint ux = (uint)(x / Constants.RegionSize); - uint uy = (uint)(y / Constants.RegionSize); - ulong regionHandle = Util.UIntsToLong(ux, uy); - responseData["region_handle"] = regionHandle.ToString(); - - // Let's remove the seed cap from the login - //responseData.Remove("seed_capability"); - - // Let's add the appearance - UUID userID = UUID.Zero; - UUID.TryParse((string)responseData["agent_id"], out userID); - AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); - if (appearance == null) - { - m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); - appearance = new AvatarAppearance(); - } - - responseData["appearance"] = appearance.ToHashTable(); - - // Let's also send the auth token - UUID token = UUID.Random(); - responseData["auth_token"] = token.ToString(); - UserProfileData userProfile = m_userManager.GetUserProfile(userID); - if (userProfile != null) - { - userProfile.WebLoginKey = token; - m_userManager.CommitAgent(ref userProfile); - } - m_log.Warn("[HGLOGIN]: Auth token: " + token); - - - return response; - } - - public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - // Verify the key of who's calling - UUID userID = UUID.Zero; - UUID authKey = UUID.Zero; - UUID.TryParse((string)request.Params[0], out userID); - UUID.TryParse((string)request.Params[1], out authKey); - - m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); - string newKey = string.Empty; - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); - } - else - { - newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = (string) newKey; - return response; - } - - public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - bool success = false; - - if (request.Params.Count >= 2) - { - // Verify the key of who's calling - UUID userID = UUID.Zero; - string authKey = string.Empty; - if (UUID.TryParse((string)request.Params[0], out userID)) - { - authKey = (string)request.Params[1]; - - m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); - - if (!(m_userManager is IAuthentication)) - { - m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); - } - else - { - success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); - } - } - } - - m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = success; - return response; - } - - public override UserProfileData GetTheUser(string firstname, string lastname) - { - UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); - if (profile != null) - { - return profile; - } - - if (!m_authUsers) - { - //no current user account so make one - m_log.Info("[LOGIN]: No user account found so creating a new one."); - - m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); - - return m_userManager.GetUserProfile(firstname, lastname); - } - - return null; - } - - public override bool AuthenticateUser(UserProfileData profile, string password) - { - if (!m_authUsers) - { - //for now we will accept any password in sandbox mode - m_log.Info("[LOGIN]: Authorising user (no actual password check)"); - - return true; - } - else - { - m_log.Info( - "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); - - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - - bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); - return loginresult; - } - } - - protected override RegionInfo RequestClosestRegion(string region) - { - return m_regionsConnector.RequestClosestRegion(region); - } - - protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); - } - - protected override RegionInfo GetRegionInfo(UUID homeRegionId) - { - return m_regionsConnector.RequestNeighbourInfo(homeRegionId); - } - - /// - /// Not really informing the region. Just filling out the response fields related to the region. - /// - /// - /// - /// - /// true if the region was successfully contacted, false otherwise - protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) - { - IPEndPoint endPoint = regionInfo.ExternalEndPoint; - response.SimAddress = endPoint.Address.ToString(); - response.SimPort = (uint)endPoint.Port; - response.RegionX = regionInfo.RegionLocX; - response.RegionY = regionInfo.RegionLocY; - response.SimHttpPort = regionInfo.HttpPort; - - string capsPath = CapsUtil.GetRandomCapsObjectPath(); - string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); - - // Don't use the following! It Fails for logging into any region not on the same port as the http server! - // Kept here so it doesn't happen again! - // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; - - string seedcap = "http://"; - - if (m_serversInfo.HttpUsesSSL) - { - // For NAT - string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN); - - seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath; - } - else - { - // For NAT - string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName); - - seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath; - } - - response.SeedCapability = seedcap; - - // Notify the target of an incoming user - m_log.InfoFormat( - "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", - regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); - - // Update agent with target sim - user.CurrentAgent.Region = regionInfo.RegionID; - user.CurrentAgent.Handle = regionInfo.RegionHandle; - - return true; - } - - public override void LogOffUser(UserProfileData theUser, string message) - { - RegionInfo SimInfo; - try - { - SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); - - if (SimInfo == null) - { - m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); - return; - } - } - catch (Exception) - { - m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); - return; - } - - m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); - } - - protected override bool AllowLoginWithoutInventory() - { - return true; - } - - } -} diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs deleted file mode 100644 index ec5f428..0000000 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ /dev/null @@ -1,823 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -namespace OpenSim.Framework.Communications.Services -{ - /// - /// A temp class to handle login response. - /// Should make use of UserProfileManager where possible. - /// - public class LoginResponse - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Hashtable loginFlagsHash; - private Hashtable globalTexturesHash; - private Hashtable loginError; - private Hashtable uiConfigHash; - - private ArrayList loginFlags; - private ArrayList globalTextures; - private ArrayList eventCategories; - private ArrayList uiConfig; - private ArrayList classifiedCategories; - private ArrayList inventoryRoot; - private ArrayList initialOutfit; - private ArrayList agentInventory; - private ArrayList inventoryLibraryOwner; - private ArrayList inventoryLibRoot; - private ArrayList inventoryLibrary; - private ArrayList activeGestures; - - private UserInfo userProfile; - - private UUID agentID; - private UUID sessionID; - private UUID secureSessionID; - - // Login Flags - private string dst; - private string stipendSinceLogin; - private string gendered; - private string everLoggedIn; - private string login; - private uint simPort; - private uint simHttpPort; - private string simAddress; - private string agentAccess; - private string agentAccessMax; - private Int32 circuitCode; - private uint regionX; - private uint regionY; - - // Login - private string firstname; - private string lastname; - - // Global Textures - private string sunTexture; - private string cloudTexture; - private string moonTexture; - - // Error Flags - private string errorReason; - private string errorMessage; - - // Response - private XmlRpcResponse xmlRpcResponse; - // private XmlRpcResponse defaultXmlRpcResponse; - - private string welcomeMessage; - private string startLocation; - private string allowFirstLife; - private string home; - private string seedCapability; - private string lookAt; - - private BuddyList m_buddyList = null; - - public LoginResponse() - { - loginFlags = new ArrayList(); - globalTextures = new ArrayList(); - eventCategories = new ArrayList(); - uiConfig = new ArrayList(); - classifiedCategories = new ArrayList(); - - loginError = new Hashtable(); - uiConfigHash = new Hashtable(); - - // defaultXmlRpcResponse = new XmlRpcResponse(); - userProfile = new UserInfo(); - inventoryRoot = new ArrayList(); - initialOutfit = new ArrayList(); - agentInventory = new ArrayList(); - inventoryLibrary = new ArrayList(); - inventoryLibraryOwner = new ArrayList(); - activeGestures = new ArrayList(); - - xmlRpcResponse = new XmlRpcResponse(); - // defaultXmlRpcResponse = new XmlRpcResponse(); - - SetDefaultValues(); - } - - private void SetDefaultValues() - { - DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; - StipendSinceLogin = "N"; - Gendered = "Y"; - EverLoggedIn = "Y"; - login = "false"; - firstname = "Test"; - lastname = "User"; - agentAccess = "M"; - agentAccessMax = "A"; - startLocation = "last"; - allowFirstLife = "Y"; - - SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; - MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; - - ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; - ErrorReason = "key"; - welcomeMessage = "Welcome to OpenSim!"; - seedCapability = String.Empty; - home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + - userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + - userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + - userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; - lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; - RegionX = (uint) 255232; - RegionY = (uint) 254976; - - // Classifieds; - AddClassifiedCategory((Int32) 1, "Shopping"); - AddClassifiedCategory((Int32) 2, "Land Rental"); - AddClassifiedCategory((Int32) 3, "Property Rental"); - AddClassifiedCategory((Int32) 4, "Special Attraction"); - AddClassifiedCategory((Int32) 5, "New Products"); - AddClassifiedCategory((Int32) 6, "Employment"); - AddClassifiedCategory((Int32) 7, "Wanted"); - AddClassifiedCategory((Int32) 8, "Service"); - AddClassifiedCategory((Int32) 9, "Personal"); - - SessionID = UUID.Random(); - SecureSessionID = UUID.Random(); - AgentID = UUID.Random(); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - initialOutfit.Add(InitialOutfitHash); - } - - #region Login Failure Methods - - public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) - { - // Overwrite any default values; - xmlRpcResponse = new XmlRpcResponse(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - loginError["reason"] = ErrorReason; - loginError["message"] = ErrorMessage; - loginError["login"] = login; - xmlRpcResponse.Value = loginError; - return (xmlRpcResponse); - } - - public OSD GenerateFailureResponseLLSD(string reason, string message, string login) - { - OSDMap map = new OSDMap(); - - // Ensure Login Failed message/reason; - ErrorMessage = message; - ErrorReason = reason; - - map["reason"] = OSD.FromString(ErrorReason); - map["message"] = OSD.FromString(ErrorMessage); - map["login"] = OSD.FromString(login); - - return map; - } - - public XmlRpcResponse CreateFailedResponse() - { - return (CreateLoginFailedResponse()); - } - - public OSD CreateFailedResponseLLSD() - { - return CreateLoginFailedResponseLLSD(); - } - - public XmlRpcResponse CreateLoginFailedResponse() - { - return - (GenerateFailureResponse("key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false")); - } - - public OSD CreateLoginFailedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", - "false"); - } - - /// - /// Response to indicate that login failed because the agent's inventory was not available. - /// - /// - public XmlRpcResponse CreateLoginInventoryFailedResponse() - { - return GenerateFailureResponse( - "key", - "The avatar inventory service is not responding. Please notify your login region operator.", - "false"); - } - - public XmlRpcResponse CreateAlreadyLoggedInResponse() - { - return - (GenerateFailureResponse("presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner. " + - "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", - "false")); - } - - public OSD CreateAlreadyLoggedInResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "You appear to be already logged in. " + - "If this is not the case please wait for your session to timeout. " + - "If this takes longer than a few minutes please contact the grid owner", - "false"); - } - - public XmlRpcResponse CreateLoginBlockedResponse() - { - return - (GenerateFailureResponse("presence", - "Logins are currently restricted. Please try again later", - "false")); - } - - public OSD CreateLoginBlockedResponseLLSD() - { - return GenerateFailureResponseLLSD( - "presence", - "Logins are currently restricted. Please try again later", - "false"); - } - - public XmlRpcResponse CreateDeadRegionResponse() - { - return - (GenerateFailureResponse("key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false")); - } - - public OSD CreateDeadRegionResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "The region you are attempting to log into is not responding. Please select another region and try again.", - "false"); - } - - public XmlRpcResponse CreateGridErrorResponse() - { - return - (GenerateFailureResponse("key", - "Error connecting to grid. Could not percieve credentials from login XML.", - "false")); - } - - public OSD CreateGridErrorResponseLLSD() - { - return GenerateFailureResponseLLSD( - "key", - "Error connecting to grid. Could not perceive credentials from login XML.", - "false"); - } - - #endregion - - public virtual XmlRpcResponse ToXmlRpcResponse() - { - try - { - Hashtable responseData = new Hashtable(); - - loginFlagsHash = new Hashtable(); - loginFlagsHash["daylight_savings"] = DST; - loginFlagsHash["stipend_since_login"] = StipendSinceLogin; - loginFlagsHash["gendered"] = Gendered; - loginFlagsHash["ever_logged_in"] = EverLoggedIn; - loginFlags.Add(loginFlagsHash); - - responseData["first_name"] = Firstname; - responseData["last_name"] = Lastname; - responseData["agent_access"] = agentAccess; - responseData["agent_access_max"] = agentAccessMax; - - globalTexturesHash = new Hashtable(); - globalTexturesHash["sun_texture_id"] = SunTexture; - globalTexturesHash["cloud_texture_id"] = CloudTexture; - globalTexturesHash["moon_texture_id"] = MoonTexture; - globalTextures.Add(globalTexturesHash); - // this.eventCategories.Add(this.eventCategoriesHash); - - AddToUIConfig("allow_first_life", allowFirstLife); - uiConfig.Add(uiConfigHash); - - responseData["sim_port"] = (Int32) SimPort; - responseData["sim_ip"] = SimAddress; - responseData["http_port"] = (Int32)SimHttpPort; - - responseData["agent_id"] = AgentID.ToString(); - responseData["session_id"] = SessionID.ToString(); - responseData["secure_session_id"] = SecureSessionID.ToString(); - responseData["circuit_code"] = CircuitCode; - responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = loginFlags; - responseData["global-textures"] = globalTextures; - responseData["seed_capability"] = seedCapability; - - responseData["event_categories"] = eventCategories; - responseData["event_notifications"] = new ArrayList(); // todo - responseData["classified_categories"] = classifiedCategories; - responseData["ui-config"] = uiConfig; - - if (agentInventory != null) - { - responseData["inventory-skeleton"] = agentInventory; - responseData["inventory-root"] = inventoryRoot; - } - responseData["inventory-skel-lib"] = inventoryLibrary; - responseData["inventory-lib-root"] = inventoryLibRoot; - responseData["gestures"] = activeGestures; - responseData["inventory-lib-owner"] = inventoryLibraryOwner; - responseData["initial-outfit"] = initialOutfit; - responseData["start_location"] = startLocation; - responseData["seed_capability"] = seedCapability; - responseData["home"] = home; - responseData["look_at"] = lookAt; - responseData["message"] = welcomeMessage; - responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); - responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); - - if (m_buddyList != null) - { - responseData["buddy-list"] = m_buddyList.ToArray(); - } - - responseData["login"] = "true"; - xmlRpcResponse.Value = responseData; - - return (xmlRpcResponse); - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); - - return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); - } - } - - public OSD ToLLSDResponse() - { - try - { - OSDMap map = new OSDMap(); - - map["first_name"] = OSD.FromString(Firstname); - map["last_name"] = OSD.FromString(Lastname); - map["agent_access"] = OSD.FromString(agentAccess); - map["agent_access_max"] = OSD.FromString(agentAccessMax); - - map["sim_port"] = OSD.FromInteger(SimPort); - map["sim_ip"] = OSD.FromString(SimAddress); - - map["agent_id"] = OSD.FromUUID(AgentID); - map["session_id"] = OSD.FromUUID(SessionID); - map["secure_session_id"] = OSD.FromUUID(SecureSessionID); - map["circuit_code"] = OSD.FromInteger(CircuitCode); - map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); - - #region Login Flags - - OSDMap loginFlagsLLSD = new OSDMap(); - loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); - loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); - loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); - loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); - map["login-flags"] = WrapOSDMap(loginFlagsLLSD); - - #endregion Login Flags - - #region Global Textures - - OSDMap globalTexturesLLSD = new OSDMap(); - globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); - globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); - globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); - - map["global-textures"] = WrapOSDMap(globalTexturesLLSD); - - #endregion Global Textures - - map["seed_capability"] = OSD.FromString(seedCapability); - - map["event_categories"] = ArrayListToOSDArray(eventCategories); - //map["event_notifications"] = new OSDArray(); // todo - map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); - - #region UI Config - - OSDMap uiConfigLLSD = new OSDMap(); - uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); - map["ui-config"] = WrapOSDMap(uiConfigLLSD); - - #endregion UI Config - - #region Inventory - - map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); - - map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; - map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); - map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); - - #endregion Inventory - - map["gestures"] = ArrayListToOSDArray(activeGestures); - - map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); - map["start_location"] = OSD.FromString(startLocation); - - map["seed_capability"] = OSD.FromString(seedCapability); - map["home"] = OSD.FromString(home); - map["look_at"] = OSD.FromString(lookAt); - map["message"] = OSD.FromString(welcomeMessage); - map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); - map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); - - if (m_buddyList != null) - { - map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); - } - - map["login"] = OSD.FromString("true"); - - return map; - } - catch (Exception e) - { - m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); - - return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); - } - } - - public OSDArray ArrayListToOSDArray(ArrayList arrlst) - { - OSDArray llsdBack = new OSDArray(); - foreach (Hashtable ht in arrlst) - { - OSDMap mp = new OSDMap(); - foreach (DictionaryEntry deHt in ht) - { - mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); - } - llsdBack.Add(mp); - } - return llsdBack; - } - - private static OSDArray WrapOSDMap(OSDMap wrapMe) - { - OSDArray array = new OSDArray(); - array.Add(wrapMe); - return array; - } - - public void SetEventCategories(string category, string value) - { - // this.eventCategoriesHash[category] = value; - //TODO - } - - public void AddToUIConfig(string itemName, string item) - { - uiConfigHash[itemName] = item; - } - - public void AddClassifiedCategory(Int32 ID, string categoryName) - { - Hashtable hash = new Hashtable(); - hash["category_name"] = categoryName; - hash["category_id"] = ID; - classifiedCategories.Add(hash); - // this.classifiedCategoriesHash.Clear(); - } - - #region Properties - - public string Login - { - get { return login; } - set { login = value; } - } - - public string DST - { - get { return dst; } - set { dst = value; } - } - - public string StipendSinceLogin - { - get { return stipendSinceLogin; } - set { stipendSinceLogin = value; } - } - - public string Gendered - { - get { return gendered; } - set { gendered = value; } - } - - public string EverLoggedIn - { - get { return everLoggedIn; } - set { everLoggedIn = value; } - } - - public uint SimPort - { - get { return simPort; } - set { simPort = value; } - } - - public uint SimHttpPort - { - get { return simHttpPort; } - set { simHttpPort = value; } - } - - public string SimAddress - { - get { return simAddress; } - set { simAddress = value; } - } - - public UUID AgentID - { - get { return agentID; } - set { agentID = value; } - } - - public UUID SessionID - { - get { return sessionID; } - set { sessionID = value; } - } - - public UUID SecureSessionID - { - get { return secureSessionID; } - set { secureSessionID = value; } - } - - public Int32 CircuitCode - { - get { return circuitCode; } - set { circuitCode = value; } - } - - public uint RegionX - { - get { return regionX; } - set { regionX = value; } - } - - public uint RegionY - { - get { return regionY; } - set { regionY = value; } - } - - public string SunTexture - { - get { return sunTexture; } - set { sunTexture = value; } - } - - public string CloudTexture - { - get { return cloudTexture; } - set { cloudTexture = value; } - } - - public string MoonTexture - { - get { return moonTexture; } - set { moonTexture = value; } - } - - public string Firstname - { - get { return firstname; } - set { firstname = value; } - } - - public string Lastname - { - get { return lastname; } - set { lastname = value; } - } - - public string AgentAccess - { - get { return agentAccess; } - set { agentAccess = value; } - } - - public string AgentAccessMax - { - get { return agentAccessMax; } - set { agentAccessMax = value; } - } - - public string StartLocation - { - get { return startLocation; } - set { startLocation = value; } - } - - public string LookAt - { - get { return lookAt; } - set { lookAt = value; } - } - - public string SeedCapability - { - get { return seedCapability; } - set { seedCapability = value; } - } - - public string ErrorReason - { - get { return errorReason; } - set { errorReason = value; } - } - - public string ErrorMessage - { - get { return errorMessage; } - set { errorMessage = value; } - } - - public ArrayList InventoryRoot - { - get { return inventoryRoot; } - set { inventoryRoot = value; } - } - - public ArrayList InventorySkeleton - { - get { return agentInventory; } - set { agentInventory = value; } - } - - public ArrayList InventoryLibrary - { - get { return inventoryLibrary; } - set { inventoryLibrary = value; } - } - - public ArrayList InventoryLibraryOwner - { - get { return inventoryLibraryOwner; } - set { inventoryLibraryOwner = value; } - } - - public ArrayList InventoryLibRoot - { - get { return inventoryLibRoot; } - set { inventoryLibRoot = value; } - } - - public ArrayList ActiveGestures - { - get { return activeGestures; } - set { activeGestures = value; } - } - - public string Home - { - get { return home; } - set { home = value; } - } - - public string Message - { - get { return welcomeMessage; } - set { welcomeMessage = value; } - } - - public BuddyList BuddList - { - get { return m_buddyList; } - set { m_buddyList = value; } - } - - #endregion - - public class UserInfo - { - public string firstname; - public string lastname; - public ulong homeregionhandle; - public Vector3 homepos; - public Vector3 homelookat; - } - - public class BuddyList - { - public List Buddies = new List(); - - public void AddNewBuddy(BuddyInfo buddy) - { - if (!Buddies.Contains(buddy)) - { - Buddies.Add(buddy); - } - } - - public ArrayList ToArray() - { - ArrayList buddyArray = new ArrayList(); - foreach (BuddyInfo buddy in Buddies) - { - buddyArray.Add(buddy.ToHashTable()); - } - return buddyArray; - } - - public class BuddyInfo - { - public int BuddyRightsHave = 1; - public int BuddyRightsGiven = 1; - public UUID BuddyID; - - public BuddyInfo(string buddyID) - { - BuddyID = new UUID(buddyID); - } - - public BuddyInfo(UUID buddyID) - { - BuddyID = buddyID; - } - - public Hashtable ToHashTable() - { - Hashtable hTable = new Hashtable(); - hTable["buddy_rights_has"] = BuddyRightsHave; - hTable["buddy_rights_given"] = BuddyRightsGiven; - hTable["buddy_id"] = BuddyID.ToString(); - return hTable; - } - } - } - } -} diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs deleted file mode 100644 index 57ca704..0000000 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ /dev/null @@ -1,1243 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using System.Web; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Statistics; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications.Services -{ - public abstract class LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected string m_welcomeMessage = "Welcome to OpenSim"; - protected int m_minLoginLevel = 0; - protected UserManagerBase m_userManager = null; - protected Mutex m_loginMutex = new Mutex(false); - - /// - /// Used during login to send the skeleton of the OpenSim Library to the client. - /// - protected LibraryRootFolder m_libraryRootFolder; - - protected uint m_defaultHomeX; - protected uint m_defaultHomeY; - - protected bool m_warn_already_logged = true; - - /// - /// Used by the login service to make requests to the inventory service. - /// - protected IInterServiceInventoryServices m_interInventoryService; - // Hack - protected IInventoryService m_InventoryService; - - /// - /// Constructor - /// - /// - /// - /// - public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, - string welcomeMess) - { - m_userManager = userManager; - m_libraryRootFolder = libraryRootFolder; - - if (welcomeMess != String.Empty) - { - m_welcomeMessage = welcomeMess; - } - } - - /// - /// If the user is already logged in, try to notify the region that the user they've got is dead. - /// - /// - public virtual void LogOffUser(UserProfileData theUser, string message) - { - } - - /// - /// Called when we receive the client's initial XMLRPC login_to_simulator request message - /// - /// The XMLRPC request - /// The response to send - public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. - //CKF: m_log.Info("[LOGIN]: Attempting login now..."); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - SniffLoginKey((Uri)request.Params[2], requestData); - - bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && - (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); - - string startLocationRequest = "last"; - - UserProfileData userProfile; - LoginResponse logResponse = new LoginResponse(); - - string firstname; - string lastname; - - if (GoodXML) - { - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - } - - firstname = (string)requestData["first"]; - lastname = (string)requestData["last"]; - - m_log.InfoFormat( - "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", - firstname, lastname); - - string clientVersion = "Unknown"; - - if (requestData.Contains("version")) - { - clientVersion = (string)requestData["version"]; - } - - m_log.DebugFormat( - "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); - - if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) - { - return logResponse.CreateLoginFailedResponse(); - } - } - else - { - m_log.Info( - "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); - - return logResponse.CreateGridErrorResponse(); - } - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponse(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - //TODO: The following statements can cause trouble: - // If agentOnline could not turn from true back to false normally - // because of some problem, for instance, the crashment of server or client, - // the user cannot log in any longer. - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - - // try to tell the region that their user is dead. - LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); - - if (m_warn_already_logged) - { - // This is behavior for for grid, reject login - m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", - firstname, lastname); - - return logResponse.CreateAlreadyLoggedInResponse(); - } - else - { - // This is behavior for standalone (silent logout of last hung session) - m_log.InfoFormat( - "[LOGIN]: XMLRPC User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", - firstname, lastname); - } - } - - // Otherwise... - // Create a new agent session - - // XXYY we don't need this - //m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - // We need to commit the agent right here, even though the userProfile info is not complete - // at this point. There is another commit further down. - // This is for the new sessionID to be stored so that the region can check it for session authentication. - // CustomiseResponse->PrepareLoginToRegion - CommitAgent(ref userProfile); - - try - { - UUID agentID = userProfile.ID; - InventoryData inventData = null; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", - agentID, e); - - // Let's not panic - if (!AllowLoginWithoutInventory()) - return logResponse.CreateLoginInventoryFailedResponse(); - } - - if (inventData != null) - { - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - } - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - if (CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient)) - { - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); - - return logResponse.ToXmlRpcResponse(); - } - else - { - m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); - return logResponse.CreateDeadRegionResponse(); - } - } - catch (Exception e) - { - m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); - m_log.Error(e.StackTrace); - } - } - - m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); - return response; - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - protected virtual bool TryAuthenticateXmlRpcLogin( - XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) - { - Hashtable requestData = (Hashtable)request.Params[0]; - - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Debug("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); - return false; - } - else - { - if (requestData.Contains("passwd")) - { - string passwd = (string)requestData["passwd"]; - bool authenticated = AuthenticateUser(userProfile, passwd); - - if (!authenticated) - m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed password authentication", - firstname, lastname); - - return authenticated; - } - - if (requestData.Contains("web_login_key")) - { - try - { - UUID webloginkey = new UUID((string)requestData["web_login_key"]); - bool authenticated = AuthenticateUser(userProfile, webloginkey); - - if (!authenticated) - m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed web login key authentication", - firstname, lastname); - - return authenticated; - } - catch (Exception e) - { - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", - requestData["web_login_key"], firstname, lastname, e); - - return false; - } - } - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC login request for {0} {1} contained neither a password nor a web login key", - firstname, lastname); - } - - return false; - } - - protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) - { - bool GoodLogin = false; - userProfile = GetTheUser(firstname, lastname); - if (userProfile == null) - { - m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); - - return false; - } - - GoodLogin = AuthenticateUser(userProfile, passwd); - return GoodLogin; - } - - /// - /// Called when we receive the client's initial LLSD login_to_simulator request message - /// - /// The LLSD request - /// The response to send - public OSD LLSDLoginMethod(OSD request, IPEndPoint remoteClient) - { - // Temporary fix - m_loginMutex.WaitOne(); - - try - { - // bool GoodLogin = false; - - string startLocationRequest = "last"; - - UserProfileData userProfile = null; - LoginResponse logResponse = new LoginResponse(); - - if (request.Type == OSDType.Map) - { - OSDMap map = (OSDMap)request; - - if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) - { - string firstname = map["first"].AsString(); - string lastname = map["last"].AsString(); - string passwd = map["passwd"].AsString(); - - if (map.ContainsKey("start")) - { - m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); - startLocationRequest = map["start"].AsString(); - } - m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); - - if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) - { - return logResponse.CreateLoginFailedResponseLLSD(); - } - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - } - else - return logResponse.CreateLoginFailedResponseLLSD(); - - - if (userProfile.GodLevel < m_minLoginLevel) - { - return logResponse.CreateLoginBlockedResponseLLSD(); - } - else - { - // If we already have a session... - if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) - { - userProfile.CurrentAgent.AgentOnline = false; - - m_userManager.CommitAgent(ref userProfile); - // try to tell the region that their user is dead. - LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); - - if (m_warn_already_logged) - { - // This is behavior for for grid, reject login - m_log.InfoFormat( - "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", - userProfile.FirstName, userProfile.SurName); - - userProfile.CurrentAgent = null; - return logResponse.CreateAlreadyLoggedInResponseLLSD(); - } - else - { - // This is behavior for standalone (silent logout of last hung session) - m_log.InfoFormat( - "[LOGIN]: LLSD User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", - userProfile.FirstName, userProfile.SurName); - } - } - - // Otherwise... - // Create a new agent session - - // XXYY We don't need this - //m_userManager.ResetAttachments(userProfile.ID); - - CreateAgent(userProfile, request); - - // We need to commit the agent right here, even though the userProfile info is not complete - // at this point. There is another commit further down. - // This is for the new sessionID to be stored so that the region can check it for session authentication. - // CustomiseResponse->PrepareLoginToRegion - CommitAgent(ref userProfile); - - try - { - UUID agentID = userProfile.ID; - - //InventoryData inventData = GetInventorySkeleton(agentID); - InventoryData inventData = null; - - try - { - inventData = GetInventorySkeleton(agentID); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", - agentID, e.GetType(), e.Message); - - return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); - } - - - ArrayList AgentInventoryArray = inventData.InventoryArray; - - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); - ArrayList InventoryRoot = new ArrayList(); - InventoryRoot.Add(InventoryRootHash); - - - // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - ArrayList InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); - - logResponse.InventoryLibRoot = InventoryLibRoot; - logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.InventoryRoot = InventoryRoot; - logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = GetInventoryLibrary(); - - logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); - logResponse.Lastname = userProfile.SurName; - logResponse.Firstname = userProfile.FirstName; - logResponse.AgentID = agentID; - logResponse.SessionID = userProfile.CurrentAgent.SessionID; - logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; - logResponse.Message = GetMessage(); - logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); - logResponse.StartLocation = startLocationRequest; - - try - { - CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateDeadRegionResponseLLSD(); - } - - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", - userProfile.FirstName, userProfile.SurName); - - return logResponse.ToLLSDResponse(); - } - catch (Exception ex) - { - m_log.Info("[LOGIN]: LLSD " + ex.ToString()); - return logResponse.CreateFailedResponseLLSD(); - } - } - } - finally - { - m_loginMutex.ReleaseMutex(); - } - } - - public Hashtable ProcessHTMLLogin(Hashtable keysvals) - { - // Matches all unspecified characters - // Currently specified,; lowercase letters, upper case letters, numbers, underline - // period, space, parens, and dash. - - Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); - - Hashtable returnactions = new Hashtable(); - int statuscode = 200; - - string firstname = String.Empty; - string lastname = String.Empty; - string location = String.Empty; - string region = String.Empty; - string grid = String.Empty; - string channel = String.Empty; - string version = String.Empty; - string lang = String.Empty; - string password = String.Empty; - string errormessages = String.Empty; - - // the client requires the HTML form field be named 'username' - // however, the data it sends when it loads the first time is 'firstname' - // another one of those little nuances. - - if (keysvals.Contains("firstname")) - firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); - - if (keysvals.Contains("username")) - firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); - - if (keysvals.Contains("lastname")) - lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); - - if (keysvals.Contains("location")) - location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); - - if (keysvals.Contains("region")) - region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); - - if (keysvals.Contains("grid")) - grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); - - if (keysvals.Contains("channel")) - channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); - - if (keysvals.Contains("version")) - version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); - - if (keysvals.Contains("lang")) - lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); - - if (keysvals.Contains("password")) - password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); - - // load our login form. - string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - - if (keysvals.ContainsKey("show_login_form")) - { - UserProfileData user = GetTheUser(firstname, lastname); - bool goodweblogin = false; - - if (user != null) - goodweblogin = AuthenticateUser(user, password); - - if (goodweblogin) - { - UUID webloginkey = UUID.Random(); - m_userManager.StoreWebLoginKey(user.ID, webloginkey); - //statuscode = 301; - - // string redirectURL = "about:blank?redirect-http-hack=" + - // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + - // lastname + - // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); - //m_log.Info("[WEB]: R:" + redirectURL); - returnactions["int_response_code"] = statuscode; - //returnactions["str_redirect_location"] = redirectURL; - //returnactions["str_response_string"] = "GoodLogin"; - returnactions["str_response_string"] = webloginkey.ToString(); - } - else - { - errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; - - loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - } - else - { - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - } - return returnactions; - } - - public string GetLoginForm(string firstname, string lastname, string location, string region, - string grid, string channel, string version, string lang, - string password, string errormessages) - { - // inject our values in the form at the markers - - string loginform = String.Empty; - string file = Path.Combine(Util.configDir(), "http_loginform.html"); - if (!File.Exists(file)) - { - loginform = GetDefaultLoginForm(); - } - else - { - StreamReader sr = File.OpenText(file); - loginform = sr.ReadToEnd(); - sr.Close(); - } - - loginform = loginform.Replace("[$firstname]", firstname); - loginform = loginform.Replace("[$lastname]", lastname); - loginform = loginform.Replace("[$location]", location); - loginform = loginform.Replace("[$region]", region); - loginform = loginform.Replace("[$grid]", grid); - loginform = loginform.Replace("[$channel]", channel); - loginform = loginform.Replace("[$version]", version); - loginform = loginform.Replace("[$lang]", lang); - loginform = loginform.Replace("[$password]", password); - loginform = loginform.Replace("[$errors]", errormessages); - - return loginform; - } - - public string GetDefaultLoginForm() - { - string responseString = - ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "OpenSim Login"; - responseString += "
"; - responseString += "
"; - - responseString += "
"; - - responseString += "
[$errors]
"; - responseString += "
"; - responseString += "First Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Last Name:"; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += "Password:"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += "
Connecting...
"; - - responseString += "
"; - - responseString += "
[$channel] | [$version]=[$lang]
"; - responseString += "
"; - responseString += ""; - responseString += "
"; - responseString += ""; - responseString += ""; - responseString += ""; - - return responseString; - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - return m_userManager.CommitAgent(ref profile); - } - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public virtual bool AuthenticateUser(UserProfileData profile, string password) - { - bool passwordSuccess = false; - //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Web Login method seems to also occasionally send the hashed password itself - - // we do this to get our hash in a form that the server password code can consume - // when the web-login-form submits the password in the clear (supposed to be over SSL!) - if (!password.StartsWith("$1$")) - password = "$1$" + Util.Md5Hash(password); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); - // Testing... - //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); - //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - - passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); - - return passwordSuccess; - } - - public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) - { - bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); - - // Match web login key unless it's the default weblogin key UUID.Zero - passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); - - return passwordSuccess; - } - - /// - /// - /// - /// - /// - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - m_userManager.CreateAgent(profile, request); - } - - public void CreateAgent(UserProfileData profile, OSD request) - { - m_userManager.CreateAgent(profile, request); - } - - /// - /// - /// - /// - /// - /// - public virtual UserProfileData GetTheUser(string firstname, string lastname) - { - return m_userManager.GetUserProfile(firstname, lastname); - } - - /// - /// - /// - /// - public virtual string GetMessage() - { - return m_welcomeMessage; - } - - private static LoginResponse.BuddyList ConvertFriendListItem(List LFL) - { - LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); - foreach (FriendListItem fl in LFL) - { - LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); - buddyitem.BuddyID = fl.Friend; - buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; - buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; - buddylistreturn.AddNewBuddy(buddyitem); - } - return buddylistreturn; - } - - /// - /// Converts the inventory library skeleton into the form required by the rpc request. - /// - /// - protected virtual ArrayList GetInventoryLibrary() - { - Dictionary rootFolders - = m_libraryRootFolder.RequestSelfAndDescendentFolders(); - ArrayList folderHashes = new ArrayList(); - - foreach (InventoryFolderBase folder in rootFolders.Values) - { - Hashtable TempHash = new Hashtable(); - TempHash["name"] = folder.Name; - TempHash["parent_id"] = folder.ParentID.ToString(); - TempHash["version"] = (Int32)folder.Version; - TempHash["type_default"] = (Int32)folder.Type; - TempHash["folder_id"] = folder.ID.ToString(); - folderHashes.Add(TempHash); - } - - return folderHashes; - } - - /// - /// - /// - /// - protected virtual ArrayList GetLibraryOwner() - { - //for now create random inventory library owner - Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; - ArrayList inventoryLibOwner = new ArrayList(); - inventoryLibOwner.Add(TempHash); - return inventoryLibOwner; - } - - public class InventoryData - { - public ArrayList InventoryArray = null; - public UUID RootFolderID = UUID.Zero; - - public InventoryData(ArrayList invList, UUID rootID) - { - InventoryArray = invList; - RootFolderID = rootID; - } - } - - protected void SniffLoginKey(Uri uri, Hashtable requestData) - { - string uri_str = uri.ToString(); - string[] parts = uri_str.Split(new char[] { '=' }); - if (parts.Length > 1) - { - string web_login_key = parts[1]; - requestData.Add("web_login_key", web_login_key); - m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); - } - } - - /// - /// Customises the login response and fills in missing values. This method also tells the login region to - /// expect a client connection. - /// - /// The existing response - /// The user profile - /// The requested start location - /// true on success, false if the region was not successfully told to expect a user connection - public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest, IPEndPoint client) - { - // add active gestures to login-response - AddActiveGestures(response, theUser); - - // HomeLocation - RegionInfo homeInfo = null; - - // use the homeRegionID if it is stored already. If not, use the regionHandle as before - UUID homeRegionId = theUser.HomeRegionID; - ulong homeRegionHandle = theUser.HomeRegion; - if (homeRegionId != UUID.Zero) - { - homeInfo = GetRegionInfo(homeRegionId); - } - else - { - homeInfo = GetRegionInfo(homeRegionHandle); - } - - if (homeInfo != null) - { - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - (homeInfo.RegionLocX * Constants.RegionSize), - (homeInfo.RegionLocY * Constants.RegionSize), - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - } - else - { - m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); - // Emergency mode: Home-region isn't available, so we can't request the region info. - // Use the stored home regionHandle instead. - // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again - ulong regionX = homeRegionHandle >> 32; - ulong regionY = homeRegionHandle & 0xffffffff; - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - regionX, regionY, - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); - - m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", - theUser.FirstName, theUser.SurName, - regionX, regionY); - } - - // StartLocation - RegionInfo regionInfo = null; - if (startLocationRequest == "home") - { - regionInfo = homeInfo; - theUser.CurrentAgent.Position = theUser.HomeLocation; - response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(), - theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString()); - } - else if (startLocationRequest == "last") - { - UUID lastRegion = theUser.CurrentAgent.Region; - regionInfo = GetRegionInfo(lastRegion); - response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(), - theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString()); - } - else - { - Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); - Match uriMatch = reURI.Match(startLocationRequest); - if (uriMatch == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); - } - else - { - string region = uriMatch.Groups["region"].ToString(); - regionInfo = RequestClosestRegion(region); - if (regionInfo == null) - { - m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); - } - else - { - theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), - float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); - } - } - response.LookAt = "[r0,r1,r0]"; - // can be: last, home, safe, url - response.StartLocation = "url"; - } - - if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response, client))) - { - return true; - } - - // Get the default region handle - ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize); - - // If we haven't already tried the default region, reset regionInfo - if (regionInfo != null && defaultHandle != regionInfo.RegionHandle) - regionInfo = null; - - if (regionInfo == null) - { - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - } - - if (regionInfo == null) - { - m_log.ErrorFormat("[LOGIN]: Sending user to any region"); - regionInfo = RequestClosestRegion(String.Empty); - } - - theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f); - response.StartLocation = "safe"; - - return PrepareLoginToRegion(regionInfo, theUser, response, client); - } - - protected abstract RegionInfo RequestClosestRegion(string region); - protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); - protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); - - /// - /// Prepare a login to the given region. This involves both telling the region to expect a connection - /// and appropriately customising the response to the user. - /// - /// - /// - /// - /// - /// true if the region was successfully contacted, false otherwise - protected abstract bool PrepareLoginToRegion( - RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); - - /// - /// Add active gestures of the user to the login response. - /// - /// - /// A - /// - /// - /// A - /// - protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) - { - List gestures = null; - try - { - if (m_InventoryService != null) - gestures = m_InventoryService.GetActiveGestures(theUser.ID); - else - gestures = m_interInventoryService.GetActiveGestures(theUser.ID); - } - catch (Exception e) - { - m_log.Debug("[LOGIN]: Unable to retrieve active gestures from inventory server. Reason: " + e.Message); - } - //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); - ArrayList list = new ArrayList(); - if (gestures != null) - { - foreach (InventoryItemBase gesture in gestures) - { - Hashtable item = new Hashtable(); - item["item_id"] = gesture.ID.ToString(); - item["asset_id"] = gesture.AssetID.ToString(); - list.Add(item); - } - } - response.ActiveGestures = list; - } - - /// - /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. - /// - /// - /// - /// This will be thrown if there is a problem with the inventory service - protected InventoryData GetInventorySkeleton(UUID userID) - { - List folders = null; - if (m_InventoryService != null) - { - folders = m_InventoryService.GetInventorySkeleton(userID); - } - else - { - folders = m_interInventoryService.GetInventorySkeleton(userID); - } - - // If we have user auth but no inventory folders for some reason, create a new set of folders. - if (folders == null || folders.Count == 0) - { - m_log.InfoFormat( - "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); - - // Although the create user function creates a new agent inventory along with a new user profile, some - // tools are creating the user profile directly in the database without creating the inventory. At - // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already - // exist. - if (m_interInventoryService != null) - { - if (!m_interInventoryService.CreateNewUserInventory(userID)) - { - throw new Exception( - String.Format( - "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", - userID)); - } - } - else if ((m_InventoryService != null) && !m_InventoryService.CreateUserInventory(userID)) - { - throw new Exception( - String.Format( - "The inventory creation request for user {0} did not succeed." - + " Please contact your inventory service provider for more information.", - userID)); - } - - - m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); - - if (m_InventoryService != null) - folders = m_InventoryService.GetInventorySkeleton(userID); - else - folders = m_interInventoryService.GetInventorySkeleton(userID); - - if (folders == null || folders.Count == 0) - { - throw new Exception( - String.Format( - "A root inventory folder for user {0} could not be retrieved from the inventory service", - userID)); - } - } - - UUID rootID = UUID.Zero; - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolderBase InvFolder in folders) - { - if (InvFolder.ParentID == UUID.Zero) - { - rootID = InvFolder.ID; - } - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.Name; - TempHash["parent_id"] = InvFolder.ParentID.ToString(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.Type; - TempHash["folder_id"] = InvFolder.ID.ToString(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, rootID); - } - - protected virtual bool AllowLoginWithoutInventory() - { - return false; - } - - public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - string authed = "FALSE"; - if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) - { - UUID guess_aid; - UUID guess_sid; - - UUID.TryParse((string)requestData["avatar_uuid"], out guess_aid); - if (guess_aid == UUID.Zero) - { - return Util.CreateUnknownUserErrorResponse(); - } - - UUID.TryParse((string)requestData["session_id"], out guess_sid); - if (guess_sid == UUID.Zero) - { - return Util.CreateUnknownUserErrorResponse(); - } - - if (m_userManager.VerifySession(guess_aid, guess_sid)) - { - authed = "TRUE"; - m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); - } - else - { - m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); - return Util.CreateUnknownUserErrorResponse(); - } - } - - Hashtable responseData = new Hashtable(); - responseData["auth_session"] = authed; - response.Value = responseData; - return response; - } - } -} \ No newline at end of file -- cgit v1.1 From cddd48aeeaee98d14fd4ae887cdf32abc6110c40 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 21:00:03 -0800 Subject: Some more unnecessary things deleted in Framework.Communications. --- .../Framework/Communications/IAuthentication.cs | 39 - OpenSim/Framework/Communications/IAvatarService.cs | 48 -- .../IInterServiceInventoryServices.cs | 64 -- .../Framework/Communications/IMessagingService.cs | 37 - .../Framework/Communications/IUserAdminService.cs | 71 -- .../Framework/Communications/UserManagerBase.cs | 910 --------------------- 6 files changed, 1169 deletions(-) delete mode 100644 OpenSim/Framework/Communications/IAuthentication.cs delete mode 100644 OpenSim/Framework/Communications/IAvatarService.cs delete mode 100644 OpenSim/Framework/Communications/IInterServiceInventoryServices.cs delete mode 100644 OpenSim/Framework/Communications/IMessagingService.cs delete mode 100644 OpenSim/Framework/Communications/IUserAdminService.cs delete mode 100644 OpenSim/Framework/Communications/UserManagerBase.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs deleted file mode 100644 index bd568e4..0000000 --- a/OpenSim/Framework/Communications/IAuthentication.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IAuthentication - { - string GetNewKey(string url, UUID userID, UUID authToken); - bool VerifyKey(UUID userID, string key); - bool VerifySession(UUID iserID, UUID sessionID); - } -} diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs deleted file mode 100644 index 760aa62..0000000 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IAvatarService - { - /// - /// Get avatar appearance information - /// - /// - /// - AvatarAppearance GetUserAppearance(UUID user); - - /// - /// Update avatar appearance information - /// - /// - /// - void UpdateUserAppearance(UUID user, AvatarAppearance appearance); - } -} diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs deleted file mode 100644 index 7f17872..0000000 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - /// - /// Inventory operations used between grid services. - /// - public interface IInterServiceInventoryServices - { - /// - /// Create a new inventory for the given user. - /// - /// - /// true if the inventory was successfully created, false otherwise - bool CreateNewUserInventory(UUID user); - - /// - /// Returns a list of all the folders in a given user's inventory. - /// - /// - /// A flat list of the user's inventory folder tree, - /// null if there is no inventory for this user - List GetInventorySkeleton(UUID userId); - - /// - /// Returns a list of all the active gestures in a user's inventory. - /// - /// - /// The of the user - /// - /// - /// A flat list of the gesture items. - /// - List GetActiveGestures(UUID userId); - } -} diff --git a/OpenSim/Framework/Communications/IMessagingService.cs b/OpenSim/Framework/Communications/IMessagingService.cs deleted file mode 100644 index 5d65f19..0000000 --- a/OpenSim/Framework/Communications/IMessagingService.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - public interface IMessagingService - { - Dictionary GetFriendRegionInfos (List uuids); - } -} diff --git a/OpenSim/Framework/Communications/IUserAdminService.cs b/OpenSim/Framework/Communications/IUserAdminService.cs deleted file mode 100644 index 423b49b..0000000 --- a/OpenSim/Framework/Communications/IUserAdminService.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; - -namespace OpenSim.Framework.Communications -{ - /// - /// Interface for the service for administrating users - /// - public interface IUserAdminService - { - /// - /// Add a new user - /// - /// The first name - /// The last name - /// password of avatar - /// email of user - /// region X - /// region Y - /// The UUID of the created user profile. On failure, returns UUID.Zero - UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY); - - /// - /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules! - /// - /// The first name - /// The last name - /// password of avatar - /// email of user - /// region X - /// region Y - /// The set UUID - /// The UUID of the created user profile. On failure, returns UUID.Zero - UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); - - /// - /// Reset a user password - /// - /// - /// - /// - /// true if the update was successful, false otherwise - bool ResetUserPassword(string firstName, string lastName, string newPassword); - } -} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs deleted file mode 100644 index caa9c1c..0000000 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ /dev/null @@ -1,910 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Net; -using System.Reflection; -using System.Security.Cryptography; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Data; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Statistics; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications -{ - /// - /// Base class for user management (create, read, etc) - /// - public abstract class UserManagerBase - : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication - { - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// List of plugins to search for user data - /// - private List m_plugins = new List(); - - protected CommunicationsManager m_commsManager; - protected IInventoryService m_InventoryService; - - /// - /// Constructor - /// - /// - public UserManagerBase(CommunicationsManager commsManager) - { - m_commsManager = commsManager; - } - - public virtual void SetInventoryService(IInventoryService invService) - { - m_InventoryService = invService; - } - - /// - /// Add a new user data plugin - plugins will be requested in the order they were added. - /// - /// The plugin that will provide user data - public void AddPlugin(IUserDataPlugin plugin) - { - m_plugins.Add(plugin); - } - - /// - /// Adds a list of user data plugins, as described by `provider' and - /// `connect', to `_plugins'. - /// - /// - /// The filename of the inventory server plugin DLL. - /// - /// - /// The connection string for the storage backend. - /// - public void AddPlugin(string provider, string connect) - { - m_plugins.AddRange(DataPluginFactory.LoadDataPlugins(provider, connect)); - } - - #region UserProfile - - public virtual void AddTemporaryUserProfile(UserProfileData userProfile) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - plugin.AddTemporaryUserProfile(userProfile); - } - } - - public virtual UserProfileData GetUserProfile(string fname, string lname) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - UserProfileData profile = plugin.GetUserByName(fname, lname); - - if (profile != null) - { - profile.CurrentAgent = GetUserAgent(profile.ID); - return profile; - } - } - - return null; - } - - public void LogoutUsers(UUID regionID) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - plugin.LogoutUsers(regionID); - } - } - - public void ResetAttachments(UUID userID) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - plugin.ResetAttachments(userID); - } - } - - public UserProfileData GetUserProfile(Uri uri) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - UserProfileData profile = plugin.GetUserByUri(uri); - - if (null != profile) - return profile; - } - - return null; - } - - public virtual UserAgentData GetAgentByUUID(UUID userId) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - UserAgentData agent = plugin.GetAgentByUUID(userId); - - if (agent != null) - { - return agent; - } - } - - return null; - } - - public Uri GetUserUri(UserProfileData userProfile) - { - throw new NotImplementedException(); - } - - // see IUserService - public virtual UserProfileData GetUserProfile(UUID uuid) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - UserProfileData profile = plugin.GetUserByUUID(uuid); - - if (null != profile) - { - profile.CurrentAgent = GetUserAgent(profile.ID); - return profile; - } - } - - return null; - } - - public virtual List GenerateAgentPickerRequestResponse(UUID queryID, string query) - { - List allPickerList = new List(); - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - List pickerList = plugin.GeneratePickerResults(queryID, query); - if (pickerList != null) - allPickerList.AddRange(pickerList); - } - catch (Exception) - { - m_log.Error( - "[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); - } - } - - return allPickerList; - } - - public virtual bool UpdateUserProfile(UserProfileData data) - { - bool result = false; - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.UpdateUserProfile(data); - result = true; - } - catch (Exception e) - { - m_log.ErrorFormat( - "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", - data.FirstName, data.SurName, plugin.Name, e.ToString()); - } - } - - return result; - } - - #endregion - - #region Get UserAgent - - /// - /// Loads a user agent by uuid (not called directly) - /// - /// The agent's UUID - /// Agent profiles - public UserAgentData GetUserAgent(UUID uuid) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - UserAgentData result = plugin.GetAgentByUUID(uuid); - - if (result != null) - return result; - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user agent by name (not called directly) - /// - /// The agent's name - /// A user agent - public UserAgentData GetUserAgent(string name) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - UserAgentData result = plugin.GetAgentByName(name); - - if (result != null) - return result; - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return null; - } - - /// - /// Loads a user agent by name (not called directly) - /// - /// The agent's firstname - /// The agent's lastname - /// A user agent - public UserAgentData GetUserAgent(string fname, string lname) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - UserAgentData result = plugin.GetAgentByName(fname, lname); - - if (result != null) - return result; - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return null; - } - - public virtual List GetUserFriendList(UUID ownerID) - { - List allFriends = new List(); - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - List friends = plugin.GetUserFriendList(ownerID); - - if (friends != null) - allFriends.AddRange(friends); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return allFriends; - } - - public virtual Dictionary GetFriendRegionInfos (List uuids) - { - //Dictionary allFriendRegions = new Dictionary(); - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - Dictionary friendRegions = plugin.GetFriendRegionInfos(uuids); - - if (friendRegions != null) - return friendRegions; - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return new Dictionary(); - } - - public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.StoreWebLoginKey(agentID, webLoginKey); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - } - - public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.AddNewUserFriend(friendlistowner, friend, perms); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - } - - public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.RemoveUserFriend(friendlistowner, friend); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - } - - public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.UpdateUserFriendPerms(friendlistowner, friend, perms); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - } - - /// - /// Resets the currentAgent in the user profile - /// - /// The agent's ID - public virtual void ClearUserAgent(UUID agentID) - { - UserProfileData profile = GetUserProfile(agentID); - - if (profile == null) - { - return; - } - - profile.CurrentAgent = null; - - UpdateUserProfile(profile); - } - - #endregion - - #region CreateAgent - - /// - /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB - /// - /// The users profile - /// The users loginrequest - public void CreateAgent(UserProfileData profile, XmlRpcRequest request) - { - //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); - - UserAgentData agent = new UserAgentData(); - - // User connection - agent.AgentOnline = true; - - if (request.Params.Count > 1) - { - if (request.Params[1] != null) - { - IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; - agent.AgentIP = RemoteIPEndPoint.Address.ToString(); - agent.AgentPort = (uint)RemoteIPEndPoint.Port; - } - } - - // Generate sessions - RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); - byte[] randDataS = new byte[16]; - byte[] randDataSS = new byte[16]; - rand.GetBytes(randDataS); - rand.GetBytes(randDataSS); - - agent.SecureSessionID = new UUID(randDataSS, 0); - agent.SessionID = new UUID(randDataS, 0); - - // Profile UUID - agent.ProfileID = profile.ID; - - // Current location/position/alignment - if (profile.CurrentAgent != null) - { - agent.Region = profile.CurrentAgent.Region; - agent.Handle = profile.CurrentAgent.Handle; - agent.Position = profile.CurrentAgent.Position; - agent.LookAt = profile.CurrentAgent.LookAt; - } - else - { - agent.Region = profile.HomeRegionID; - agent.Handle = profile.HomeRegion; - agent.Position = profile.HomeLocation; - agent.LookAt = profile.HomeLookAt; - } - - // What time did the user login? - agent.LoginTime = Util.UnixTimeSinceEpoch(); - agent.LogoutTime = 0; - - profile.CurrentAgent = agent; - } - - public void CreateAgent(UserProfileData profile, OSD request) - { - //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); - - UserAgentData agent = new UserAgentData(); - - // User connection - agent.AgentOnline = true; - - //if (request.Params.Count > 1) - //{ - // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; - // agent.AgentIP = RemoteIPEndPoint.Address.ToString(); - // agent.AgentPort = (uint)RemoteIPEndPoint.Port; - //} - - // Generate sessions - RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); - byte[] randDataS = new byte[16]; - byte[] randDataSS = new byte[16]; - rand.GetBytes(randDataS); - rand.GetBytes(randDataSS); - - agent.SecureSessionID = new UUID(randDataSS, 0); - agent.SessionID = new UUID(randDataS, 0); - - // Profile UUID - agent.ProfileID = profile.ID; - - // Current location/position/alignment - if (profile.CurrentAgent != null) - { - agent.Region = profile.CurrentAgent.Region; - agent.Handle = profile.CurrentAgent.Handle; - agent.Position = profile.CurrentAgent.Position; - agent.LookAt = profile.CurrentAgent.LookAt; - } - else - { - agent.Region = profile.HomeRegionID; - agent.Handle = profile.HomeRegion; - agent.Position = profile.HomeLocation; - agent.LookAt = profile.HomeLookAt; - } - - // What time did the user login? - agent.LoginTime = Util.UnixTimeSinceEpoch(); - agent.LogoutTime = 0; - - profile.CurrentAgent = agent; - } - - /// - /// Saves a target agent to the database - /// - /// The users profile - /// Successful? - public bool CommitAgent(ref UserProfileData profile) - { - //m_log.DebugFormat("[USER MANAGER]: Committing agent {0} {1}", profile.Name, profile.ID); - - // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" - // TODO: what is the logic should be? - bool ret = false; - ret = AddUserAgent(profile.CurrentAgent); - ret = ret & UpdateUserProfile(profile); - return ret; - } - - /// - /// Process a user logoff from OpenSim. - /// - /// - /// - /// - /// - /// - public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) - { - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddLogout(); - - UserProfileData userProfile = GetUserProfile(userid); - - if (userProfile != null) - { - UserAgentData userAgent = userProfile.CurrentAgent; - if (userAgent != null) - { - userAgent.AgentOnline = false; - userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); - //userAgent.sessionID = UUID.Zero; - if (regionid != UUID.Zero) - { - userAgent.Region = regionid; - } - userAgent.Handle = regionhandle; - userAgent.Position = position; - userAgent.LookAt = lookat; - //userProfile.CurrentAgent = userAgent; - userProfile.LastLogin = userAgent.LogoutTime; - - CommitAgent(ref userProfile); - } - else - { - // If currentagent is null, we can't reference it here or the UserServer crashes! - m_log.Info("[LOGOUT]: didn't save logout position: " + userid.ToString()); - } - } - else - { - m_log.Warn("[LOGOUT]: Unknown User logged out"); - } - } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) - { - LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); - } - - #endregion - - /// - /// Add a new user - /// - /// first name - /// last name - /// password - /// email - /// location X - /// location Y - /// The UUID of the created user profile. On failure, returns UUID.Zero - public virtual UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) - { - return AddUser(firstName, lastName, password, email, regX, regY, UUID.Random()); - } - - /// - /// Add a new user - /// - /// first name - /// last name - /// password - /// email - /// location X - /// location Y - /// UUID of avatar. - /// The UUID of the created user profile. On failure, returns UUID.Zero - public virtual UUID AddUser( - string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) - { - - UserProfileData user = new UserProfileData(); - - user.PasswordSalt = Util.Md5Hash(UUID.Random().ToString()); - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + user.PasswordSalt); - - user.HomeLocation = new Vector3(128, 128, 100); - user.ID = SetUUID; - user.FirstName = firstName; - user.SurName = lastName; - user.PasswordHash = md5PasswdHash; - user.Created = Util.UnixTimeSinceEpoch(); - user.HomeLookAt = new Vector3(100, 100, 100); - user.HomeRegionX = regX; - user.HomeRegionY = regY; - user.Email = email; - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.AddNewUserProfile(user); - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - UserProfileData userProf = GetUserProfile(firstName, lastName); - if (userProf == null) - { - return UUID.Zero; - } - else - { - return userProf.ID; - } - } - - /// - /// Reset a user password. - /// - /// - /// - /// - /// true if the update was successful, false otherwise - public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) - { - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); - - UserProfileData profile = GetUserProfile(firstName, lastName); - - if (null == profile) - { - m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName); - return false; - } - - profile.PasswordHash = md5PasswdHash; - profile.PasswordSalt = String.Empty; - - UpdateUserProfile(profile); - - return true; - } - - public abstract UserProfileData SetupMasterUser(string firstName, string lastName); - public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); - public abstract UserProfileData SetupMasterUser(UUID uuid); - - /// - /// Add an agent using data plugins. - /// - /// The agent data to be added - /// - /// true if at least one plugin added the user agent. false if no plugin successfully added the agent - /// - public virtual bool AddUserAgent(UserAgentData agentdata) - { - bool result = false; - - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.AddNewUserAgent(agentdata); - result = true; - } - catch (Exception e) - { - m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); - } - } - - return result; - } - - /// - /// Get avatar appearance information - /// - /// - /// - public virtual AvatarAppearance GetUserAppearance(UUID user) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - AvatarAppearance appearance = plugin.GetUserAppearance(user); - - if (appearance != null) - return appearance; - } - catch (Exception e) - { - m_log.ErrorFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); - } - } - - return null; - } - - public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) - { - foreach (IUserDataPlugin plugin in m_plugins) - { - try - { - plugin.UpdateUserAppearance(user, appearance); - } - catch (Exception e) - { - m_log.ErrorFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); - } - } - } - - #region IAuthentication - - protected Dictionary> m_userKeys = new Dictionary>(); - - /// - /// This generates authorization keys in the form - /// http://userserver/uuid - /// after verifying that the caller is, indeed, authorized to request a key - /// - /// URL of the user server - /// The user ID requesting the new key - /// The original authorization token for that user, obtained during login - /// - public string GetNewKey(string url, UUID userID, UUID authToken) - { - UserProfileData profile = GetUserProfile(userID); - string newKey = string.Empty; - if (!url.EndsWith("/")) - url = url + "/"; - - if (profile != null) - { - // I'm overloading webloginkey for this, so that no changes are needed in the DB - // The uses of webloginkey are fairly mutually exclusive - if (profile.WebLoginKey.Equals(authToken)) - { - newKey = UUID.Random().ToString(); - List keys; - lock (m_userKeys) - { - if (m_userKeys.ContainsKey(userID)) - { - keys = m_userKeys[userID]; - } - else - { - keys = new List(); - m_userKeys.Add(userID, keys); - } - keys.Add(newKey); - } - m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID); - } - else - m_log.Warn("[USERAUTH]: Unauthorized key generation request. Denying new key."); - } - else - m_log.Warn("[USERAUTH]: User not found."); - - return url + newKey; - } - - /// - /// This verifies the uuid portion of the key given out by GenerateKey - /// - /// - /// - /// - public bool VerifyKey(UUID userID, string key) - { - lock (m_userKeys) - { - if (m_userKeys.ContainsKey(userID)) - { - List keys = m_userKeys[userID]; - if (keys.Contains(key)) - { - // Keys are one-time only, so remove it - keys.Remove(key); - return true; - } - return false; - } - else - return false; - } - } - - public virtual bool VerifySession(UUID userID, UUID sessionID) - { - UserProfileData userProfile = GetUserProfile(userID); - - if (userProfile != null && userProfile.CurrentAgent != null) - { - m_log.DebugFormat( - "[USER AUTH]: Verifying session {0} for {1}; current session {2}", - sessionID, userID, userProfile.CurrentAgent.SessionID); - - if (userProfile.CurrentAgent.SessionID == sessionID) - { - return true; - } - } - - return false; - } - - public virtual bool AuthenticateUserByPassword(UUID userID, string password) - { -// m_log.DebugFormat("[USER AUTH]: Authenticating user {0} given password {1}", userID, password); - - UserProfileData userProfile = GetUserProfile(userID); - - if (null == userProfile) - return false; - - string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt); - -// m_log.DebugFormat( -// "[USER AUTH]: Submitted hash {0}, stored hash {1}", md5PasswordHash, userProfile.PasswordHash); - - if (md5PasswordHash == userProfile.PasswordHash) - return true; - else - return false; - } - - #endregion - } -} -- cgit v1.1 From 751e70af788bf27fa0401c25d899f73186c8eafa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 21:37:36 -0800 Subject: NetworkServersInfo removed from CommsManager. --- OpenSim/Framework/Communications/CommunicationsManager.cs | 7 ------- 1 file changed, 7 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bc04009..7c4ae9a 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -44,12 +44,6 @@ namespace OpenSim.Framework.Communications public class CommunicationsManager { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public NetworkServersInfo NetworkServersInfo - { - get { return m_networkServersInfo; } - } - protected NetworkServersInfo m_networkServersInfo; /// /// Constructor @@ -58,7 +52,6 @@ namespace OpenSim.Framework.Communications public CommunicationsManager(NetworkServersInfo serversInfo, LibraryRootFolder libraryRootFolder) { - m_networkServersInfo = serversInfo; } } -- cgit v1.1 From 001d3695683d9511446d194feeb763c437170028 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 07:45:47 -0800 Subject: CommunicationsManager deleted. --- .../Communications/CommunicationsManager.cs | 58 ---------------------- 1 file changed, 58 deletions(-) delete mode 100644 OpenSim/Framework/Communications/CommunicationsManager.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs deleted file mode 100644 index 7c4ae9a..0000000 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 OpenMetaverse; -using OpenSim.Framework.Communications.Cache; - -namespace OpenSim.Framework.Communications -{ - /// - /// This class manages references to OpenSim non-region services (inventory, user, etc.) - /// - /// - /// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region - /// modules from scene. Among other things, this will allow this class to be used in many different contexts - /// (from a grid service executable, to provide services on a region) without lots of messy nulls and confusion. - /// Also, a post initialize step on the plugins will be needed so that we don't get tortuous problems with - /// circular dependencies between plugins. - public class CommunicationsManager - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Constructor - /// - /// - public CommunicationsManager(NetworkServersInfo serversInfo, - LibraryRootFolder libraryRootFolder) - { - } - - } -} -- cgit v1.1 From c5ea783526611a968400a1936e4c6764ee1c7013 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 07:51:33 -0800 Subject: OpenSim/Framework/Communications/Cache deleted. LibraryRootFolder deleted. --- .../Communications/Cache/LibraryRootFolder.cs | 257 --------------------- .../Framework/Communications/Osp/OspResolver.cs | 1 - 2 files changed, 258 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs deleted file mode 100644 index 74ba0a5..0000000 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Reflection; -using System.Xml; -using log4net; -using Nini.Config; -using OpenMetaverse; - -namespace OpenSim.Framework.Communications.Cache -{ - /// - /// Basically a hack to give us a Inventory library while we don't have a inventory server - /// once the server is fully implemented then should read the data from that - /// - public class LibraryRootFolder : InventoryFolderImpl - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); - - /// - /// Holds the root library folder and all its descendents. This is really only used during inventory - /// setup so that we don't have to repeatedly search the tree of library folders. - /// - protected Dictionary libraryFolders - = new Dictionary(); - - public LibraryRootFolder(string pLibrariesLocation) - { - Owner = libOwner; - ID = new UUID("00000112-000f-0000-0000-000100bba000"); - Name = "OpenSim Library"; - ParentID = UUID.Zero; - Type = (short) 8; - Version = (ushort) 1; - - libraryFolders.Add(ID, this); - - LoadLibraries(pLibrariesLocation); - } - - public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, - int assetType, int invType, UUID parentFolderID) - { - InventoryItemBase item = new InventoryItemBase(); - item.Owner = libOwner; - item.CreatorId = libOwner.ToString(); - item.ID = inventoryID; - item.AssetID = assetID; - item.Description = description; - item.Name = name; - item.AssetType = assetType; - item.InvType = invType; - item.Folder = parentFolderID; - item.BasePermissions = 0x7FFFFFFF; - item.EveryOnePermissions = 0x7FFFFFFF; - item.CurrentPermissions = 0x7FFFFFFF; - item.NextPermissions = 0x7FFFFFFF; - return item; - } - - /// - /// Use the asset set information at path to load assets - /// - /// - /// - protected void LoadLibraries(string librariesControlPath) - { - m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath); - LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); - } - - /// - /// Read a library set from config - /// - /// - protected void ReadLibraryFromConfig(IConfig config, string path) - { - string basePath = Path.GetDirectoryName(path); - string foldersPath - = Path.Combine( - basePath, config.GetString("foldersFile", String.Empty)); - - LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); - - string itemsPath - = Path.Combine( - basePath, config.GetString("itemsFile", String.Empty)); - - LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); - } - - /// - /// Read a library inventory folder from a loaded configuration - /// - /// - private void ReadFolderFromConfig(IConfig config, string path) - { - InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - - folderInfo.ID = new UUID(config.GetString("folderID", ID.ToString())); - folderInfo.Name = config.GetString("name", "unknown"); - folderInfo.ParentID = new UUID(config.GetString("parentFolderID", ID.ToString())); - folderInfo.Type = (short)config.GetInt("type", 8); - - folderInfo.Owner = libOwner; - folderInfo.Version = 1; - - if (libraryFolders.ContainsKey(folderInfo.ParentID)) - { - InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; - - libraryFolders.Add(folderInfo.ID, folderInfo); - parentFolder.AddChildFolder(folderInfo); - -// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); - } - else - { - m_log.WarnFormat( - "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", - folderInfo.Name, folderInfo.ID, folderInfo.ParentID); - } - } - - /// - /// Read a library inventory item metadata from a loaded configuration - /// - /// - private void ReadItemFromConfig(IConfig config, string path) - { - InventoryItemBase item = new InventoryItemBase(); - item.Owner = libOwner; - item.CreatorId = libOwner.ToString(); - item.ID = new UUID(config.GetString("inventoryID", ID.ToString())); - item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); - item.Folder = new UUID(config.GetString("folderID", ID.ToString())); - item.Name = config.GetString("name", String.Empty); - item.Description = config.GetString("description", item.Name); - item.InvType = config.GetInt("inventoryType", 0); - item.AssetType = config.GetInt("assetType", item.InvType); - item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); - item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); - item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); - item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); - item.Flags = (uint)config.GetInt("flags", 0); - - if (libraryFolders.ContainsKey(item.Folder)) - { - InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; - try - { - parentFolder.Items.Add(item.ID, item); - } - catch (Exception) - { - m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); - } - } - else - { - m_log.WarnFormat( - "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", - item.Name, item.ID, item.Folder); - } - } - - private delegate void ConfigAction(IConfig config, string path); - - /// - /// Load the given configuration at a path and perform an action on each Config contained within it - /// - /// - /// - /// - private static void LoadFromFile(string path, string fileDescription, ConfigAction action) - { - if (File.Exists(path)) - { - try - { - XmlConfigSource source = new XmlConfigSource(path); - - for (int i = 0; i < source.Configs.Count; i++) - { - action(source.Configs[i], path); - } - } - catch (XmlException e) - { - m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e); - } - } - else - { - m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path); - } - } - - /// - /// Looks like a simple getter, but is written like this for some consistency with the other Request - /// methods in the superclass - /// - /// - public Dictionary RequestSelfAndDescendentFolders() - { - Dictionary fs = new Dictionary(); - fs.Add(ID, this); - List fis = TraverseFolder(this); - foreach (InventoryFolderImpl f in fis) - { - fs.Add(f.ID, f); - } - //return libraryFolders; - return fs; - } - - private List TraverseFolder(InventoryFolderImpl node) - { - List folders = node.RequestListOfFolderImpls(); - List subs = new List(); - foreach (InventoryFolderImpl f in folders) - subs.AddRange(TraverseFolder(f)); - - folders.AddRange(subs); - return folders; - } - } -} diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 14f813a..2e55f53 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -30,7 +30,6 @@ using System.Text; using log4net; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; using OpenSim.Services.Interfaces; namespace OpenSim.Framework.Communications.Osp -- cgit v1.1 From 910d2177ad1e90d8b5748fbc8ffe9dbfe0c0fc9b Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 26 Jan 2010 12:49:53 -0500 Subject: * .. More Endlines... --- OpenSim/Framework/Communications/Clients/RegionClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 5ceaf39..ee7dec8 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Communications.Clients } // Add the regionhandle of the destination region ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); + args["destination_handle"] = OSD.FromString(regionHandle.ToString()); args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); string strBuffer = ""; -- cgit v1.1 From 35925942fca6d881b42771754700f2fbeeddb742 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 8 Feb 2010 15:02:50 -0800 Subject: Deleted unused class that came back because of merge conflicts. --- .../Communications/Clients/RegionClient.cs | 755 --------------------- 1 file changed, 755 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Clients/RegionClient.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs deleted file mode 100644 index ee7dec8..0000000 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.IO; -using System.Net; -using System.Reflection; -using System.Text; - -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -using log4net; - -namespace OpenSim.Framework.Communications.Clients -{ - public class RegionClient - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) - { - reason = String.Empty; - - // Eventually, we want to use a caps url instead of the agentID - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); - reason = e.Message; - return false; - } - - //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); - - HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); - AgentCreateRequest.Method = "POST"; - AgentCreateRequest.ContentType = "application/json"; - AgentCreateRequest.Timeout = 10000; - //AgentCreateRequest.KeepAlive = false; - AgentCreateRequest.Headers.Add("Authorization", authKey); - - // Fill it in - OSDMap args = null; - try - { - args = aCircuit.PackAgentCircuitData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = AgentCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - reason = "cannot contact remote region"; - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - WebResponse webResponse = null; - StreamReader sr = null; - try - { - webResponse = AgentCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); - } - else - { - - sr = new StreamReader(webResponse.GetResponseStream()); - string response = sr.ReadToEnd().Trim(); - m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); - - if (!String.IsNullOrEmpty(response)) - { - try - { - // we assume we got an OSDMap back - OSDMap r = GetOSDMap(response); - bool success = r["success"].AsBoolean(); - reason = r["reason"].AsString(); - return success; - } - catch (NullReferenceException e) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); - - // check for old style response - if (response.ToLower().StartsWith("true")) - return true; - - return false; - } - } - } - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) - { - // Eventually, we want to use a caps url instead of the agentID - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); - return false; - } - //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); - - HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); - ChildUpdateRequest.Method = "PUT"; - ChildUpdateRequest.ContentType = "application/json"; - ChildUpdateRequest.Timeout = 10000; - //ChildUpdateRequest.KeepAlive = false; - - // Fill it in - OSDMap args = null; - try - { - args = cAgentData.Pack(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ChildUpdateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); - - WebResponse webResponse = null; - StreamReader sr = null; - try - { - webResponse = ChildUpdateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) - { - agent = null; - // Eventually, we want to use a caps url instead of the agentID - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); - request.Method = "GET"; - request.Timeout = 10000; - //request.Headers.Add("authorization", ""); // coming soon - - HttpWebResponse webResponse = null; - string reply = string.Empty; - StreamReader sr = null; - try - { - webResponse = (HttpWebResponse)request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent get "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - reply = sr.ReadToEnd().Trim(); - - //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); - // ignore, really - return false; - } - finally - { - if (sr != null) - sr.Close(); - } - - if (webResponse.StatusCode == HttpStatusCode.OK) - { - // we know it's jason - OSDMap args = GetOSDMap(reply); - if (args == null) - { - //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); - return false; - } - - agent = new CompleteAgentData(); - agent.Unpack(args); - return true; - } - - //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); - return false; - } - - public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) - { - //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - StreamReader sr = null; - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - - public bool DoCloseAgentCall(GridRegion region, UUID id) - { - string uri = string.Empty; - try - { - uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); - return false; - } - - //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); - - WebRequest request = WebRequest.Create(uri); - request.Method = "DELETE"; - request.Timeout = 10000; - - StreamReader sr = null; - try - { - WebResponse webResponse = request.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on agent delete "); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - sr.Close(); - //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - } - - public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri - = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort - + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "POST"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["sog"] = OSD.FromString(sogXml2); - args["extra"] = OSD.FromString(sog.ExtraToXmlString()); - if (allowScriptCrossing) - { - string state = sog.GetStateSnapshot(); - if (state.Length > 0) - args["state"] = OSD.FromString(state); - } - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) - { - ulong regionHandle = GetRegionHandle(region.RegionHandle); - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; - //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); - - WebRequest ObjectCreateRequest = WebRequest.Create(uri); - ObjectCreateRequest.Method = "PUT"; - ObjectCreateRequest.ContentType = "application/json"; - ObjectCreateRequest.Timeout = 10000; - - OSDMap args = new OSDMap(2); - args["userid"] = OSD.FromUUID(userID); - args["itemid"] = OSD.FromUUID(itemID); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send - os = ObjectCreateRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = ObjectCreateRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - - //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) - { - string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; - //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); - - WebRequest HelloNeighbourRequest = WebRequest.Create(uri); - HelloNeighbourRequest.Method = "POST"; - HelloNeighbourRequest.ContentType = "application/json"; - HelloNeighbourRequest.Timeout = 10000; - - // Fill it in - OSDMap args = null; - try - { - args = thisRegion.PackRegionInfoData(); - } - catch (Exception e) - { - m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); - } - // Add the regionhandle of the destination region - ulong regionHandle = GetRegionHandle(region.RegionHandle); - args["destination_handle"] = OSD.FromString(regionHandle.ToString()); - - string strBuffer = ""; - byte[] buffer = new byte[1]; - try - { - strBuffer = OSDParser.SerializeJsonString(args); - Encoding str = Util.UTF8; - buffer = str.GetBytes(strBuffer); - - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - Stream os = null; - try - { // send the Post - HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send - os = HelloNeighbourRequest.GetRequestStream(); - os.Write(buffer, 0, strBuffer.Length); //Send it - //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); - } - //catch (WebException ex) - catch - { - //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); - - return false; - } - finally - { - if (os != null) - os.Close(); - } - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); - - StreamReader sr = null; - try - { - WebResponse webResponse = HelloNeighbourRequest.GetResponse(); - if (webResponse == null) - { - m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); - } - - sr = new StreamReader(webResponse.GetResponseStream()); - //reply = sr.ReadToEnd().Trim(); - sr.ReadToEnd().Trim(); - //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); - - } - catch (WebException ex) - { - m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); - // ignore, really - } - finally - { - if (sr != null) - sr.Close(); - } - - return true; - - } - - #region Hyperlinks - - public virtual ulong GetRegionHandle(ulong handle) - { - return handle; - } - - public virtual bool IsHyperlink(ulong handle) - { - return false; - } - - public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) - { - } - - public virtual void AdjustUserInformation(AgentCircuitData aCircuit) - { - } - - #endregion /* Hyperlinks */ - - public static OSDMap GetOSDMap(string data) - { - OSDMap args = null; - try - { - OSD buffer; - // We should pay attention to the content-type, but let's assume we know it's Json - buffer = OSDParser.DeserializeJson(data); - if (buffer.Type == OSDType.Map) - { - args = (OSDMap)buffer; - return args; - } - else - { - // uh? - System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); - return null; - } - } - catch (Exception ex) - { - System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); - return null; - } - } - - - } -} -- cgit v1.1 From bb171717ceaef37b022a135209c2e0bf031d21f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 15:38:52 -0800 Subject: Deleted obsolete files in the Data layer. Compiles. --- .../Communications/TemporaryUserProfilePlugin.cs | 104 --------------------- 1 file changed, 104 deletions(-) delete mode 100644 OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs deleted file mode 100644 index 2413055..0000000 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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 log4net; -using OpenMetaverse; -using OpenSim.Data; - -namespace OpenSim.Framework.Communications -{ - /// - /// Plugin for managing temporary user profiles. - /// - public class TemporaryUserProfilePlugin : IUserDataPlugin - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Dictionary m_profiles = new Dictionary(); - - public string Name { get { return "TemporaryUserProfilePlugin"; } } - public string Version { get { return "0.1"; } } - public void Initialise() {} - public void Initialise(string connect) {} - public void Dispose() {} - - public UserProfileData GetUserByUUID(UUID user) - { - //m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); - - lock (m_profiles) - { - if (m_profiles.ContainsKey(user)) - return m_profiles[user]; - else - return null; - } - } - - public UserProfileData GetUserByName(string fname, string lname) - { - // We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary - // profiles. - - return null; - } - - public virtual void AddTemporaryUserProfile(UserProfileData userProfile) - { - //m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); - - lock (m_profiles) - { - m_profiles[userProfile.ID] = userProfile; - } - } - - public UserProfileData GetUserByUri(Uri uri) { return null; } - public List GeneratePickerResults(UUID queryID, string query) { return null; } - public UserAgentData GetAgentByUUID(UUID user) { return null; } - public UserAgentData GetAgentByName(string name) { return null; } - public UserAgentData GetAgentByName(string fname, string lname) { return null; } - public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} - public void AddNewUserProfile(UserProfileData user) {} - public bool UpdateUserProfile(UserProfileData user) { return false; } - public void AddNewUserAgent(UserAgentData agent) {} - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {} - public void RemoveUserFriend(UUID friendlistowner, UUID friend) {} - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {} - public List GetUserFriendList(UUID friendlistowner) { return null; } - public Dictionary GetFriendRegionInfos(List uuids) { return null; } - public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } - public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } - public AvatarAppearance GetUserAppearance(UUID user) { return null; } - public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} - public void ResetAttachments(UUID userID) {} - public void LogoutUsers(UUID regionID) {} - } -} -- cgit v1.1 From 08ba34da0325e3ed2a839cff62f2020742e887e7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 31 Mar 2010 21:30:44 -0700 Subject: First attempt at fixing mantis #4641. It's better but there are now some issues with permissions. (looks like my commit is going to touch CM files, I'm going to let it do it - eof only) --- OpenSim/Framework/Communications/Osp/OspResolver.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 2e55f53..24ea64d 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -139,6 +139,9 @@ namespace OpenSim.Framework.Communications.Osp /// protected static UUID ResolveOspaName(string name, IUserAccountService userService) { + if (userService == null) + return UUID.Zero; + int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); if (nameSeparatorIndex < 0) @@ -149,7 +152,7 @@ namespace OpenSim.Framework.Communications.Osp string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); - + UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); if (account != null) return account.PrincipalID; -- cgit v1.1 From f86c438653fc3c8356a8f0c43a055b1928183f02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 29 Nov 2010 08:43:33 -0800 Subject: Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function. --- .../Osp/OspInventoryWrapperPlugin.cs | 104 ------------ .../Framework/Communications/Osp/OspResolver.cs | 177 --------------------- 2 files changed, 281 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs delete mode 100644 OpenSim/Framework/Communications/Osp/OspResolver.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs deleted file mode 100644 index bcd1eee..0000000 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using OpenSim.Data; -using OpenMetaverse; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications.Osp -{ - /// - /// Wrap other inventory data plugins so that we can perform OSP related post processing for items - /// - public class OspInventoryWrapperPlugin : IInventoryDataPlugin - { - protected IInventoryDataPlugin m_wrappedPlugin; - //protected CommunicationsManager m_commsManager; - protected IUserAccountService m_userAccountService; - - public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService) - { - m_wrappedPlugin = wrappedPlugin; - m_userAccountService = userService; - } - - public string Name { get { return "OspInventoryWrapperPlugin"; } } - public string Version { get { return "0.1"; } } - public void Initialise() {} - public void Initialise(string connect) {} - public void Dispose() {} - - public InventoryItemBase getInventoryItem(UUID item) - { - return PostProcessItem(m_wrappedPlugin.getInventoryItem(item)); - } - - // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem? - public InventoryItemBase queryInventoryItem(UUID item) - { - return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item)); - } - - public List getInventoryInFolder(UUID folderID) - { - List items = m_wrappedPlugin.getInventoryInFolder(folderID); - - foreach (InventoryItemBase item in items) - PostProcessItem(item); - - return items; - } - - public List fetchActiveGestures(UUID avatarID) - { - return m_wrappedPlugin.fetchActiveGestures(avatarID); - - // Presuming that no post processing is needed here as gestures don't refer to creator information (?) - } - - protected InventoryItemBase PostProcessItem(InventoryItemBase item) - { - item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService); - return item; - } - - public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); } - public List getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); } - public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); } - public List getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); } - public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); } - public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); } - public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); } - public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); } - public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); } - public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); } - public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); } - public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); } - public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); } - } -} diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs deleted file mode 100644 index 24ea64d..0000000 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator 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.Reflection; -using System.Text; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Framework.Communications.Osp -{ - /// - /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for - /// identifying user profiles or supplying a simple name if no profile is available. - /// - public class OspResolver - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public const string OSPA_PREFIX = "ospa:"; - public const string OSPA_NAME_KEY = "n"; - public const string OSPA_NAME_VALUE_SEPARATOR = " "; - public const string OSPA_TUPLE_SEPARATOR = "|"; - public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); - public const string OSPA_PAIR_SEPARATOR = "="; - - /// - /// Make an OSPA given a user UUID - /// - /// - /// - /// The OSPA. Null if a user with the given UUID could not be found. - public static string MakeOspa(UUID userId, IUserAccountService userService) - { - UserAccount account = userService.GetUserAccount(UUID.Zero, userId); - if (account != null) - return MakeOspa(account.FirstName, account.LastName); - - return null; - } - - /// - /// Make an OSPA given a user name - /// - /// - /// - public static string MakeOspa(string firstName, string lastName) - { - return - OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - } - - /// - /// Resolve an osp string into the most suitable internal OpenSim identifier. - /// - /// - /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may - /// just return the same identifier after creating a temporary profile. - /// - /// - /// - /// - /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero - /// is returned. - /// - public static UUID ResolveOspa(string ospa, IUserAccountService userService) - { - if (!ospa.StartsWith(OSPA_PREFIX)) - return UUID.Zero; - -// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); - - string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); - string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); - - foreach (string tuple in ospaTuples) - { - int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); - - if (tupleSeparatorIndex < 0) - { - m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); - continue; - } - - string key = tuple.Remove(tupleSeparatorIndex).Trim(); - string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); - - if (OSPA_NAME_KEY == key) - return ResolveOspaName(value, userService); - } - - return UUID.Zero; - } - - /// - /// Hash a profile name into a UUID - /// - /// - /// - public static UUID HashName(string name) - { - return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); - } - - /// - /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile - /// then a temporary user profile is inserted in the cache. - /// - /// - /// - /// - /// An OpenSim internal identifier for the name given. Returns null if the name was not valid - /// - protected static UUID ResolveOspaName(string name, IUserAccountService userService) - { - if (userService == null) - return UUID.Zero; - - int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); - - if (nameSeparatorIndex < 0) - { - m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); - return UUID.Zero; - } - - string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); - string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); - - UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); - if (account != null) - return account.PrincipalID; - - // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc - /* - UserProfileData tempUserProfile = new UserProfileData(); - tempUserProfile.FirstName = firstName; - tempUserProfile.SurName = lastName; - tempUserProfile.ID = HashName(tempUserProfile.Name); - - m_log.DebugFormat( - "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); - commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); - - return tempUserProfile.ID; - */ - - return UUID.Zero; - } - } -} -- cgit v1.1 From 531edd51d82ecd6a842a2611c99e9919634491ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:22:55 -0700 Subject: Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow. Thanks R.Gunther (rigun@rigutech.nl) https://lists.berlios.de/pipermail/opensim-users/2012-September/010986.html --- OpenSim/Framework/Communications/RestClient.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 97b3b60..226e52f 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -306,6 +306,7 @@ namespace OpenSim.Framework.Communications _request.ContentType = "application/xml"; _request.Timeout = 200000; _request.Method = RequestMethod; + _request.Proxy = null; _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -365,6 +366,7 @@ namespace OpenSim.Framework.Communications _request.ContentType = "application/xml"; _request.Timeout = 900000; _request.Method = RequestMethod; + _request.Proxy = null; _asyncException = null; _request.ContentLength = src.Length; -- cgit v1.1 From 91a5c602e313b96ffaf1d50b7f0d2923a2e141ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:48:03 -0700 Subject: Revert "Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow." But the patch is here, in case anyone wants to try it. This reverts commit 531edd51d82ecd6a842a2611c99e9919634491ef. --- OpenSim/Framework/Communications/RestClient.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 226e52f..97b3b60 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -306,7 +306,6 @@ namespace OpenSim.Framework.Communications _request.ContentType = "application/xml"; _request.Timeout = 200000; _request.Method = RequestMethod; - _request.Proxy = null; _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -366,7 +365,6 @@ namespace OpenSim.Framework.Communications _request.ContentType = "application/xml"; _request.Timeout = 900000; _request.Method = RequestMethod; - _request.Proxy = null; _asyncException = null; _request.ContentLength = src.Length; -- cgit v1.1 From e4cb7af98a122773e84baf9be38b8b34f02e89a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Nov 2012 19:26:43 -0800 Subject: Updated all existing AssemblyVersions's to 0.7.5.*. Many DLLs still don't have an AssemblyInfo file. --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 2df6ace..9bafa57 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 27b12cebbba8df2f03fe7918b9672be23bc41a09 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 14 Nov 2012 08:10:15 -0800 Subject: A few more AssemblyInfos in a few more dlls. --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 9bafa57..6d1c03a 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -32,12 +32,12 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly : AssemblyTitle("OpenGrid.Framework.Communications")] +[assembly : AssemblyTitle("OpenSim.Framework.Communications")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("http://opensimulator.org")] -[assembly : AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] +[assembly : AssemblyProduct("OpenSim")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] -- cgit v1.1 From 1f1da230976451d30d920c237d53c699ba96b9d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Feb 2013 00:23:17 +0000 Subject: Bump version and assembly version numbers from 0.7.5 to 0.7.6 This is mostly Bluewall's work but I am also bumping the general version number OpenSimulator 0.7.5 remains in the release candidate stage. I'm doing this because master is significantly adding things that will not be in 0.7.5 This update should not cause issues with existing external binary DLLs because our DLLs do not have strong names and so the exact version match requirement is not in force. --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 6d1c03a..cf575ac 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.7.5.*")] +[assembly : AssemblyVersion("0.7.6.*")] [assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 4779f7d7d5ce0e284d9ed15104389f8479b11545 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 19 Feb 2013 17:14:55 -0800 Subject: Deleted all AssemblyFileVersion directives --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index cf575ac..df8eb52 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("0.7.6.*")] -[assembly : AssemblyFileVersion("0.6.5.0")] + -- cgit v1.1 From 42bdf446585007029faf4cd21abd289487f0f797 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 23:33:47 +0100 Subject: Bump OPenSimulator version and assembly versions up to 0.8.0 Dev --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index df8eb52..09611fa 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.7.6.*")] +[assembly : AssemblyVersion("0.8.0.*")] -- cgit v1.1 From 01daa74adf64aceb9cb2aef718c84f452b4f29e9 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 3 Apr 2014 16:10:53 +0300 Subject: Better error messages in RestClient --- OpenSim/Framework/Communications/RestClient.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 97b3b60..2275e31 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -318,12 +318,11 @@ namespace OpenSim.Framework.Communications HttpWebResponse errorResponse = e.Response as HttpWebResponse; if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) { - m_log.Warn("[REST CLIENT] Resource not found (404)"); + m_log.WarnFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); } else { - m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString()); - m_log.Debug(e.ToString()); + m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); } return null; -- cgit v1.1 From 672bd9fc98711db81696ed31e88c53f7ba10ce66 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 3 Apr 2014 17:03:58 +0300 Subject: Reduced log levels for REST 404 errors to DEBUG --- OpenSim/Framework/Communications/RestClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 2275e31..e7f0ca8 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -318,7 +318,8 @@ namespace OpenSim.Framework.Communications HttpWebResponse errorResponse = e.Response as HttpWebResponse; if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) { - m_log.WarnFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); + // This is often benign. E.g., requesting a missing asset will return 404. + m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); } else { -- cgit v1.1 From 20f20895cf1444071d5edc42e11a1fb94b1b1079 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 23 May 2014 16:19:43 -0700 Subject: Adds optional HTTP Basic Authentication to Robust service connectors. --- OpenSim/Framework/Communications/RestClient.cs | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e7f0ca8..89e6aa1 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -35,6 +35,8 @@ using System.Threading; using System.Web; using log4net; +using OpenSim.Framework.ServiceAuth; + namespace OpenSim.Framework.Communications { /// @@ -297,7 +299,7 @@ namespace OpenSim.Framework.Communications /// /// Perform a synchronous request /// - public Stream Request() + public Stream Request(IServiceAuth auth) { lock (_lock) { @@ -307,6 +309,8 @@ namespace OpenSim.Framework.Communications _request.Timeout = 200000; _request.Method = RequestMethod; _asyncException = null; + if (auth != null) + auth.AddAuthorization(_request.Headers); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); try @@ -358,7 +362,7 @@ namespace OpenSim.Framework.Communications } } - public Stream Request(Stream src) + public Stream Request(Stream src, IServiceAuth auth) { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; @@ -367,6 +371,8 @@ namespace OpenSim.Framework.Communications _request.Method = RequestMethod; _asyncException = null; _request.ContentLength = src.Length; + if (auth != null) + auth.AddAuthorization(_request.Headers); m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); @@ -384,7 +390,22 @@ namespace OpenSim.Framework.Communications length = src.Read(buf, 0, 1024); } - _response = (HttpWebResponse) _request.GetResponse(); + try + { + _response = (HttpWebResponse)_request.GetResponse(); + } + catch (WebException e) + { + m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", + RequestMethod, _request.RequestUri, e.Status, e.Message); + } + catch (Exception e) + { + m_log.WarnFormat( + "[REST]: Request {0} {1} failed with exception {2} {3}", + RequestMethod, _request.RequestUri, e.Message, e.StackTrace); + } + // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -423,7 +444,7 @@ namespace OpenSim.Framework.Communications try { // Perform the operation; if sucessful set the result - Stream s = Request(); + Stream s = Request(null); ar.SetAsCompleted(s, false); } catch (Exception e) -- cgit v1.1 From 9ced61fbc26a977cb2b0aedecdc60fcd684f365e Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 30 May 2014 13:47:19 -0700 Subject: Add a 0 parameter overload for RestClient.Request() for use when no auth is required. This preserves API compatibility for external modules using this function. --- OpenSim/Framework/Communications/RestClient.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 89e6aa1..586400f 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -299,6 +299,14 @@ namespace OpenSim.Framework.Communications /// /// Perform a synchronous request /// + public Stream Request() + { + return Request(null); + } + + /// + /// Perform a synchronous request + /// public Stream Request(IServiceAuth auth) { lock (_lock) -- cgit v1.1 From 5450b1b0247bb3907f60f2b3f9b0582903de4f83 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 17 Jun 2014 18:37:15 +0100 Subject: Change assembly versions to 0.8.1 --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 09611fa..907cebd 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.8.0.*")] +[assembly : AssemblyVersion("0.8.1.*")] -- cgit v1.1 From a8860d79d8b0e2007b16cd2b1a316b51a80c13da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jul 2014 23:12:14 +0100 Subject: Turn RestClient.Request() logging down the debug and comment out for now. --- OpenSim/Framework/Communications/RestClient.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 586400f..e556181 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -382,16 +382,16 @@ namespace OpenSim.Framework.Communications if (auth != null) auth.AddAuthorization(_request.Headers); - m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); - m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); +// m_log.DebugFormat("[REST]: Request Length {0}", _request.ContentLength); +// m_log.DebugFormat("[REST]: Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); - m_log.Info("[REST]: Seek is ok"); +// m_log.Debug("[REST]: Seek is ok"); Stream dst = _request.GetRequestStream(); - m_log.Info("[REST]: GetRequestStream is ok"); +// m_log.Debug("[REST]: GetRequestStream is ok"); byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); - m_log.Info("[REST]: First Read is ok"); +// m_log.Debug("[REST]: First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); -- cgit v1.1 From 99ac770abbe3a95887c4b10c82f3985aa878eeef Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 1 Jun 2014 17:39:11 +0300 Subject: Close streams immediately when we finish using them --- OpenSim/Framework/Communications/RestClient.cs | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e556181..fb79c59 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Communications /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be /// invoked by the caller in either synchronous mode or asynchronous modes. /// - public class RestClient + public class RestClient : IDisposable { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -148,6 +148,33 @@ namespace OpenSim.Framework.Communications #endregion constructors + + #region Dispose + + private bool disposed = false; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposed) + return; + + if (disposing) + { + _resource.Dispose(); + } + + disposed = true; + } + + #endregion Dispose + + /// /// Add a path element to the query, e.g. assets /// -- cgit v1.1 From 6b57b6183603601d8bebf5c4cf5caced56d13242 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 13 Jul 2014 19:19:58 +0300 Subject: Log RestClient requests similarly to WebClient (e.g, "debug http all 6" logs the entire request and response) --- OpenSim/Framework/Communications/RestClient.cs | 36 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index fb79c59..de6fe30 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -347,6 +347,10 @@ namespace OpenSim.Framework.Communications if (auth != null) auth.AddAuthorization(_request.Headers); + int reqnum = WebUtil.RequestNumber++; + if (WebUtil.DebugLevel >= 3) + m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri); + // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); try { @@ -393,6 +397,9 @@ namespace OpenSim.Framework.Communications _resource.Seek(0, SeekOrigin.Begin); } + if (WebUtil.DebugLevel >= 5) + WebUtil.LogResponseDetail(reqnum, _resource); + return _resource; } } @@ -409,16 +416,18 @@ namespace OpenSim.Framework.Communications if (auth != null) auth.AddAuthorization(_request.Headers); -// m_log.DebugFormat("[REST]: Request Length {0}", _request.ContentLength); -// m_log.DebugFormat("[REST]: Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); -// m_log.Debug("[REST]: Seek is ok"); + + int reqnum = WebUtil.RequestNumber++; + if (WebUtil.DebugLevel >= 3) + m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri); + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src); + Stream dst = _request.GetRequestStream(); -// m_log.Debug("[REST]: GetRequestStream is ok"); byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); -// m_log.Debug("[REST]: First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); @@ -433,14 +442,29 @@ namespace OpenSim.Framework.Communications { m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", RequestMethod, _request.RequestUri, e.Status, e.Message); + return null; } catch (Exception e) { m_log.WarnFormat( "[REST]: Request {0} {1} failed with exception {2} {3}", RequestMethod, _request.RequestUri, e.Message, e.StackTrace); + return null; + } + + if (WebUtil.DebugLevel >= 5) + { + using (Stream responseStream = _response.GetResponseStream()) + { + using (StreamReader reader = new StreamReader(responseStream)) + { + string responseStr = reader.ReadToEnd(); + WebUtil.LogResponseDetail(reqnum, responseStr); + } + } } - + + _response.Close(); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); -- cgit v1.1 From ec8d21c434a39f46518ee9cf9f5539d1790eacc0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 4 Nov 2014 00:55:48 +0000 Subject: Label all threadpool calls being made in core OpenSimulator. This is to add problem diagnosis. "show threadpool calls" now also returns named (labelled), anonymous (unlabelled) and total call stats. --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index de6fe30..72018e4 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -483,7 +483,7 @@ namespace OpenSim.Framework.Communications /// In case, we are invoked asynchroneously this object will keep track of the state /// AsyncResult ar = new AsyncResult(callback, state); - Util.FireAndForget(RequestHelper, ar); + Util.FireAndForget(RequestHelper, ar, "RestClient.BeginRequest"); return ar; } -- cgit v1.1 From e3d07bd0cc120e2187389f6aa4a78b0506b04f92 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 20 Dec 2014 01:39:31 +0000 Subject: minor: Correct propery doc RestClient._resource spelling mistake --- OpenSim/Framework/Communications/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 72018e4..4a8301e 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Communications private byte[] _readbuf; /// - /// MemoryStream representing the resultiong resource + /// MemoryStream representing the resulting resource /// private Stream _resource; -- cgit v1.1 From 7100475b90a097a3a1775d2b92756e1260383c73 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 20 Dec 2014 01:56:33 +0000 Subject: Make sure we always dispose of disposables inside RestClient.Request() --- OpenSim/Framework/Communications/RestClient.cs | 56 ++++++++++++++------------ 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 4a8301e..6f517b6 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -352,42 +352,46 @@ namespace OpenSim.Framework.Communications m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); + try { - _response = (HttpWebResponse) _request.GetResponse(); + using (_response = (HttpWebResponse) _request.GetResponse()) + { + using (Stream src = _response.GetResponseStream()) + { + int length = src.Read(_readbuf, 0, BufferSize); + while (length > 0) + { + _resource.Write(_readbuf, 0, length); + length = src.Read(_readbuf, 0, BufferSize); + } + + // TODO! Implement timeout, without killing the server + // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted + //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); + + // _allDone.WaitOne(); + } + } } catch (WebException e) { - HttpWebResponse errorResponse = e.Response as HttpWebResponse; - if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) - { - // This is often benign. E.g., requesting a missing asset will return 404. - m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); - } - else + using (HttpWebResponse errorResponse = e.Response as HttpWebResponse) { - m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); + if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) + { + // This is often benign. E.g., requesting a missing asset will return 404. + m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); + } + else + { + m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); + } } return null; } - Stream src = _response.GetResponseStream(); - int length = src.Read(_readbuf, 0, BufferSize); - while (length > 0) - { - _resource.Write(_readbuf, 0, length); - length = src.Read(_readbuf, 0, BufferSize); - } - - - // TODO! Implement timeout, without killing the server - // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted - //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - -// _allDone.WaitOne(); - if (_response != null) - _response.Close(); if (_asyncException != null) throw _asyncException; @@ -515,4 +519,4 @@ namespace OpenSim.Framework.Communications #endregion Async Invocation } -} +} \ No newline at end of file -- cgit v1.1 From 7d3bafd5abf22f5c1ea3c3d8918d9b8177693bda Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Mar 2015 17:43:00 +0000 Subject: Add outbound URL filter to llHttpRequest() and osSetDynamicTextureURL*() script functions. This is to address an issue where HTTP script functions could make calls to localhost and other endpoints inside the simulator's LAN. By default, calls to all private addresses are now blocked as per http://en.wikipedia.org/wiki/Reserved_IP_addresses If you require exceptions to this, configure [Network] OutboundDisallowForUserScriptsExcept in OpenSim.ini --- .../Framework/Communications/OutboundUrlFilter.cs | 256 +++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 OpenSim/Framework/Communications/OutboundUrlFilter.cs (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/OutboundUrlFilter.cs b/OpenSim/Framework/Communications/OutboundUrlFilter.cs new file mode 100644 index 0000000..8b572d1 --- /dev/null +++ b/OpenSim/Framework/Communications/OutboundUrlFilter.cs @@ -0,0 +1,256 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator 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.Linq; +using System.Net; +using System.Reflection; +using log4net; +using LukeSkywalker.IPNetwork; +using Nini.Config; + +namespace OpenSim.Framework.Communications +{ + public class OutboundUrlFilter + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get; private set; } + + private List m_blacklistNetworks; + private List m_blacklistEndPoints; + + private List m_blacklistExceptionNetworks; + private List m_blacklistExceptionEndPoints; + + public OutboundUrlFilter( + string name, + List blacklistNetworks, List blacklistEndPoints, + List blacklistExceptionNetworks, List blacklistExceptionEndPoints) + { + Name = name; + + m_blacklistNetworks = blacklistNetworks; + m_blacklistEndPoints = blacklistEndPoints; + m_blacklistExceptionNetworks = blacklistExceptionNetworks; + m_blacklistExceptionEndPoints = blacklistExceptionEndPoints; + } + + /// + /// Initializes a new instance of the class. + /// + /// Name of the filter for logging purposes. + /// Filter configuration + public OutboundUrlFilter(string name, IConfigSource config) + { + Name = name; + + string configBlacklist + = "0.0.0.0/8|10.0.0.0/8|100.64.0.0/10|127.0.0.0/8|169.254.0.0/16|172.16.0.0/12|192.0.0.0/24|192.0.2.0/24|192.88.99.0/24|192.168.0.0/16|198.18.0.0/15|198.51.100.0/24|203.0.113.0/24|224.0.0.0/4|240.0.0.0/4|255.255.255.255/32"; + string configBlacklistExceptions = ""; + + IConfig networkConfig = config.Configs["Network"]; + + if (networkConfig != null) + { + configBlacklist = networkConfig.GetString("OutboundDisallowForUserScripts", configBlacklist); + configBlacklistExceptions + = networkConfig.GetString("OutboundDisallowForUserScriptsExcept", configBlacklistExceptions); + } + + m_log.DebugFormat( + "[OUTBOUND URL FILTER]: OutboundDisallowForUserScripts for {0} is [{1}]", Name, configBlacklist); + m_log.DebugFormat( + "[OUTBOUND URL FILTER]: OutboundDisallowForUserScriptsExcept for {0} is [{1}]", Name, configBlacklistExceptions); + + OutboundUrlFilter.ParseConfigList( + configBlacklist, Name, out m_blacklistNetworks, out m_blacklistEndPoints); + OutboundUrlFilter.ParseConfigList( + configBlacklistExceptions, Name, out m_blacklistExceptionNetworks, out m_blacklistExceptionEndPoints); + } + + private static void ParseConfigList( + string fullConfigEntry, string filterName, out List networks, out List endPoints) + { + // Parse blacklist + string[] configBlacklistEntries + = fullConfigEntry.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + + configBlacklistEntries = configBlacklistEntries.Select(e => e.Trim()).ToArray(); + + networks = new List(); + endPoints = new List(); + + foreach (string configEntry in configBlacklistEntries) + { + if (configEntry.Contains("/")) + { + IPNetwork network; + + if (!IPNetwork.TryParse(configEntry, out network)) + { + m_log.ErrorFormat( + "[OUTBOUND URL FILTER]: Entry [{0}] is invalid network for {1}", configEntry, filterName); + + continue; + } + + networks.Add(network); + } + else + { + Uri configEntryUri; + + if (!Uri.TryCreate("http://" + configEntry, UriKind.Absolute, out configEntryUri)) + { + m_log.ErrorFormat( + "[OUTBOUND URL FILTER]: EndPoint entry [{0}] is invalid endpoint for {1}", + configEntry, filterName); + + continue; + } + + IPAddress[] addresses = Dns.GetHostAddresses(configEntryUri.Host); + + foreach (IPAddress addr in addresses) + { + if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + // m_log.DebugFormat("[OUTBOUND URL FILTER]: Found address [{0}] in config", addr); + + IPEndPoint configEntryEp = new IPEndPoint(addr, configEntryUri.Port); + endPoints.Add(configEntryEp); + + // m_log.DebugFormat("[OUTBOUND URL FILTER]: Added blacklist exception [{0}]", configEntryEp); + } + } + } + } + } + + /// + /// Determines if an url is in a list of networks and endpoints. + /// + /// + /// IP address + /// + /// Networks. + /// End points. + /// Filter name. + private static bool IsInNetwork( + IPAddress addr, int port, List networks, List endPoints, string filterName) + { + foreach (IPNetwork ipn in networks) + { +// m_log.DebugFormat( +// "[OUTBOUND URL FILTER]: Checking [{0}] against network [{1}]", addr, ipn); + + if (IPNetwork.Contains(ipn, addr)) + { +// m_log.DebugFormat( +// "[OUTBOUND URL FILTER]: Found [{0}] in network [{1}]", addr, ipn); + + return true; + } + } + + // m_log.DebugFormat("[OUTBOUND URL FILTER]: Found address [{0}]", addr); + + foreach (IPEndPoint ep in endPoints) + { +// m_log.DebugFormat( +// "[OUTBOUND URL FILTER]: Checking [{0}:{1}] against endpoint [{2}]", +// addr, port, ep); + + if (addr.Equals(ep.Address) && port == ep.Port) + { +// m_log.DebugFormat( +// "[OUTBOUND URL FILTER]: Found [{0}:{1}] in endpoint [{2}]", addr, port, ep); + + return true; + } + } + +// m_log.DebugFormat("[OUTBOUND URL FILTER]: Did not find [{0}:{1}] in list", addr, port); + + return false; + } + + /// + /// Checks whether the given url is allowed by the filter. + /// + /// + public bool CheckAllowed(Uri url) + { + bool allowed = true; + + // Check that we are permitted to make calls to this endpoint. + bool foundIpv4Address = false; + + IPAddress[] addresses = Dns.GetHostAddresses(url.Host); + + foreach (IPAddress addr in addresses) + { + if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { +// m_log.DebugFormat("[OUTBOUND URL FILTER]: Found address [{0}]", addr); + + foundIpv4Address = true; + + // Check blacklist + if (OutboundUrlFilter.IsInNetwork(addr, url.Port, m_blacklistNetworks, m_blacklistEndPoints, Name)) + { +// m_log.DebugFormat("[OUTBOUND URL FILTER]: Found [{0}] in blacklist for {1}", url, Name); + + // Check blacklist exceptions + allowed + = OutboundUrlFilter.IsInNetwork( + addr, url.Port, m_blacklistExceptionNetworks, m_blacklistExceptionEndPoints, Name); + +// if (allowed) +// m_log.DebugFormat("[OUTBOUND URL FILTER]: Found [{0}] in whitelist for {1}", url, Name); + } + } + + // Found at least one address in a blacklist and not a blacklist exception + if (!allowed) + return false; +// else +// m_log.DebugFormat("[OUTBOUND URL FILTER]: URL [{0}] not in blacklist for {1}", url, Name); + } + + // We do not know how to handle IPv6 securely yet. + if (!foundIpv4Address) + return false; + +// m_log.DebugFormat("[OUTBOUND URL FILTER]: Allowing request [{0}]", url); + + return allowed; + } + } +} \ No newline at end of file -- cgit v1.1 From da32512ea449c2de2d4a6069f899fbd4a8bb03fa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 29 Apr 2015 18:47:17 -0700 Subject: Updated all occurrences of AssemblyVersion("0.8.1.*") to AssemblyVersion("0.8.2.*") --- OpenSim/Framework/Communications/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 907cebd..b398167 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.8.1.*")] +[assembly : AssemblyVersion("0.8.2.*")] -- cgit v1.1