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 +++++++++++++++++++++- OpenSim/Framework/Data/UserProfileData.cs | 2 + OpenSim/Framework/General/AgentInventory.cs | 10 +--- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 13 ++++- OpenSim/Framework/General/NullClientAPI.cs | 8 ++- OpenSim/Framework/UserManager/UserManagerBase.cs | 3 +- 7 files changed, 100 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework') 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); } /// diff --git a/OpenSim/Framework/Data/UserProfileData.cs b/OpenSim/Framework/Data/UserProfileData.cs index 88f956f..67ff64c 100644 --- a/OpenSim/Framework/Data/UserProfileData.cs +++ b/OpenSim/Framework/Data/UserProfileData.cs @@ -81,6 +81,8 @@ namespace OpenSim.Framework.Data /// public int lastLogin; + public LLUUID rootInventoryFolderID; + /// /// A URI to the users inventory server, used for foreigners and large grids /// diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs index 0aeb0b3..4c80791 100644 --- a/OpenSim/Framework/General/AgentInventory.cs +++ b/OpenSim/Framework/General/AgentInventory.cs @@ -52,12 +52,11 @@ namespace OpenSim.Framework.Inventory public virtual void Initialise() { - Wearables = new AvatarWearable[13]; //should be 12 of these + Wearables = new AvatarWearable[13]; for (int i = 0; i < 13; i++) { Wearables[i] = new AvatarWearable(); } - } public bool CreateNewFolder(LLUUID folderID, ushort type) @@ -96,11 +95,10 @@ namespace OpenSim.Framework.Inventory 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) + public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID) { if (!this.InventoryFolders.ContainsKey(folderID)) { @@ -110,10 +108,9 @@ namespace OpenSim.Framework.Inventory Folder.OwnerID = this.AgentID; Folder.DefaultType = type; Folder.FolderName = folderName; - Folder.ParentID = parent; + Folder.ParentID = parentID; this.InventoryFolders.Add(Folder.FolderID, Folder); } - return (true); } @@ -135,7 +132,6 @@ namespace OpenSim.Framework.Inventory return inv.FolderID; } } - return LLUUID.Zero; } diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 808a857..df65027 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -80,7 +80,10 @@ namespace OpenSim.Framework.Interfaces public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape); - + public delegate void CreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); + public delegate void FetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); + + public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID); public interface IClientAPI { @@ -125,6 +128,10 @@ namespace OpenSim.Framework.Interfaces event NewAvatar OnNewAvatar; event GenericCall6 OnRemoveAvatar; + event CreateInventoryFolder OnCreateNewInventoryFolder; + event FetchInventoryDescendents OnFetchInventoryDescendents; + event RequestTaskInventory OnRequestTaskInventory; + event UUIDNameRequest OnNameFromUUIDRequest; event ParcelPropertiesRequest OnParcelPropertiesRequest; @@ -188,8 +195,10 @@ namespace OpenSim.Framework.Interfaces void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items); void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item); - void SendNameReply(LLUUID profileId, string firstname, string lastname); + void SendInventoryItemUpdate(InventoryItemBase Item); + void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName); + void SendNameReply(LLUUID profileId, string firstname, string lastname); void SendAlertMessage(string message); void SendAgentAlertMessage(string message, bool modal); } diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs index cfba228..18ac527 100644 --- a/OpenSim/Framework/General/NullClientAPI.cs +++ b/OpenSim/Framework/General/NullClientAPI.cs @@ -52,6 +52,10 @@ namespace OpenSim.Framework public event NewAvatar OnNewAvatar; public event GenericCall6 OnRemoveAvatar; + public event CreateInventoryFolder OnCreateNewInventoryFolder; + public event FetchInventoryDescendents OnFetchInventoryDescendents; + public event RequestTaskInventory OnRequestTaskInventory; + public event UUIDNameRequest OnNameFromUUIDRequest; public event ParcelPropertiesRequest OnParcelPropertiesRequest; @@ -124,8 +128,10 @@ namespace OpenSim.Framework public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items){} public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item){} - public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){} + public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { } + public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { } + public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){} public void SendAlertMessage(string message) { } public void SendAgentAlertMessage(string message, bool modal) { } } diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index 865adbe..c614300 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -417,7 +417,7 @@ namespace OpenSim.Framework.UserManagement Hashtable TempHash; AgentInventory Library = new AgentInventory(); - Library.CreateRootFolder(AgentID, true); + Library.CreateRootFolder(AgentID, false); foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values) { @@ -434,6 +434,7 @@ namespace OpenSim.Framework.UserManagement InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); + userProfile.rootInventoryFolderID = Library.InventoryRoot.FolderID; // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); -- cgit v1.1