void PrintFolder(InventoryNode f, StringBuilder result, int indent) { foreach ( InventoryNode i in f.Nodes.Values ) { result.Append(i.Data.Name + "\n"); if ( i.Nodes.Count > 0 ) PrintFolder(i, result, indent + 1); } }
public InventoryNode(InventoryBase data, InventoryNode parent) { this.data = data; this.parent = parent; if (parent != null) { // Add this node to the collection of parent nodes lock (parent.Nodes.SyncRoot) parent.Nodes.Add(data.UUID, this); } }
/// <summary> /// BackupFolder - recurse through the inventory nodes sending scripts and notecards to the transfer queue /// </summary> /// <param name="folder">The current leaf in the inventory tree</param> /// <param name="sPathSoFar">path so far, in the form @"c:\here" -- this needs to be "clean" for the current filesystem</param> private void BackupFolder(InventoryNode folder, string sPathSoFar) { StringBuilder sbRequests = new StringBuilder(); // FIXME: //Client.Inventory.RequestFolderContents(folder.Data.UUID, Client.Self.AgentID, true, true, false, // InventorySortOrder.ByName); // first scan this folder for text foreach (InventoryNode iNode in folder.Nodes.Values) { if (BackupWorker.CancellationPending) return; if (iNode.Data is libsecondlife.InventoryItem) { InventoryItem ii = iNode.Data as InventoryItem; if (ii.AssetType == AssetType.LSLText || ii.AssetType == AssetType.Notecard) { // check permissions on scripts if (ii.AssetType == AssetType.LSLText) { if ((ii.Permissions.OwnerMask & PermissionMask.Modify) == PermissionMask.None) { // skip this one continue; } } string sExtension = (ii.AssetType == AssetType.LSLText) ? ".lsl" : ".txt"; // make the output file string sPath = sPathSoFar + @"\" + MakeValid(ii.Name.Trim()) + sExtension; // create the new qdi QueuedDownloadInfo qdi = new QueuedDownloadInfo(sPath, ii.AssetUUID, iNode.Data.UUID, LLUUID.Zero, Client.Self.AgentID, ii.AssetType); // add it to the queue lock (PendingDownloads) { TextItemsFound++; PendingDownloads.Enqueue(qdi); } } } } // now run any subfolders foreach (InventoryNode i in folder.Nodes.Values) { if (BackupWorker.CancellationPending) return; else if (i.Data is libsecondlife.InventoryFolder) BackupFolder(i, sPathSoFar + @"\" + MakeValid(i.Data.Name.Trim())); } }
/// <summary> /// Updates the state of the InventoryNode and inventory data structure that /// is responsible for the InventoryObject. If the item was previously not added to inventory, /// it adds the item, and updates structure accordingly. If it was, it updates the /// InventoryNode, changing the parent node if <code>item.parentUUID</code> does /// not match <code>node.Parent.Data.UUID</code>. /// /// You can not set the inventory root folder using this method /// </summary> /// <param name="item">The InventoryObject to store</param> public void UpdateNodeFor(InventoryBase item) { lock (Items) { InventoryNode itemParent = null; if (item.ParentUUID != LLUUID.Zero && !Items.TryGetValue(item.ParentUUID, out itemParent)) { // OK, we have no data on the parent, let's create a fake one. InventoryFolder fakeParent = new InventoryFolder(item.ParentUUID); fakeParent.DescendentCount = 1; // Dear god, please forgive me. itemParent = new InventoryNode(fakeParent); Items[item.ParentUUID] = itemParent; // Unfortunately, this breaks the nice unified tree // while we're waiting for the parent's data to come in. // As soon as we get the parent, the tree repairs itself. Client.DebugLog("Attempting to update inventory child of " + item.ParentUUID.ToString() + " when we have no local reference to that folder"); if (Client.Settings.FETCH_MISSING_INVENTORY) { // Fetch the parent List<LLUUID> fetchreq = new List<LLUUID>(1); fetchreq.Add(item.ParentUUID); //Manager.FetchInventory(fetchreq); // we cant fetch folder data! :-O } } InventoryNode itemNode; if (Items.TryGetValue(item.UUID, out itemNode)) // We're updating. { InventoryNode oldParent = itemNode.Parent; // Handle parent change if (oldParent == null || itemParent == null || itemParent.Data.UUID != oldParent.Data.UUID) { if (oldParent != null) { lock (oldParent.Nodes.SyncRoot) oldParent.Nodes.Remove(item.UUID); } if (itemParent != null) { lock (itemParent.Nodes.SyncRoot) itemParent.Nodes[item.UUID] = itemNode; } } itemNode.Parent = itemParent; if (item != itemNode.Data) FireOnInventoryObjectUpdated(itemNode.Data, item); itemNode.Data = item; } else // We're adding. { itemNode = new InventoryNode(item, itemParent); Items.Add(item.UUID, itemNode); } } }
public void Add(LLUUID key, InventoryNode value) { value.Parent = parent; lock (syncRoot) this.Dictionary.Add(key, value); }
public InventoryNodeDictionary(InventoryNode parentNode) { parent = parentNode; }
/// <summary> /// Updates the state of the InventoryNode and inventory data structure that /// is responsible for the InventoryObject. If the item was previously not added to inventory, /// it adds the item, and updates structure accordingly. If it was, it updates the /// InventoryNode, changing the parent node if <code>item.parentUUID</code> does /// not match <code>node.Parent.Data.UUID</code>. /// /// You can not set the inventory root folder using this method /// </summary> /// <param name="item">The InventoryObject to store</param> public void UpdateNodeFor(InventoryBase item) { lock (Items) { InventoryNode itemParent = null; if (item.ParentUUID != LLUUID.Zero && !Items.TryGetValue(item.ParentUUID, out itemParent)) { // OK, we have no data on the parent, let's create a fake one. InventoryFolder fakeParent = new InventoryFolder(item.ParentUUID); fakeParent.DescendentCount = 1; // Dear god, please forgive me. itemParent = new InventoryNode(fakeParent); Items[item.ParentUUID] = itemParent; // Unfortunately, this breaks the nice unified tree // while we're waiting for the parent's data to come in. // As soon as we get the parent, the tree repairs itself. Client.DebugLog("Attempting to update inventory child of " + item.ParentUUID.ToString() + " when we have no local reference to that folder"); if (Client.Settings.FETCH_MISSING_INVENTORY) { // Fetch the parent List <LLUUID> fetchreq = new List <LLUUID>(1); fetchreq.Add(item.ParentUUID); //Manager.FetchInventory(fetchreq); // we cant fetch folder data! :-O } } InventoryNode itemNode; if (Items.TryGetValue(item.UUID, out itemNode)) // We're updating. { InventoryNode oldParent = itemNode.Parent; // Handle parent change if (oldParent == null || itemParent == null || itemParent.Data.UUID != oldParent.Data.UUID) { if (oldParent != null) { lock (oldParent.Nodes.SyncRoot) oldParent.Nodes.Remove(item.UUID); } if (itemParent != null) { lock (itemParent.Nodes.SyncRoot) itemParent.Nodes[item.UUID] = itemNode; } } itemNode.Parent = itemParent; if (item != itemNode.Data) { FireOnInventoryObjectUpdated(itemNode.Data, item); } itemNode.Data = item; } else // We're adding. { itemNode = new InventoryNode(item, itemParent); Items.Add(item.UUID, itemNode); } } }
public void Add(LLUUID key, InventoryNode value) { value.Parent = parent; lock (syncRoot) this.Dictionary.Add(key, value); }
public InventoryNodeDictionary(InventoryNode parentNode) { parent = parentNode; }