/// <summary> /// Tell the client about the various child items and folders contained in the requested folder. /// </summary> /// <param name="remoteClient"></param> /// <param name="folderID"></param> /// <param name="ownerID"></param> /// <param name="fetchFolders"></param> /// <param name="fetchItems"></param> /// <param name="sortOrder"></param> public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // TODO: This code for looking in the folder for the library should be folded back into the // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold = null; if ((fold = CommsManager.LibraryRoot.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( fold.Owner, fold, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } CachedUserInfo userProfile = CommsManager.UserService.GetUserDetails(remoteClient.AgentId); if (null == userProfile) { m_log.ErrorFormat( "[AGENT INVENTORY]: Could not find user profile for {0} {1}", remoteClient.Name, remoteClient.AgentId); return; } userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems); }
/// <summary> /// Gets everything (folders and items) inside a folder /// </summary> /// <param name="userId"></param> /// <param name="folderID"></param> /// <returns></returns> public InventoryCollection GetFolderContent(UUID userID, UUID folderID) { InventoryFolderImpl folder = null; InventoryCollection inv = new InventoryCollection(); inv.UserID = m_Library.Owner; if (folderID != m_Library.ID) { folder = m_Library.FindFolder(folderID); if (folder == null) { inv.Folders = new List <InventoryFolderBase>(); inv.Items = new List <InventoryItemBase>(); return(inv); } } else { folder = m_Library; } inv.Folders = folder.RequestListOfFolders(); inv.Items = folder.RequestListOfItems(); m_log.DebugFormat("[LIBRARY MODULE]: Got content for folder {0}", folder.Name); return(inv); }
/// <summary> /// Tell the client about the various child items and folders contained in the requested folder. /// </summary> /// <param name="remoteClient"></param> /// <param name="folderID"></param> /// <param name="ownerID"></param> /// <param name="fetchFolders"></param> /// <param name="fetchItems"></param> /// <param name="sortOrder"></param> public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // FIXME MAYBE: We're not handling sortOrder! // TODO: This code for looking in the folder for the library should be folded somewhere else // so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold = null; if (LibraryService != null && LibraryService.LibraryRootFolder != null) { if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( fold.Owner, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); return; } } // We're going to send the reply async, because there may be // an enormous quantity of packets -- basically the entire inventory! // We don't want to block the client thread while all that is happening. SendInventoryDelegate d = SendInventoryAsync; d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); }
/// <summary> /// Tell the client about the various child items and folders contained in the requested folder. /// </summary> /// <param name="remoteClient"></param> /// <param name="folderID"></param> /// <param name="ownerID"></param> /// <param name="fetchFolders"></param> /// <param name="fetchItems"></param> /// <param name="sortOrder"></param> public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // m_log.DebugFormat( // "[USER INVENTORY]: HandleFetchInventoryDescendents() for {0}, folder={1}, fetchFolders={2}, fetchItems={3}, sortOrder={4}", // remoteClient.Name, folderID, fetchFolders, fetchItems, sortOrder); if (folderID == UUID.Zero) { return; } // FIXME MAYBE: We're not handling sortOrder! // TODO: This code for looking in the folder for the library should be folded somewhere else // so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold = null; if (LibraryService != null && LibraryService.LibraryRootFolder != null) { if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( fold.Owner, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); return; } } lock (m_descendentsRequestLock) { if (!m_descendentsRequestProcessing) { m_descendentsRequestProcessing = true; // We're going to send the reply async, because there may be // an enormous quantity of packets -- basically the entire inventory! // We don't want to block the client thread while all that is happening. SendInventoryDelegate d = SendInventoryAsync; d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); return; } DescendentsRequestData req = new DescendentsRequestData(); req.RemoteClient = remoteClient; req.FolderID = folderID; req.OwnerID = ownerID; req.FetchFolders = fetchFolders; req.FetchItems = fetchItems; req.SortOrder = sortOrder; m_descendentsRequestQueue.Enqueue(req); } }
public void AddToDefaultInventory(InventoryFolderImpl folder) { foreach (InventoryFolderImpl f in folder.RequestListOfFolderImpls()) { m_LibraryRootFolder.AddChildFolder(f); } foreach (InventoryItemBase i in folder.RequestListOfItems()) { m_LibraryRootFolder.Items.Add(i.ID, i); } }
/// <summary> /// Tell the client about the various child items and folders contained in the requested folder. /// </summary> /// <param name="remoteClient"></param> /// <param name="folderID"></param> /// <param name="ownerID"></param> /// <param name="fetchFolders"></param> /// <param name="fetchItems"></param> /// <param name="sortOrder"></param> public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // m_log.DebugFormat( // "[USER INVENTORY]: HandleFetchInventoryDescendents() for {0}, folder={1}, fetchFolders={2}, fetchItems={3}, sortOrder={4}", // remoteClient.Name, folderID, fetchFolders, fetchItems, sortOrder); if (folderID == UUID.Zero) { return; } // FIXME MAYBE: We're not handling sortOrder! // TODO: This code for looking in the folder for the library should be folded somewhere else // so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold = null; if (LibraryService != null && LibraryService.LibraryRootFolder != null) { if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) { List <InventoryItemBase> its = fold.RequestListOfItems(); List <InventoryFolderBase> fds = fold.RequestListOfFolders(); remoteClient.SendInventoryFolderDetails( fold.Owner, folderID, its, fds, fold.Version, its.Count + fds.Count, fetchFolders, fetchItems); return; } } DescendentsRequestData req = new DescendentsRequestData(); req.RemoteClient = remoteClient; req.FolderID = folderID; //req.OwnerID = ownerID; req.FetchFolders = fetchFolders; req.FetchItems = fetchItems; //req.SortOrder = sortOrder; m_descendentsRequestQueue.Enqueue(req); if (Monitor.TryEnter(m_descendentsRequestLock)) { if (!m_descendentsRequestProcessing) { m_descendentsRequestProcessing = true; Util.FireAndForget(x => SendInventoryAsync()); } Monitor.Exit(m_descendentsRequestLock); } }
/// <summary> /// Save an inventory folder /// </summary> /// <param name="inventoryFolder">The inventory folder to save</param> /// <param name="path">The path to which the folder should be saved</param> /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself) { if (saveThisFolderItself) { path += string.Format( "{0}{1}{2}/", inventoryFolder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, inventoryFolder.ID); // We need to make sure that we record empty folders m_archiveWriter.WriteDir(path); } List <InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); List <InventoryItemBase> items = inventoryFolder.RequestListOfItems(); /* * Dictionary identicalFolderNames = new Dictionary<string, int>(); * * foreach (InventoryFolderImpl folder in inventories) * { * * if (!identicalFolderNames.ContainsKey(folder.Name)) * identicalFolderNames[folder.Name] = 0; * else * identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; * * int folderNameNumber = identicalFolderName[folder.Name]; * * SaveInvDir( * folder, * string.Format( * "{0}{1}{2}/", * path, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); * } */ foreach (InventoryFolderImpl childFolder in childFolders) { SaveInvFolder(childFolder, path, true); } foreach (InventoryItemBase item in items) { SaveInvItem(item, path); } }
/// <summary> /// Add the folders to the user's inventory /// </summary> /// <param name="m_MockScene"></param> /// <param name="folder"></param> private void BuildInventoryFolder(Scene m_MockScene, InventoryFolderImpl folder) { InventoryFolderBase folderBase = new InventoryFolderBase(); folderBase.ID = folder.ID; folderBase.Name = folder.Name; folderBase.Owner = folder.Owner; folderBase.ParentID = folder.ParentID; folderBase.Type = folder.Type; folderBase.Version = folder.Version; m_MockScene.InventoryService.AddFolder(folderBase); foreach (InventoryFolderImpl childFolder in folder.RequestListOfFolderImpls()) { BuildInventoryFolder(m_MockScene, childFolder); } foreach (InventoryItemBase item in folder.RequestListOfItems()) { m_MockScene.InventoryService.AddItem(item); } }