aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
diff options
context:
space:
mode:
authorMW2007-12-02 13:59:15 +0000
committerMW2007-12-02 13:59:15 +0000
commit80609c2b1572d9b946675db486fc46e327171cfa (patch)
tree85a623c1a75255d74883c3f9ba11e5f66a053a18 /OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
parentNew Inventory folder should now be stored to the inventory server/database. T... (diff)
downloadopensim-SC-80609c2b1572d9b946675db486fc46e327171cfa.zip
opensim-SC-80609c2b1572d9b946675db486fc46e327171cfa.tar.gz
opensim-SC-80609c2b1572d9b946675db486fc46e327171cfa.tar.bz2
opensim-SC-80609c2b1572d9b946675db486fc46e327171cfa.tar.xz
Some refactoring , mainly on Inventory code.
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs146
1 files changed, 146 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
new file mode 100644
index 0000000..fd029cd
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -0,0 +1,146 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System.Collections.Generic;
29using libsecondlife;
30
31namespace OpenSim.Framework.Communications.Cache
32{
33 public class InventoryFolderImpl : InventoryFolderBase
34 {
35 // Fields
36 public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
37 public Dictionary<LLUUID, InventoryFolderImpl> SubFolders = new Dictionary<LLUUID, InventoryFolderImpl>();
38
39 // Accessors
40 public int SubFoldersCount
41 {
42 get { return SubFolders.Count; }
43 }
44
45 // Constructors
46 public InventoryFolderImpl(InventoryFolderBase folderbase)
47 {
48 agentID = folderbase.agentID;
49 folderID = folderbase.folderID;
50 name = folderbase.name;
51 parentID = folderbase.parentID;
52 type = folderbase.type;
53 version = folderbase.version;
54 }
55
56 public InventoryFolderImpl()
57 {
58 }
59
60 // Methods
61 public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type)
62 {
63 if (!SubFolders.ContainsKey(folderID))
64 {
65 InventoryFolderImpl subFold = new InventoryFolderImpl();
66 subFold.name = folderName;
67 subFold.folderID = folderID;
68 subFold.type = (short)type;
69 subFold.parentID = this.folderID;
70 subFold.agentID = agentID;
71 SubFolders.Add(subFold.folderID, subFold);
72 return subFold;
73 }
74 return null;
75 }
76
77 public InventoryItemBase HasItem(LLUUID itemID)
78 {
79 InventoryItemBase base2 = null;
80 if (Items.ContainsKey(itemID))
81 {
82 return Items[itemID];
83 }
84 foreach (InventoryFolderImpl folder in SubFolders.Values)
85 {
86 base2 = folder.HasItem(itemID);
87 if (base2 != null)
88 {
89 break;
90 }
91 }
92 return base2;
93 }
94
95 public bool DeleteItem(LLUUID itemID)
96 {
97 bool found = false;
98 if (Items.ContainsKey(itemID))
99 {
100 Items.Remove(itemID);
101 return true;
102 }
103 foreach (InventoryFolderImpl folder in SubFolders.Values)
104 {
105 found = folder.DeleteItem(itemID);
106 if (found == true)
107 {
108 break;
109 }
110 }
111 return found;
112 }
113
114
115 public InventoryFolderImpl HasSubFolder(LLUUID folderID)
116 {
117 InventoryFolderImpl returnFolder = null;
118 if (SubFolders.ContainsKey(folderID))
119 {
120 returnFolder = SubFolders[folderID];
121 }
122 else
123 {
124 foreach (InventoryFolderImpl folder in SubFolders.Values)
125 {
126 returnFolder = folder.HasSubFolder(folderID);
127 if (returnFolder != null)
128 {
129 break;
130 }
131 }
132 }
133 return returnFolder;
134 }
135
136 public List<InventoryItemBase> RequestListOfItems()
137 {
138 List<InventoryItemBase> itemList = new List<InventoryItemBase>();
139 foreach (InventoryItemBase item in Items.Values)
140 {
141 itemList.Add(item);
142 }
143 return itemList;
144 }
145 }
146}