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/caches/CachedUserInfo.cs | 77 +++++++++++++++ .../Communications/caches/InventoryFolder.cs | 51 ++++++++++ .../Communications/caches/UserProfileCache.cs | 107 +++++++++++++++++++++ 3 files changed, 235 insertions(+) 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/caches') 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