From 7daa3955bc3a1918e40962851f9e8d38597a245e Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 22 Mar 2007 10:11:15 +0000 Subject: brought zircon branch into trunk --- OpenSim.Framework/AgentCiruitData.cs | 18 +++ OpenSim.Framework/AssetBase.cs | 22 +++ OpenSim.Framework/BlockingQueue.cs | 33 ++++ OpenSim.Framework/HeightMapGenHills.cs | 149 +++++++++++++++++ OpenSim.Framework/IAssetServer.cs | 68 ++++++++ OpenSim.Framework/IConfig.cs | 78 +++++++++ OpenSim.Framework/IGridServer.cs | 78 +++++++++ OpenSim.Framework/ILocalStorage.cs | 51 ++++++ OpenSim.Framework/IUserServer.cs | 14 ++ OpenSim.Framework/Inventory.cs | 127 +++++++++++++++ OpenSim.Framework/LocalGridBase.cs | 21 +++ OpenSim.Framework/Login.cs | 22 +++ OpenSim.Framework/LoginService.cs | 14 ++ OpenSim.Framework/NeighbourInfo.cs | 19 +++ OpenSim.Framework/OpenSim.Framework.csproj | 151 +++++++++++++++++ OpenSim.Framework/OpenSim.Framework.dll.build | 63 ++++++++ OpenSim.Framework/PrimData.cs | 45 ++++++ OpenSim.Framework/Properties/AssemblyInfo.cs | 33 ++++ OpenSim.Framework/RemoteGridBase.cs | 25 +++ OpenSim.Framework/SimProfile.cs | 51 ++++++ OpenSim.Framework/SimProfileBase.cs | 25 +++ OpenSim.Framework/UserProfile.cs | 50 ++++++ OpenSim.Framework/UserProfileManager.cs | 223 ++++++++++++++++++++++++++ OpenSim.Framework/UserProfileManagerBase.cs | 91 +++++++++++ OpenSim.Framework/Util.cs | 32 ++++ 25 files changed, 1503 insertions(+) create mode 100644 OpenSim.Framework/AgentCiruitData.cs create mode 100644 OpenSim.Framework/AssetBase.cs create mode 100644 OpenSim.Framework/BlockingQueue.cs create mode 100644 OpenSim.Framework/HeightMapGenHills.cs create mode 100644 OpenSim.Framework/IAssetServer.cs create mode 100644 OpenSim.Framework/IConfig.cs create mode 100644 OpenSim.Framework/IGridServer.cs create mode 100644 OpenSim.Framework/ILocalStorage.cs create mode 100644 OpenSim.Framework/IUserServer.cs create mode 100644 OpenSim.Framework/Inventory.cs create mode 100644 OpenSim.Framework/LocalGridBase.cs create mode 100644 OpenSim.Framework/Login.cs create mode 100644 OpenSim.Framework/LoginService.cs create mode 100644 OpenSim.Framework/NeighbourInfo.cs create mode 100644 OpenSim.Framework/OpenSim.Framework.csproj create mode 100644 OpenSim.Framework/OpenSim.Framework.dll.build create mode 100644 OpenSim.Framework/PrimData.cs create mode 100644 OpenSim.Framework/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Framework/RemoteGridBase.cs create mode 100644 OpenSim.Framework/SimProfile.cs create mode 100644 OpenSim.Framework/SimProfileBase.cs create mode 100644 OpenSim.Framework/UserProfile.cs create mode 100644 OpenSim.Framework/UserProfileManager.cs create mode 100644 OpenSim.Framework/UserProfileManagerBase.cs create mode 100644 OpenSim.Framework/Util.cs (limited to 'OpenSim.Framework') diff --git a/OpenSim.Framework/AgentCiruitData.cs b/OpenSim.Framework/AgentCiruitData.cs new file mode 100644 index 0000000..3ab8a80 --- /dev/null +++ b/OpenSim.Framework/AgentCiruitData.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class AgentCircuitData + { + public AgentCircuitData() { } + public LLUUID AgentID; + public LLUUID SessionID; + public LLUUID SecureSessionID; + public string firstname; + public string lastname; + public uint circuitcode; + } +} diff --git a/OpenSim.Framework/AssetBase.cs b/OpenSim.Framework/AssetBase.cs new file mode 100644 index 0000000..8206b30 --- /dev/null +++ b/OpenSim.Framework/AssetBase.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class AssetBase + { + public byte[] Data; + public LLUUID FullID; + public sbyte Type; + public sbyte InvType; + public string Name; + public string Description; + + public AssetBase() + { + + } + } +} diff --git a/OpenSim.Framework/BlockingQueue.cs b/OpenSim.Framework/BlockingQueue.cs new file mode 100644 index 0000000..f840354 --- /dev/null +++ b/OpenSim.Framework/BlockingQueue.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Utilities +{ + public class BlockingQueue + { + private Queue _queue = new Queue(); + private object _queueSync = new object(); + + public void Enqueue(T value) + { + lock (_queueSync) + { + _queue.Enqueue(value); + Monitor.Pulse(_queueSync); + } + } + + public T Dequeue() + { + lock (_queueSync) + { + if (_queue.Count < 1) + Monitor.Wait(_queueSync); + + return _queue.Dequeue(); + } + } + } +} diff --git a/OpenSim.Framework/HeightMapGenHills.cs b/OpenSim.Framework/HeightMapGenHills.cs new file mode 100644 index 0000000..6a729da --- /dev/null +++ b/OpenSim.Framework/HeightMapGenHills.cs @@ -0,0 +1,149 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING 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.Terrain +{ + public class HeightmapGenHills + { + private Random Rand = new Random(); + private int NumHills; + private float HillMin; + private float HillMax; + private bool Island; + private float[] heightmap; + + public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) + { + NumHills = numHills; + HillMin = hillMin; + HillMax = hillMax; + Island = island; + + heightmap = new float[256 * 256]; + + for (int i = 0; i < numHills; i++) + { + AddHill(); + } + + Normalize(); + + return heightmap; + } + + private void AddHill() + { + float x, y; + float radius = RandomRange(HillMin, HillMax); + + if (Island) + { + // Which direction from the center of the map the hill is placed + float theta = RandomRange(0, 6.28f); + + // How far from the center of the map to place the hill. The radius + // is subtracted from the range to prevent any part of the hill from + // reaching the edge of the map + float distance = RandomRange(radius / 2.0f, 128.0f - radius); + + x = 128.0f + (float)Math.Cos(theta) * distance; + y = 128.0f + (float)Math.Sin(theta) * distance; + } + else + { + x = RandomRange(-radius, 256.0f + radius); + y = RandomRange(-radius, 256.0f + radius); + } + + float radiusSq = radius * radius; + float distSq; + float height; + + int xMin = (int)(x - radius) - 1; + int xMax = (int)(x + radius) + 1; + if (xMin < 0) xMin = 0; + if (xMax > 255) xMax = 255; + + int yMin = (int)(y - radius) - 1; + int yMax = (int)(y + radius) + 1; + if (yMin < 0) yMin = 0; + if (yMax > 255) yMax = 255; + + // Loop through each affected cell and determine the height at that point + for (int v = yMin; v <= yMax; ++v) + { + float fv = (float)v; + + for (int h = xMin; h <= xMax; ++h) + { + float fh = (float)h; + + // Determine how far from the center of this hill this point is + distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); + height = radiusSq - distSq; + + // Don't add negative hill values + if (height > 0.0f) heightmap[h + v * 256] += height; + } + } + } + + private void Normalize() + { + float min = heightmap[0]; + float max = heightmap[0]; + + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; + if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; + } + } + + // Avoid a rare divide by zero + if (min != max) + { + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); + } + } + } + } + + private float RandomRange(float min, float max) + { + return (float)Rand.NextDouble() * (max - min) + min; + } + } +} diff --git a/OpenSim.Framework/IAssetServer.cs b/OpenSim.Framework/IAssetServer.cs new file mode 100644 index 0000000..a0de548 --- /dev/null +++ b/OpenSim.Framework/IAssetServer.cs @@ -0,0 +1,68 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING 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.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading; +using libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Description of IAssetServer. + /// + + public interface IAssetServer + { + void SetReceiver(IAssetReceiver receiver); + void RequestAsset(LLUUID assetID, bool isTexture); + void UpdateAsset(AssetBase asset); + void UploadNewAsset(AssetBase asset); + void SetServerInfo(string ServerUrl, string ServerKey); + void Close(); + } + + // could change to delegate? + public interface IAssetReceiver + { + void AssetReceived(AssetBase asset, bool IsTexture); + void AssetNotFound(AssetBase asset); + } + + public interface IAssetPlugin + { + IAssetServer GetAssetServer(); + } + + public struct ARequest + { + public LLUUID AssetID; + public bool IsTexture; + } +} diff --git a/OpenSim.Framework/IConfig.cs b/OpenSim.Framework/IConfig.cs new file mode 100644 index 0000000..ca7f645 --- /dev/null +++ b/OpenSim.Framework/IConfig.cs @@ -0,0 +1,78 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING 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 libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// This class handles connection to the underlying database used for configuration of the region. + /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate + /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from + /// what is hardcoded here and then saved into opensim.yap for future startups. + /// + + + public abstract class SimConfig + { + public string RegionName; + + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + public int IPListenPort; + public string IPListenAddr; + + public string AssetURL; + public string AssetSendKey; + + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string UserURL; + public string UserSendKey; + public string UserRecvKey; + + public abstract void InitConfig(bool sandboxMode); + public abstract void LoadFromGrid(); + public abstract float[] LoadWorld(); + public abstract void SaveMap(float[] heightmap); + + } + + public interface ISimConfig + { + SimConfig GetConfigObject(); + } +} diff --git a/OpenSim.Framework/IGridServer.cs b/OpenSim.Framework/IGridServer.cs new file mode 100644 index 0000000..026dfab --- /dev/null +++ b/OpenSim.Framework/IGridServer.cs @@ -0,0 +1,78 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING 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.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Handles connection to Grid Servers. + /// also Sim to Sim connections? + /// + + public interface IGridServer + { + UUIDBlock RequestUUIDBlock(); + NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions + AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + string GetName(); + bool RequestConnection(); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + void Close(); + } + + public struct UUIDBlock + { + public LLUUID BlockStart; + public LLUUID BlockEnd; + } + + public class AuthenticateResponse + { + public bool Authorised; + public Login LoginInfo; + + public AuthenticateResponse() + { + + } + + } + + public interface IGridPlugin + { + IGridServer GetGridServer(); + } +} diff --git a/OpenSim.Framework/ILocalStorage.cs b/OpenSim.Framework/ILocalStorage.cs new file mode 100644 index 0000000..e9aa1a2 --- /dev/null +++ b/OpenSim.Framework/ILocalStorage.cs @@ -0,0 +1,51 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING 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 libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// ILocalStorage. Really hacked together right now needs cleaning up + /// + public interface ILocalStorage + { + void StorePrim(PrimData prim); + void RemovePrim(LLUUID primID); + void LoadPrimitives(ILocalStorageReceiver receiver); + void ShutDown(); + } + + public interface ILocalStorageReceiver + { + void PrimFromStorage(PrimData prim); + } + +} + diff --git a/OpenSim.Framework/IUserServer.cs b/OpenSim.Framework/IUserServer.cs new file mode 100644 index 0000000..bb2b668 --- /dev/null +++ b/OpenSim.Framework/IUserServer.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Inventory; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IUserServer + { + AgentInventory RequestAgentsInventory(LLUUID agentID); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + } +} diff --git a/OpenSim.Framework/Inventory.cs b/OpenSim.Framework/Inventory.cs new file mode 100644 index 0000000..e34ea75 --- /dev/null +++ b/OpenSim.Framework/Inventory.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Assets; + +namespace OpenSim.Framework.Inventory +{ + public class AgentInventory + { + //Holds the local copy of Inventory info for a agent + public Dictionary InventoryFolders; + public Dictionary InventoryItems; + public InventoryFolder InventoryRoot; + public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server + public LLUUID AgentID; + public AvatarWearable[] Wearables; + + public AgentInventory() + { + InventoryFolders = new Dictionary(); + InventoryItems = new Dictionary(); + this.Initialise(); + } + + public virtual void Initialise() + { + Wearables = new AvatarWearable[2]; //should be 12 of these + for (int i = 0; i < 2; i++) + { + Wearables[i] = new AvatarWearable(); + } + + InventoryRoot = new InventoryFolder(); + InventoryRoot.FolderID = LLUUID.Random(); + InventoryRoot.ParentID = new LLUUID(); + InventoryRoot.Version = 1; + InventoryRoot.DefaultType = 8; + InventoryRoot.FolderName = "My Inventory"; + InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); + } + + public bool CreateNewFolder(LLUUID folderID) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + this.InventoryFolders.Add(Folder.FolderID, Folder); + + return (true); + } + + public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) + { + if (this.InventoryFolders.ContainsKey(folderID)) + { + LLUUID NewItemID = LLUUID.Random(); + + InventoryItem Item = new InventoryItem(); + Item.FolderID = folderID; + Item.OwnerID = AgentID; + Item.AssetID = asset.FullID; + Item.ItemID = NewItemID; + Item.Type = asset.Type; + Item.Name = asset.Name; + Item.Description = asset.Description; + Item.InvType = asset.InvType; + this.InventoryItems.Add(Item.ItemID, Item); + InventoryFolder Folder = InventoryFolders[Item.FolderID]; + Folder.Items.Add(Item); + return (Item.ItemID); + } + else + { + return (null); + } + } + } + + public class InventoryFolder + { + public List Items; + //public List Subfolders; + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ParentID; + public string FolderName; + public ushort DefaultType; + public ushort Version; + + public InventoryFolder() + { + Items = new List(); + //Subfolders = new List(); + } + + } + + public class InventoryItem + { + public LLUUID FolderID; + public LLUUID OwnerID; + public LLUUID ItemID; + public LLUUID AssetID; + public LLUUID CreatorID; + public sbyte InvType; + public sbyte Type; + public string Name; + public string Description; + + public InventoryItem() + { + this.CreatorID = LLUUID.Zero; + } + } + + public class AvatarWearable + { + public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); + public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); + + public AvatarWearable() + { + + } + } +} diff --git a/OpenSim.Framework/LocalGridBase.cs b/OpenSim.Framework/LocalGridBase.cs new file mode 100644 index 0000000..c9b278a --- /dev/null +++ b/OpenSim.Framework/LocalGridBase.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class LocalGridBase : IGridServer + { + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void AddNewSession(Login session); + public abstract void Close(); + } + +} diff --git a/OpenSim.Framework/Login.cs b/OpenSim.Framework/Login.cs new file mode 100644 index 0000000..8a67853 --- /dev/null +++ b/OpenSim.Framework/Login.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public class Login + { + public string First = "Test"; + public string Last = "User"; + public LLUUID Agent; + public LLUUID Session; + public LLUUID SecureSession = LLUUID.Zero; + public LLUUID InventoryFolder; + public LLUUID BaseFolder; + public Login() + { + + } + } +} diff --git a/OpenSim.Framework/LoginService.cs b/OpenSim.Framework/LoginService.cs new file mode 100644 index 0000000..eba0281 --- /dev/null +++ b/OpenSim.Framework/LoginService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Nwc.XmlRpc; +using libsecondlife; + +namespace OpenSim.Framework.Grid +{ + public abstract class LoginService + { + + } +} \ No newline at end of file diff --git a/OpenSim.Framework/NeighbourInfo.cs b/OpenSim.Framework/NeighbourInfo.cs new file mode 100644 index 0000000..8b4fa64 --- /dev/null +++ b/OpenSim.Framework/NeighbourInfo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Interfaces +{ + public class NeighbourInfo + { + public NeighbourInfo() + { + } + + public ulong regionhandle; + public uint RegionLocX; + public uint RegionLocY; + public string sim_ip; + public uint sim_port; + } +} diff --git a/OpenSim.Framework/OpenSim.Framework.csproj b/OpenSim.Framework/OpenSim.Framework.csproj new file mode 100644 index 0000000..7a10319 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.csproj @@ -0,0 +1,151 @@ + + + Local + 8.0.50727 + 2.0 + {1D2865A9-CF8E-45F7-B96D-91ED128A32CF} + Debug + AnyCPU + + + + OpenSim.Framework + JScript + Grid + IE50 + false + Library + + OpenSim.Framework + + + + + + 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 + + + + + \System.dll.dll + + + \System.Xml.dll.dll + + + \libsecondlife.dll.dll + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Framework/OpenSim.Framework.dll.build b/OpenSim.Framework/OpenSim.Framework.dll.build new file mode 100644 index 0000000..1418947 --- /dev/null +++ b/OpenSim.Framework/OpenSim.Framework.dll.build @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Framework/PrimData.cs b/OpenSim.Framework/PrimData.cs new file mode 100644 index 0000000..175a014 --- /dev/null +++ b/OpenSim.Framework/PrimData.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Assets +{ + public class PrimData + { + public LLUUID OwnerID; + public byte PCode; + public byte PathBegin; + public byte PathEnd; + public byte PathScaleX; + public byte PathScaleY; + public byte PathShearX; + public byte PathShearY; + public sbyte PathSkew; + public byte ProfileBegin; + public byte ProfileEnd; + public LLVector3 Scale; + public byte PathCurve; + public byte ProfileCurve; + public uint ParentID = 0; + public byte ProfileHollow; + public sbyte PathRadiusOffset; + public byte PathRevolutions; + public sbyte PathTaperX; + public sbyte PathTaperY; + public sbyte PathTwist; + public sbyte PathTwistBegin; + public byte[] Texture; + + //following only used during prim storage + public LLVector3 Position; + public LLQuaternion Rotation; + public uint LocalID; + public LLUUID FullID; + + public PrimData() + { + + } + } +} diff --git a/OpenSim.Framework/Properties/AssemblyInfo.cs b/OpenSim.Framework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..86f5cdb --- /dev/null +++ b/OpenSim.Framework/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("OpenSim.FrameWork")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.FrameWork")] +[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("a08e20c7-f191-4137-b1f0-9291408fa521")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Framework/RemoteGridBase.cs b/OpenSim.Framework/RemoteGridBase.cs new file mode 100644 index 0000000..6ca57df --- /dev/null +++ b/OpenSim.Framework/RemoteGridBase.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class RemoteGridBase : IGridServer + { + public abstract Dictionary agentcircuits + { + get; + set; + } + + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public abstract string GetName(); + public abstract bool RequestConnection(); + public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + public abstract void Close(); + } +} diff --git a/OpenSim.Framework/SimProfile.cs b/OpenSim.Framework/SimProfile.cs new file mode 100644 index 0000000..ac4cf9e --- /dev/null +++ b/OpenSim.Framework/SimProfile.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Xml; +using System.Text; +using libsecondlife; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Sims +{ + public class SimProfile : SimProfileBase + { + public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) + { + try + { + Hashtable GridReqParams = new Hashtable(); + GridReqParams["region_handle"] = region_handle.ToString(); + GridReqParams["caller"] = "userserver"; + GridReqParams["authkey"] = SendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(GridReqParams); + XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info", SendParams); + + XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000); + + Hashtable RespData = (Hashtable)GridResp.Value; + this.UUID = new LLUUID((string)RespData["UUID"]); + this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]); + this.regionname = (string)RespData["regionname"]; + this.sim_ip = (string)RespData["sim_ip"]; + this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]); + this.caps_url = (string)RespData["caps_url"]; + this.RegionLocX = (uint)Convert.ToUInt32(RespData["RegionLocX"]); + this.RegionLocY = (uint)Convert.ToUInt32(RespData["RegionLocY"]); + this.sendkey = (string)RespData["sendkey"]; + this.recvkey = (string)RespData["recvkey"]; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + return this; + } + + public SimProfile() + { + } + } + +} diff --git a/OpenSim.Framework/SimProfileBase.cs b/OpenSim.Framework/SimProfileBase.cs new file mode 100644 index 0000000..5fe2734 --- /dev/null +++ b/OpenSim.Framework/SimProfileBase.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Sims +{ + public class SimProfileBase + { + public LLUUID UUID; + public ulong regionhandle; + public string regionname; + public string sim_ip; + public uint sim_port; + public string caps_url; + public uint RegionLocX; + public uint RegionLocY; + public string sendkey; + public string recvkey; + + public SimProfileBase() + { + } + } +} diff --git a/OpenSim.Framework/UserProfile.cs b/OpenSim.Framework/UserProfile.cs new file mode 100644 index 0000000..2c264c5 --- /dev/null +++ b/OpenSim.Framework/UserProfile.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Framework.User +{ + public class UserProfile + { + + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + + public bool IsGridGod = false; + public bool IsLocal = true; // will be used in future for visitors from foreign grids + public string AssetURL; + public string MD5passwd; + + public LLUUID CurrentSessionID; + public LLUUID CurrentSecureSessionID; + public LLUUID UUID; + public Dictionary Circuits = new Dictionary(); // tracks circuit codes + + public AgentInventory Inventory; + + public UserProfile() + { + Circuits = new Dictionary(); + Inventory = new AgentInventory(); + homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ; + } + + public void InitSessionData() + { + CurrentSessionID = LLUUID.Random(); + CurrentSecureSessionID = LLUUID.Random(); + } + + public void AddSimCircuit(uint circuitCode, LLUUID regionUUID) + { + if (this.Circuits.ContainsKey(regionUUID) == false) + this.Circuits.Add(regionUUID, circuitCode); + } + + } +} diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs new file mode 100644 index 0000000..f77ca4c --- /dev/null +++ b/OpenSim.Framework/UserProfileManager.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using libsecondlife; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Framework.User +{ + public class UserProfileManager : UserProfileManagerBase + { + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string DefaultStartupMsg; + + public UserProfileManager() + { + + } + + public void SetKeys(string sendKey, string recvKey, string url, string message) + { + GridRecvKey = recvKey; + GridSendKey = sendKey; + GridURL = url; + DefaultStartupMsg = message; + } + + public virtual string ParseXMLRPC(string requestBody) + { + XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + + Hashtable requestData = (Hashtable)request.Params[0]; + switch (request.MethodName) + { + case "login_to_simulator": + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + string firstname = ""; + string lastname = ""; + string passwd = ""; + + if (GoodXML) + { + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + passwd = (string)requestData["passwd"]; + GoodLogin = AuthenticateUser(firstname, lastname, passwd); + } + + + if (!(GoodXML && GoodLogin)) + { + XmlRpcResponse LoginErrorResp = new XmlRpcResponse(); + Hashtable ErrorRespData = new Hashtable(); + ErrorRespData["reason"] = "key"; + ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; + ErrorRespData["login"] = "false"; + LoginErrorResp.Value = ErrorRespData; + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp), " encoding=\"utf-16\"", "")); + } + + UserProfile TheUser = GetProfileByName(firstname, lastname); + + if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) + { + XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); + Hashtable PresenceErrorRespData = new Hashtable(); + PresenceErrorRespData["reason"] = "presence"; + PresenceErrorRespData["message"] = "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"; + PresenceErrorRespData["login"] = "false"; + PresenceErrorResp.Value = PresenceErrorRespData; + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "")); + + } + + try + { + LLUUID AgentID = TheUser.UUID; + TheUser.InitSessionData(); + // SimProfile SimInfo = new SimProfile(); + // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + + XmlRpcResponse LoginGoodResp = new XmlRpcResponse(); + Hashtable LoginGoodData = new Hashtable(); + + Hashtable GlobalT = new Hashtable(); + GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; + GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + ArrayList GlobalTextures = new ArrayList(); + GlobalTextures.Add(GlobalT); + + Hashtable LoginFlagsHash = new Hashtable(); + LoginFlagsHash["daylight_savings"] = "N"; + LoginFlagsHash["stipend_since_login"] = "N"; + LoginFlagsHash["gendered"] = "Y"; + LoginFlagsHash["ever_logged_in"] = "Y"; + ArrayList LoginFlags = new ArrayList(); + LoginFlags.Add(LoginFlagsHash); + + Hashtable uiconfig = new Hashtable(); + uiconfig["allow_first_life"] = "Y"; + ArrayList ui_config = new ArrayList(); + ui_config.Add(uiconfig); + + Hashtable ClassifiedCategoriesHash = new Hashtable(); + ClassifiedCategoriesHash["category_name"] = "bla bla"; + ClassifiedCategoriesHash["category_id"] = (Int32)1; + ArrayList ClassifiedCategories = new ArrayList(); + ClassifiedCategories.Add(ClassifiedCategoriesHash); + + ArrayList AgentInventory = new ArrayList(); + foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) + { + Hashtable 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(); + AgentInventory.Add(TempHash); + } + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + ArrayList InitialOutfit = new ArrayList(); + InitialOutfit.Add(InitialOutfitHash); + + uint circode = (uint)(Util.RandomClass.Next()); + //TheUser.AddSimCircuit(circode, SimInfo.UUID); + + LoginGoodData["last_name"] = "\"" + TheUser.firstname + "\""; + LoginGoodData["ui-config"] = ui_config; + LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); + LoginGoodData["login-flags"] = LoginFlags; + LoginGoodData["global-textures"] = GlobalTextures; + LoginGoodData["classified_categories"] = ClassifiedCategories; + LoginGoodData["event_categories"] = new ArrayList(); + LoginGoodData["inventory-skeleton"] = AgentInventory; + LoginGoodData["inventory-skel-lib"] = new ArrayList(); + LoginGoodData["inventory-root"] = InventoryRoot; + LoginGoodData["event_notifications"] = new ArrayList(); + LoginGoodData["gestures"] = new ArrayList(); + LoginGoodData["inventory-lib-owner"] = new ArrayList(); + LoginGoodData["initial-outfit"] = InitialOutfit; + LoginGoodData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + LoginGoodData["start_location"] = "last"; + LoginGoodData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; + LoginGoodData["message"] = DefaultStartupMsg; + LoginGoodData["first_name"] = "\"" + firstname + "\""; + LoginGoodData["circuit_code"] = (Int32)circode; + LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; + LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); + LoginGoodData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; + LoginGoodData["agent_id"] = AgentID.ToStringHyphenated(); + LoginGoodData["region_y"] = (Int32) 996 * 256; // (Int32)SimInfo.RegionLocY * 256; + LoginGoodData["region_x"] = (Int32) 997 * 256; //SimInfo.RegionLocX * 256; + LoginGoodData["seed_capability"] = null; + LoginGoodData["agent_access"] = "M"; + LoginGoodData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); + LoginGoodData["login"] = "true"; + + this.CustomiseResponse(ref LoginGoodData, TheUser); + LoginGoodResp.Value = LoginGoodData; + //TheUser.SendDataToSim(SimInfo); + return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp), "utf-16", "utf-8")); + + } + catch (Exception E) + { + Console.WriteLine(E.ToString()); + } + + break; + } + + return ""; + } + + public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) + { + //default method set up to act as ogs user server + SimProfile SimInfo = new SimProfile(); + //get siminfo from grid server + SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); + uint circode = (uint)response["circuit_code"]; + theUser.AddSimCircuit(circode, SimInfo.UUID); + response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; + response["sim_ip"] = SimInfo.sim_ip.ToString(); + response["sim_port"] = (Int32)SimInfo.sim_port; + response["region_y"] = (Int32) SimInfo.RegionLocY * 256; + response["region_x"] = (Int32) SimInfo.RegionLocX * 256; + + //default is ogs user server, so let the sim know about the user via a XmlRpcRequest + Console.WriteLine(SimInfo.caps_url); + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.CurrentSessionID.ToString(); + SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString(); + SimParams["firstname"] = theUser.firstname; + SimParams["lastname"] = theUser.lastname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)theUser.Circuits[SimInfo.UUID]; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); + } + } +} diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs new file mode 100644 index 0000000..ad03bc2 --- /dev/null +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Framework.User +{ + public class UserProfileManagerBase + { + + public Dictionary UserProfiles = new Dictionary(); + + public UserProfileManagerBase() + { + } + + public virtual void InitUserProfiles() + { + // TODO: need to load from database + } + + public UserProfile GetProfileByName(string firstname, string lastname) + { + foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) + { + if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname)) + { + return UserProfiles[UUID]; + } + } + return null; + } + + public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) + { + return UserProfiles[ProfileLLUUID]; + } + + public virtual bool AuthenticateUser(string firstname, string lastname, string passwd) + { + UserProfile TheUser = GetProfileByName(firstname, lastname); + if (TheUser != null) + { + if (TheUser.MD5passwd == passwd) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + + } + + public void SetGod(LLUUID GodID) + { + this.UserProfiles[GodID].IsGridGod = true; + } + + public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) + { + UserProfile newprofile = new UserProfile(); + newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); + newprofile.firstname = firstname; + newprofile.lastname = lastname; + newprofile.MD5passwd = MD5passwd; + newprofile.UUID = LLUUID.Random(); + this.UserProfiles.Add(newprofile.UUID, newprofile); + return newprofile; + } + + public virtual AgentInventory GetUsersInventory(LLUUID agentID) + { + UserProfile user = this.GetProfileByLLUUID(agentID); + if (user != null) + { + return user.Inventory; + } + + return null; + } + + } +} diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs new file mode 100644 index 0000000..042360d --- /dev/null +++ b/OpenSim.Framework/Util.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenSim.Framework.Utilities +{ + public class Util + { + private static Random randomClass = new Random(); + + public static ulong UIntsToLong(uint X, uint Y) + { + return Helpers.UIntsToLong(X, Y); + } + + public static Random RandomClass + { + get + { + return randomClass; + } + } + + public Util() + { + + } + } + +} -- cgit v1.1