aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/caches/InventoryFolder.cs
blob: 8978ceea0af126f1603be7f4f7fe41be66998e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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<LLUUID, InventoryFolder> SubFolders = new Dictionary<LLUUID, InventoryFolder>();
        public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();

        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;
        }

        public List<InventoryItemBase> RequestListOfItems()
        {
            List<InventoryItemBase> itemList = new List<InventoryItemBase>();
            foreach (InventoryItemBase item in this.Items.Values)
            {
                itemList.Add(item);
            }
            return itemList;
        }
    }
}