From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- .../Services/InventoryService/XInventoryService.cs | 172 +++++++++++---------- 1 file changed, 93 insertions(+), 79 deletions(-) (limited to 'OpenSim/Services/InventoryService/XInventoryService.cs') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 7bad4b0..b75193f 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -111,40 +111,48 @@ namespace OpenSim.Services.InventoryService if (rootFolder == null) { - rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)AssetType.RootFolder, "My Inventory")); + rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)FolderType.Root, InventoryFolderBase.ROOT_FOLDER_NAME)); result = true; } XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootFolder.ID); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.LostAndFoundFolder, "Lost And Found"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Notecard, "Notecards"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Object, "Objects"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.SnapshotFolder, "Photo Album"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.LSLText, "Scripts"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Sound, "Sounds"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.Texture, "Textures"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.TrashFolder, "Trash"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Animation) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Animation, "Animations"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.BodyPart) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.BodyPart, "Body Parts"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CallingCard) return true; return false; })) + { + XInventoryFolder folder = CreateFolder(principalID, rootFolder.ID, (int)FolderType.CallingCard, "Calling Cards"); + folder = CreateFolder(principalID, folder.folderID, (int)FolderType.CallingCard, "Friends"); + CreateFolder(principalID, folder.folderID, (int)FolderType.CallingCard, "All"); + } + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Clothing) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Clothing, "Clothing"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CurrentOutfit) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.CurrentOutfit, "Current Outfit"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Favorites) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Favorites, "Favorites"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Gesture) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Gesture, "Gestures"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Landmark) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Landmark, "Landmarks"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LostAndFound) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.LostAndFound, "Lost And Found"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Notecard) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Notecard, "Notecards"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Object) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Object, "Objects"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Snapshot) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Snapshot, "Photo Album"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LSLText) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.LSLText, "Scripts"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Sound) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Sound, "Sounds"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Texture) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Texture, "Textures"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Trash) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)FolderType.Trash, "Trash"); return result; } @@ -220,7 +228,7 @@ namespace OpenSim.Services.InventoryService XInventoryFolder root = null; foreach (XInventoryFolder folder in folders) { - if (folder.folderName == "My Inventory") + if (folder.folderName == InventoryFolderBase.ROOT_FOLDER_NAME) { root = folder; break; @@ -233,7 +241,7 @@ namespace OpenSim.Services.InventoryService return ConvertToOpenSim(root); } - public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) + public virtual InventoryFolderBase GetFolderForType(UUID principalID, FolderType type) { // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); @@ -251,11 +259,11 @@ namespace OpenSim.Services.InventoryService return GetSystemFolderForType(rootFolder, type); } - private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type) + private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, FolderType type) { -// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); - - if (type == AssetType.RootFolder) + //m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0}", type); + + if (type == FolderType.Root) return rootFolder; XInventoryFolder[] folders = m_Database.GetFolders( @@ -264,13 +272,13 @@ namespace OpenSim.Services.InventoryService if (folders.Length == 0) { -// m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID); + //m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} ", type); return null; } - -// m_log.DebugFormat( -// "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}", -// folders[0].folderName, folders[0].folderID, type, principalID); + + //m_log.DebugFormat( + // "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2}", + // folders[0].folderName, folders[0].folderID, type); return ConvertToOpenSim(folders[0]); } @@ -283,7 +291,7 @@ namespace OpenSim.Services.InventoryService // //m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString()); InventoryCollection inventory = new InventoryCollection(); - inventory.UserID = principalID; + inventory.OwnerID = principalID; inventory.Folders = new List(); inventory.Items = new List(); @@ -307,8 +315,27 @@ namespace OpenSim.Services.InventoryService inventory.Items.Add(ConvertToOpenSim(i)); } + InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); + f = GetFolder(f); + if (f != null) + { + inventory.Version = f.Version; + inventory.OwnerID = f.Owner; + } + inventory.FolderID = folderID; + return inventory; } + + public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) + { + InventoryCollection[] multiple = new InventoryCollection[folderIDs.Length]; + int i = 0; + foreach (UUID fid in folderIDs) + multiple[i++] = GetFolderContent(principalID, fid); + + return multiple; + } public virtual List GetFolderItems(UUID principalID, UUID folderID) { @@ -336,7 +363,7 @@ namespace OpenSim.Services.InventoryService if (check != null) return false; - if (folder.Type != (short)AssetType.Folder && folder.Type != (short)AssetType.Unknown) + if (folder.Type != (short)FolderType.None) { InventoryFolderBase rootFolder = GetRootFolder(folder.Owner); @@ -353,7 +380,7 @@ namespace OpenSim.Services.InventoryService if (folder.ParentID == rootFolder.ID) { InventoryFolderBase existingSystemFolder - = GetSystemFolderForType(rootFolder, (AssetType)folder.Type); + = GetSystemFolderForType(rootFolder, (FolderType)folder.Type); if (existingSystemFolder != null) { @@ -380,8 +407,8 @@ namespace OpenSim.Services.InventoryService if (check == null) return AddFolder(folder); - if ((check.Type != (short)AssetType.Unknown || xFolder.type != (short)AssetType.Unknown) - && (check.Type != (short)AssetType.OutfitFolder || xFolder.type != (short)AssetType.OutfitFolder)) + if ((check.Type != (short)FolderType.None || xFolder.type != (short)FolderType.None) + && (check.Type != (short)FolderType.Outfit || xFolder.type != (short)FolderType.Outfit)) { if (xFolder.version < check.Version) { @@ -583,6 +610,21 @@ namespace OpenSim.Services.InventoryService return ConvertToOpenSim(items[0]); } + public virtual InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] ids) + { + InventoryItemBase[] items = new InventoryItemBase[ids.Length]; + int i = 0; + InventoryItemBase item = new InventoryItemBase(); + item.Owner = userID; + foreach (UUID id in ids) + { + item.ID = id; + items[i++] = GetItem(item); + } + + return items; + } + public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) { XInventoryFolder[] folders = m_Database.GetFolders( @@ -615,34 +657,6 @@ namespace OpenSim.Services.InventoryService return m_Database.GetAssetPermissions(principalID, assetID); } - public virtual InventoryCollection GetUserInventory(UUID userID) - { - InventoryCollection userInventory = new InventoryCollection(); - userInventory.UserID = userID; - userInventory.Folders = new List(); - userInventory.Items = new List(); - - List skel = GetInventorySkeleton(userID); - if (skel != null) - { - foreach (InventoryFolderBase f in skel) - { - InventoryCollection c = GetFolderContent(userID, f.ID); - if (c != null && c.Items != null && c.Items.Count > 0) - userInventory.Items.AddRange(c.Items); - if (c != null && c.Folders != null && c.Folders.Count > 0) - userInventory.Folders.AddRange(c.Folders); - } - } - m_log.DebugFormat("[XINVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", - userID, userInventory.Folders.Count, userInventory.Items.Count); - return userInventory; - } - - public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) - { - } - // Unused. // public bool HasInventoryForUser(UUID userID) @@ -658,9 +672,9 @@ namespace OpenSim.Services.InventoryService newFolder.ParentID = folder.parentFolderID; newFolder.Type = (short)folder.type; - // Viewer can't understand anything that's not in it's LLFolderType enum - if (newFolder.Type == 100) - newFolder.Type = -1; + //// Viewer can't understand anything that's not in it's LLFolderType enum + //if (newFolder.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + // newFolder.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; newFolder.Version = (ushort)folder.version; newFolder.Name = folder.folderName; newFolder.Owner = folder.agentID; @@ -751,7 +765,7 @@ namespace OpenSim.Services.InventoryService if (folder.Length < 1) return false; - if (folder[0].type == (int)AssetType.TrashFolder) + if (folder[0].type == (int)FolderType.Trash) return true; UUID parentFolder = folder[0].parentFolderID; @@ -762,9 +776,9 @@ namespace OpenSim.Services.InventoryService if (parent.Length < 1) return false; - if (parent[0].type == (int)AssetType.TrashFolder) + if (parent[0].type == (int)FolderType.Trash) return true; - if (parent[0].type == (int)AssetType.RootFolder) + if (parent[0].type == (int)FolderType.Root) return false; parentFolder = parent[0].parentFolderID; -- cgit v1.1