From 35fa85069e792579ebd44a974053d6dce288ea0a Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 28 Mar 2007 18:10:52 +0000 Subject: After hours of searching for a bug, it works - User accounts in sandbox mode, currently they are not persistent between restarts (ie restarting opensim.exe) but should be persistent between sessions (login/ logout). Use the -account command line arg to enable them and then create new accounts through the web interface --- OpenSim.Framework/AgentInventory.cs | 59 +++++++++++++++++++++++++++-- OpenSim.Framework/IUserServer.cs | 1 + OpenSim.Framework/UserProfile.cs | 1 + OpenSim.Framework/UserProfileManager.cs | 12 +++--- OpenSim.Framework/UserProfileManagerBase.cs | 6 +++ 5 files changed, 71 insertions(+), 8 deletions(-) (limited to 'OpenSim.Framework') diff --git a/OpenSim.Framework/AgentInventory.cs b/OpenSim.Framework/AgentInventory.cs index 8ab2f3a..1abf59a 100644 --- a/OpenSim.Framework/AgentInventory.cs +++ b/OpenSim.Framework/AgentInventory.cs @@ -11,7 +11,7 @@ namespace OpenSim.Framework.Inventory //Holds the local copy of Inventory info for a agent public Dictionary InventoryFolders; public Dictionary InventoryItems; - public InventoryFolder InventoryRoot; + public InventoryFolder InventoryRoot = new InventoryFolder(); public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server public LLUUID AgentID; public AvatarWearable[] Wearables; @@ -30,14 +30,16 @@ namespace OpenSim.Framework.Inventory { Wearables[i] = new AvatarWearable(); } - + InventoryRoot = new InventoryFolder(); InventoryRoot.FolderID = LLUUID.Random(); InventoryRoot.ParentID = new LLUUID(); InventoryRoot.Version = 1; InventoryRoot.DefaultType = 8; + InventoryRoot.OwnerID = this.AgentID; InventoryRoot.FolderName = "My Inventory"; InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); + } public bool CreateNewFolder(LLUUID folderID, ushort type) @@ -47,10 +49,61 @@ namespace OpenSim.Framework.Inventory Folder.OwnerID = this.AgentID; Folder.DefaultType = type; this.InventoryFolders.Add(Folder.FolderID, Folder); + return (true); + } + + public void CreateRootFolder(LLUUID newAgentID, bool createTextures) + { + this.AgentID = newAgentID; + /* InventoryRoot = new InventoryFolder(); + InventoryRoot.FolderID = LLUUID.Random(); + InventoryRoot.ParentID = new LLUUID(); + InventoryRoot.Version = 1; + InventoryRoot.DefaultType = 8; + InventoryRoot.OwnerID = this.AgentID; + InventoryRoot.FolderName = "My Inventory-"; + InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);*/ + InventoryRoot.OwnerID = this.AgentID; + if (createTextures) + { + this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); + } + } + + public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + Folder.DefaultType = type; + Folder.FolderName = folderName; + this.InventoryFolders.Add(Folder.FolderID, Folder); + + return (true); + } + + public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent) + { + InventoryFolder Folder = new InventoryFolder(); + Folder.FolderID = folderID; + Folder.OwnerID = this.AgentID; + Folder.DefaultType = type; + Folder.FolderName = folderName; + Folder.ParentID = parent; + this.InventoryFolders.Add(Folder.FolderID, Folder); return (true); } + public bool HasFolder(LLUUID folderID) + { + if (this.InventoryFolders.ContainsKey(folderID)) + { + return true; + } + return false; + } + public bool UpdateItem(LLUUID itemID, AssetBase asset) { if(this.InventoryItems.ContainsKey(itemID)) @@ -96,7 +149,7 @@ namespace OpenSim.Framework.Inventory //public List Subfolders; public LLUUID FolderID; public LLUUID OwnerID; - public LLUUID ParentID; + public LLUUID ParentID = LLUUID.Zero; public string FolderName; public ushort DefaultType; public ushort Version; diff --git a/OpenSim.Framework/IUserServer.cs b/OpenSim.Framework/IUserServer.cs index bb2b668..21f2721 100644 --- a/OpenSim.Framework/IUserServer.cs +++ b/OpenSim.Framework/IUserServer.cs @@ -10,5 +10,6 @@ namespace OpenSim.Framework.Interfaces { AgentInventory RequestAgentsInventory(LLUUID agentID); void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory); } } diff --git a/OpenSim.Framework/UserProfile.cs b/OpenSim.Framework/UserProfile.cs index 2c264c5..215f7da 100644 --- a/OpenSim.Framework/UserProfile.cs +++ b/OpenSim.Framework/UserProfile.cs @@ -32,6 +32,7 @@ namespace OpenSim.Framework.User Circuits = new Dictionary(); Inventory = new AgentInventory(); homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256)); ; + } public void InitSessionData() diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs index f77ca4c..d6304d0 100644 --- a/OpenSim.Framework/UserProfileManager.cs +++ b/OpenSim.Framework/UserProfileManager.cs @@ -68,6 +68,7 @@ namespace OpenSim.Framework.User UserProfile TheUser = GetProfileByName(firstname, lastname); + /* if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) { XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); @@ -78,7 +79,7 @@ namespace OpenSim.Framework.User PresenceErrorResp.Value = PresenceErrorRespData; return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "")); - } + }*/ try { @@ -116,6 +117,7 @@ namespace OpenSim.Framework.User ArrayList ClassifiedCategories = new ArrayList(); ClassifiedCategories.Add(ClassifiedCategoriesHash); + Console.WriteLine("copying inventory data to response"); ArrayList AgentInventory = new ArrayList(); foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) { @@ -142,7 +144,7 @@ namespace OpenSim.Framework.User uint circode = (uint)(Util.RandomClass.Next()); //TheUser.AddSimCircuit(circode, SimInfo.UUID); - LoginGoodData["last_name"] = "\"" + TheUser.firstname + "\""; + LoginGoodData["last_name"] = "\"" + TheUser.lastname + "\""; LoginGoodData["ui-config"] = ui_config; LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); LoginGoodData["login-flags"] = LoginFlags; @@ -160,7 +162,7 @@ namespace OpenSim.Framework.User 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["first_name"] = "\"" + TheUser.firstname + "\""; LoginGoodData["circuit_code"] = (Int32)circode; LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); @@ -196,8 +198,8 @@ namespace OpenSim.Framework.User 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); + Int32 circode = (Int32)response["circuit_code"]; + theUser.AddSimCircuit((uint)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; diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs index ad03bc2..218a98c 100644 --- a/OpenSim.Framework/UserProfileManagerBase.cs +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -41,19 +41,23 @@ namespace OpenSim.Framework.User public virtual bool AuthenticateUser(string firstname, string lastname, string passwd) { UserProfile TheUser = GetProfileByName(firstname, lastname); + passwd = passwd.Remove(0, 3); //remove $1$ if (TheUser != null) { if (TheUser.MD5passwd == passwd) { + Console.WriteLine("UserProfile - authorised "); return true; } else { + Console.WriteLine("UserProfile - not authorised, password not match "+ TheUser.MD5passwd +" and "+ passwd); return false; } } else { + Console.WriteLine("UserProfile - not authorised , unkown: "+ firstname +" , " + lastname); return false; } @@ -66,12 +70,14 @@ namespace OpenSim.Framework.User public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) { + Console.WriteLine("creating new profile for : " + firstname + " , " + lastname); 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(); + newprofile.Inventory.CreateRootFolder(newprofile.UUID, true); this.UserProfiles.Add(newprofile.UUID, newprofile); return newprofile; } -- cgit v1.1